Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need to a write a program in PYTHON with the below instructions. ---Cre

ID: 3808539 • Letter: H

Question

Hello, I need to a write a program in PYTHON with the below instructions.

---Create an application that asks the user to guess a random number between X and Y; where X and Y are configurable.

---The program should ask the user if they would like to play again. Keep track of the number of sessions.

-Display instructions to the user explaining the program.

Hello, what is your name?

-Ask the question:

Hi <<Name Entered above>>, I am thinking of a number between ___ and ___.

Guess the number: 10

-Indicate whether the number is too high or low

Your guess is too high. Try again: 5

-Indicate whether the number is too high or low

Your guess is too low. Try again: 7

You guessed right Bob! It took you 3 tries!

Ask the user if they want to re-run the program

Notes:

Most importantly, your solution should demonstrate your knowledge of EACH OF the following topics:

- import statements

- Modules

- while statements

- Conditions / Comparisons

- Data Types

- Making Decisions (switch/case, if/else, etc.)

- Repeating Instructions (while, for, etc.)


Extra credit is possible for creativity There should be a counter displaying the session number. Be creative outputting the High/Low values. Maybe keep track of what numbers were too high and too low and show them appropriately. Hint: Think of sorted list(s).

Explanation / Answer

PROGRAM CODE:

# This is a guess the number game.
import random

x = 1;
y = 20;
totalGames = 0;
totalWins = 0;
choice = 'y';
guessesTaken = 0
myName = input('Hello! What is your name?')
number = random.randint(x, y)
print('Hello, ' + myName + ', I am thinking of a number between ' + str(x) + ' and ' + str(y) + '.')
while choice == 'y':
   totalGames += 1;
   while guessesTaken <=5:
   guess = input('Take a guess: ')
   guess = int(guess)
   guessesTaken = guessesTaken + 1
   if guess < number:
   print('Your guess is too low.')
   if guess > number:
   print('Your guess is too high.')
   if guess == number:
   break;
   if guess == number:
       totalWins += 1;
       guessesTaken = str(guessesTaken)
       print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + ' guesses!')
   if guess != number:
       number = str(number)
       print('Nope. The number I was thinking of was ' + number)
   choice = input('Do you want to play again?(y/n): ')

print('You have played ' + str(totalGames) + ' game(s) and you have won ' + str(totalWins) + ' time(s).');

OUTPUT:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote