Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone help with this python code with comments? Thanks so much! Part 2: Guess the Number Game Note: This program should NOT be written

image text in transcribedCan anyone help with this python code with comments? Thanks so much!

Part 2: Guess the Number Game Note: This program should NOT be written using a "while" loop. You should be able to write this using "if", "elif" and "else" statements only. Also, you may not use the "sys.exit()" function to cause your program to prematurely quit! Write a program that lets the user guess an integer between 1 and 10. The integer should be randomly selected by your program when it starts up. Your player is allowed to guess three times - if they guess correctly, they win and the program ends. If they guess incorrectly they should be told if the number they guessed was too high or too low and then be asked to guess another time. At the end of the program you shoud display the secret number as well as how many attempts it took to guess that number. You may assume valid input. Here are a few sample runnings of your program: Run #1 I'm thinking of a number between 1 and 10! What's your guess? 5 You got it! The secret number was 5. It took you 1 try to guess the number. Run #2 I'm thinking of a number between 1 and 10! What's your guess? 5 Too low, try again. What's your guess? 8 Too high try again. What's your guess? 7 You got it! The secret number was 7. It took you 3 tries to guess the number. Run #3 I'm thinking of a number between 1 and 10! What's your guess? 5 Too high, try again. What's your guess? 1 Too low, try again. What's your guess? 3 The secret number was 4. You didn't guess the number

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago