

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


1. 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) 1 0#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70# 2. Study the following program and select the possible output(s) from the options (i) to (iv) following it. Also, write the maximum and the minimum values that can be assigned to the variable Y. import random x = random.random( ) y = random. randint (0, 4 ) print ( int (x) , โ : โ , y + int (x)) i) 0 : 0 ii) 1 : 6 iii) 2 : 4 iv) 0 : 3
3. Observe the following program and answer the questions that follow: import random X = 3 N = random. randint(1 , X) for i in range (N): print ( i , โ#โ , i+1) a) What is the minimum and maximum number of times the loop will execute? b) Find out, which option of output(s) out of (i) to (iv) will not be expected from the program? i. 0#1 ii. 1#2 iii. 2#3 iv. 3# 4. Observe the following Python code and find out , which out of the given options i) to iv) are the expected correct output(s).Also assign the maximum and minimum value that can be assigned to the variable โGoโ. import random X =[100,75,10,125] Go = random.randint(0,3) for i in range(Go): print (X[i],"$$",end= โโ) i. 100$$75$$10 ii. 75$$10$$125$$ iii. 75$$10$$ iv. 10$$125$$