CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

ABC School has allotted unique token IDs from (1 to 600) to all the parents for facilitating a lucky draw on the day of their Annual day function. The winner would receive a special prize. Write a program using Python that helps to automate the task.(Hint: use random module)

Open in App
Solution

It is suggested in the question to use the 'random' module. Therefore, ‘randint()’ function can be used which will return a random integer within the given range as parameters.

Program:
from random import randint

#Defining the function to generate the random number between 1 and 600
def generateRandom():
print("The winner of the lucky draw is the parent with token id: ",randint(1, 600))
print("")


#calling the function
generateRandom()


OUTPUT:
The winner of the lucky draw is the parent with token id: 313

flag
Suggest Corrections
thumbs-up
4
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Frequency Distribution Table
STATISTICS
Watch in App
Join BYJU'S Learning Program
CrossIcon