The final Python assignment is testing your code readability and commenting. Submit Python 3 code that contains a small game. The only requirements for the game are: * The player/user must make at...

1 answer below »
see attached file



The final Python assignment is testing your code readability and commenting. Submit Python 3 code that contains a small game. The only requirements for the game are: * The player/user must make at least three decisions during the game. * You must define one function of your own that is called later in the script. * You must check user inputs for reasonable mistakes but feel free to be creative when handling (ie: the user enters anything with a 'y' can be taken as a 'yes' since this is how early games like Zork actually worked). * You must comment your code thoroughly. There should not be large sections of your code that just run mysteriously. Every named variable should make sense and most should be mentioned in comments. All functions should be mentioned in comments. Loops should be explained as well as any switches. Organize your code to be efficient, neat, and well organized. Submit this code as a py file. You may use whatever Python modules you wish and that I can import from the default install of Python from python.org.
Answered 3 days AfterApr 04, 2021

Answer To: The final Python assignment is testing your code readability and commenting. Submit Python 3 code...

Pratap answered on Apr 08 2021
150 Votes
"""
-----NUMBER GUESSING GAME-----
Given the number of tries as you wish,
if you guess the secret
number, you WIN,
else you LOSE!
"""
#import libraries
from random import randint
def get_user_input():
"""Function to obtain user guess number"""
try:
guess = int(input("Please enter your number of guess: ")) #user guess
return guess #return the guess input
except:
print("Invalid input", Exception.__class__) #exception handling
return None #return none object
def get_random_number(lb, ub):
"""Function to generate random number"""
return randint(lb, ub) #return random number generated
def is_higher_or_lower(target, current):
"""Function to check whether the guess
is higher or lower than secret number"""
#target - target number to guess
#current - current number guessed
#Check if target is lesser or greater than current
if target < current:
return "High guess! (Hint: Try...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here