Answer to Question #212065 in Python for Lia

Question #212065

Each user has 100 credits, the user needs to input credits under 100 and the system needs to take the amount the user played and subtract that from the amount of credits the user had, then 3 numbers need to be randomly generated and the machine needs to check if the 3 numbers are the same. If it is the same the user wins double the credits than what they had and is added to the amount of credits they have. If yes to go again, if they won the credits must be added to start again but if they lost, credits must be lost.


1
Expert's answer
2021-06-30T03:16:07-0400


from random import randint
def cred(credit):
    
    n = int(input("Enter credit under 100: "))
    credit = credit-n
    rand1 = randint(0,10)
    rand2 = randint(0,10)
    rand3 = randint(0,10)
    print("Random numbers are:", rand1,rand2,rand3)
    if rand1 == rand2 == rand3:
        bala=credit*2
        credit =credit+bala
        print("New credit is ", credit)
        cred(credit)
    else:
        credit=0
        print("You lost and New credit is ", credit)
        exit()



#main
credit = 100
cred(credit)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS