mardi 30 décembre 2014

Python code for random number generator not printing as expected

Sorry if this is a silly question I've researched it and found similar code that works and applied the same layout, but for some reason when I run mine it doesn't print num or the true or false result, just a blank line. I'm using Python 2, what am I missing? the rand_divis_3 function should just simply generate a random number and print True or False depending on whether it is divisible by 3. Help much appreciated, I'm new to python



import random
def rand_divis_3():
num = random.randint(0,100)
print num
if num % 3 == 0:
print True
else:
print False




Aucun commentaire:

Enregistrer un commentaire