Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem One. Modify your program in Python from Problem Three of HW #7 (coding provided below) so that it records the guessing game in a

Problem One. Modify your program in Python from Problem Three of HW #7 (coding provided below) so that it records the guessing game in a file, as it plays the game. The file should end up looking something like this:

Game 1: The number is 8.

User guesses 5, too low.

User guesses 12, too high.

User guesses 10, too high.

User guesses 8, thats it!

Game 2: The number is 17.

User guesses 22, too high.

User guesses 8, too low.

User guesses 20, too high.

User guesses 13, too low.

User guesses 16, too low.

User guesses 17, thats it!

Game over!!!

Try to match this style.

previous coding:

import random def set_the_number(): """ Function that sets the number """  global _number _number = random.randint(1, maximum) def get_user_guess(): """ Function that reads the guess from user """  guess = int(input("Guess a number between 1 and " + str(maximum) + ": ")) return guess def guessing_game(): """ Function that plays a game """  # Assigning number  set_the_number(); # Iterate till user guess correctly  while True: # Reading guess  guess = get_user_guess() # Comparing  if guess < _number: print("Too low"); elif guess > _number: print("Too high"); else: print("You got it!"); break; def main(): """ Main function """  global maximum maximum = 20 # Loop till user want to quit  while True: # Playing a game  guessing_game() # Reading option  opt = input(" Do you want to play another game(y/n)? "); # Checking input  if opt.lower() != 'y': break; # Calling main function main() 

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

Define Management by exception

Answered: 1 week ago

Question

Explain the importance of staffing in business organisations

Answered: 1 week ago

Question

=+free to pirate employees from competitors?

Answered: 1 week ago