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

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad