Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help, My code is not working correcly with the console. i provided my works and console, please help me fixing my code. import random def

Help, My code is not working correcly with the console. i provided my works and console, please help me fixing my code. import random def display_title(): print("Guess the number!") print() def get_limit(): limit = int(input("Enter the upper limit for the range of numbers: ")) return limit def play_game(limit): number = random.randint(1, limit) print("I'm thinking of a number from 1 to " + str(limit) + " ") while True: guess = int(input("Your guess: ")) if guess < number: print("Too low.") count += 1 elif guess >= number: print("Too high.") count += 1 elif guess == number: print("You guessed it in " + str(count) + " tries. ") return  def main(): display_title() again = "y"  while again.lower() == "y": get_limit() play_game(limit) again = input("Play again? (y/n): ") print() print("Bye!") # if started as the main module, call the main function if __name__ == "__main__": main() 

Console

Guess the number!

Enter the upper limit for the range of numbers: 100 I'm thinking of a number from 1 to 100.

Your guess: 50 Too low. Your guess: 75 Too low. Your guess: 87 Too low. Your guess: 94 Too low. Your guess: 97 Too high. Your guess: 95 Too low. Your guess: 96 You guessed it in 7 tries.

Play again? (y/n): y

Enter the upper limit for the range of numbers: 10 I'm thinking of a number from 1 to 10.

Your guess: 5 Too low. Your guess: 7 Too low. Your guess: 9 Too low. Your guess: 10 You guessed it in 4 tries.

Play again? (y/n): n

Bye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago

Question

7. Determine what feedback is provided to employees.

Answered: 1 week ago