Tommy tried this code, but it couldn't run properly --- only allow one attempt and couldn't get the correct number. Coul

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Tommy tried this code, but it couldn't run properly --- only allow one attempt and couldn't get the correct number. Coul

Post by answerhappygod »

Tommy Tried This Code But It Couldn T Run Properly Only Allow One Attempt And Couldn T Get The Correct Number Coul 1
Tommy Tried This Code But It Couldn T Run Properly Only Allow One Attempt And Couldn T Get The Correct Number Coul 1 (93.94 KiB) Viewed 35 times
what are the correct codes for this problem?
Tommy tried this code, but it couldn't run properly --- only allow one attempt and couldn't get the correct number. Could you please explain to him what the problems are in this code and revise the problems --- still use while True – break statement. [10 marks] import random # Generate a random number to be guessed number = random.randint(1, 100) print ("Guess a magic number between 0 and 100") while True: guess = int(input("Enter your guess: ")) if guess == number: 3 3 print es, the number is", number) elif guess > number: print("Your guess is too high") else: print("Your guess is too low") break
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply