Answered step by step
Verified Expert Solution
Link Copied!

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... 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

Quantitative Methods For Business

Authors: David Anderson, Dennis Sweeney, Thomas Williams, Jeffrey Cam

11th Edition

978-0324651812, 324651813, 978-0324651751

More Books

Students also viewed these Programming questions

Question

Please answer the question in the screenshot below:

Answered: 1 week ago

Question

What are the key elements of a system investigation report?

Answered: 1 week ago