"""
guessing game design
Sally CS Major
Spring 2020
"""
from random import *
def main():
printIntro()
answer = randrange(1,101)
# for debugging/testing...will delete later
print(answer)
nguesses = 0
done = False
while not done:
nguesses = nguesses + 1
guess = getInt(nguesses)
if guess == answer:
print("Correct!!")
done = True
elif guess > answer:
print("Nope...too high.")
else:
print("Nope...too low")
finalMessage(nguesses)
def printIntro():
"""
Inputs: None
Returns: None
Purpose: To print an introduction to the user.
"""
print("Intro to guessing game...")
def getInt(nguesses):
"""
Inputs: which guess we are on
Returns: integer guessed by user
Purpose: get integer from user, make sure it's valid (1-100)
"""
# will add validation loop later, make sure number is 1-100
# will add guess number to prompt later
n = int(input("your guess: "))
return n
def finalMessage(nguesses):
"""
Inputs: number of guesses it took
Returns: None
Purpose: display message based on how many guesses it took
"""
print("Super.", nguesses)
main()