Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+3 votes
375k views
in Computer by (53.4k points)
closed by

What possible outputs(s) are expected to be displayed on screen at the time of execution of the program from the following code? Also specify the maximum values that can be assigned to each of the variables FROM and TO. 

import random

AR = [20,30,40,50,60,70]; 

FROM = random.randint(1,3) 

TO = random.randint(2,4)

for K in range(FROM,TO + 1):

print (AR[K],end=”# “)

(i)  10#40#70#

(ii)  30#40#50#

(iii)  50#60#70# 

(iv)  40#50#70#

2 Answers

+1 vote
by (15.1k points)
selected by
 
Best answer

Correct option is (ii) 30#40#50#

First AR is declared as a variable and has a series of different numbers.

Then, let FROM be 1 as the limit is given 1 to 3.

Then, let TO be 2 as the limit is given 2 to 4.

Now in for loop FROM is 1 and TO will become 3 as to give (FROM, TO+1).

Now FROM and TO are (1,3)

At last, as K in FROM is 1 and K in TO is 3, the number indexing on 1 to 3 will be printed with # between them.

+1 vote
by (53.3k points)

(ii)  30#40#50# Maximum value FROM,TO is (3,4)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...