mardi 30 mars 2021

The number shown starts at 10 and increases by a random amount until 60 is reached

The number shown starts at 10 and increases by a random amount until 60 is reached. Write an subroutine that will achieve this. E.g 10% off. 24% off. 48% off. 60% off.

That is what the code is supposed to do. This is the code I have written so far. It only prints out 0% insted of the full thing

import random

#subroutine to show discounts

def Percent(total, Num):
    while total != 60:
        total = total + Num
    return total, Num

#main program
Num = random.randint(0,10)
total = 10
print(total,"% off")

ps Im quite new to python so if the fix is really obvious please dont be mean about it :)




Aucun commentaire:

Enregistrer un commentaire