हिंदी

What possible output(s) are expected to be displayed on the screen at the time of execution of the following program: import random M=[5, 10, 15, 20, 25, 30] for i in range(1, 3): first - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

What possible output(s) are expected to be displayed on the screen at the time of execution of the following program:

import random
M=[5, 10, 15, 20, 25, 30]
for i in range(1, 3):
first=random.randint(2, 5)-1
sec=random.randint(3, 6)-2
third=random.randint(1, 4)
print(M[first],M[sec],M[third],sep="#") 

विकल्प

  • 10#25#15
    20#25#25
  • 5#25#20
    25#20#15
  • 30#20#20
    20#25#25
  • 10#15#25#
    15#20#10#
MCQ
Advertisements

उत्तर

10#25#15
20#25#25

Explanation:

The randint(x, y) function returns a random value between x and y. In this case, all three calls to the randint() method yield random numbers ranging from 1 to 4 in the list M. 

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2022-2023 (March) Set 4

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×