samedi 11 juin 2016

Which number is bigger and by how much for random numbers

I'm doing an online tutorial on python, and its asking to write a program that takes two random integers as parameters and display which integar is larger and by how much using a void function. But if both random intgars are the same the def show-larger should handle that too. So in the main section I have written the code to generate 2 random numbers, I'm not sure how to do the next step and call show_larger with the integers as arguments. The example solutions that are given are 3 is larger than 1 by 2 and The integers are equal, both are 3. This is what I have so far:

def main():
value_1=random.randrange(1,6)
value_2=random.rangrange(1,6)

def show_larger():    
difference= value_1=-value_2
if value_1 == value_2:
    print('The integers are equal, both are' + str(value_1))




Aucun commentaire:

Enregistrer un commentaire