samedi 21 septembre 2019

Can anyone help me in this python-if-else task?

Assignment image

import random

n = random.randint(1,100)
if (n % 2 != 0):
    print("Weird")
elif (n % 2 == 0 and n in range(2,5)):
    print("Not Weird")
elif (n % 2 == 0 and n in range(6,20)):
    print("Weird")
elif (n % 2 == 0 and n > 20):
    print("Not Weird")    

Is there any problem with this code?

Aucun commentaire:

Enregistrer un commentaire