Programming Examples
Write a function with name dividebyfive which generate and prints a random integer number from the range 0 to 100 and then return True if the randomly generated number is divisible by 5, and False otherwise.
Write a function with name dividebyfive which generate and prints a random integer number from the range 0 to 100 and then return True if the randomly generated number is divisible by 5, and False otherwise.
Solution
import random
def divbyfive():
num=random.randint(1,100)
print("Random genrated Number :",num)
if num%5==0:
return True
else:
return False
x=divbyfive()
print(x)
Output
Random genrated Number : 42
False