Q. Write a function that receives two numbers and generates a random number from that range Using this function, the main program should be able to print three numbers randomly.
You can understand by Watching video :-
Answer :-
import random def ran(a , b) : print( random . randint(a , b ) ) first = int(input("Enter a number = ")) second = int(input("Enter second number = ")) ran(first , second ) ran(first , second ) ran(first , second )
Output :-
Enter Frist number = 2
Enter Second number = 9
3
9
4
>>>
Enter Frist number = 100
Enter Second number = 1566
1010
1015
651
>>>
Enter Frist number = 56416
Enter Second number = 56166351
38740824
36091125
52147407
>>>
thanks for your answer
ReplyDeleteWelcome.
DeleteU could have used:
ReplyDeletefor i in range(3):
ran(first , second )
instead of:
ran(first , second )
ran(first , second )
ran(first , second )
yes
DeleteRight.
DeleteNice teaching 👍
ReplyDeleteThank you 😊☺️
Deletecan u do it without random module?
ReplyDeleteCan it be done without random module?
ReplyDeletebut it become hard.
DeleteBy user defined function can we do this question ,that is not using randint function
ReplyDeletebut it will become very large.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )