Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The codes below can be used to randomly generate an integer number i between the range of 1 and 10 (inclusive). import random irandom.randint
The codes below can be used to randomly generate an integer number i between the range of 1 and 10 (inclusive). import random irandom.randint (1,10) Write a integer number guessing game program, which allows a user to guess the randomly generated number within 5 tries. If user enters a wrong number, display hints, such as the guessed the number is too low or too high to the user. If user enters a correct number, user is considered to have won the game, and "You win with x tries" (x is the total number of tries that the user takes to win the game) message is displayed. If within 5 tries, user is still not able to guess the correct number, user is considered to have lost the game, and "You lose" is displayed. Example of how the game program can run is as follow. Enter a number (1-10] : 5 Your guessed number is too low. Enter a number [1-10] : 7 Your guessed number is too low. Enter a number [1-10] : 9 You win with 3 tries.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import random def numberguessinggame num randomrandint1 10 tr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started