# [ ] input a variable: age as digit and cast to int
# if age greater than or equal to 12 then print message on age in 10 years
# or else print message "It is good to be" age
age = input("How old are you?")
age = int(age)
if age >= 12:
print("You will be" , age + 10 , "in a decade")
else:
print("It is good to be" , age)
# [ ] input a number
# - if number is NOT a digit cast to int
# - print number "greater than 100 is" True/False
num = input("Enter a number: ")
if num.isdigit():
num = int(num)
else:
print("Please enter an integer!")
if num > 100:
print(num , "greater than 100 is TRUE")
else:
print(num , "greater than 100 is FALSE")
# [ ] create check_guess()
# call with test
def check_guess(letter , user_guess):
if user_guess.isalpha():
if user_guess == letter:
print(user_guess , "is correct!")
return(True)
elif user_guess > letter:
print(user_guess , "is too high")
return(False)
elif user_guess < letter:
print((user_guess) , "is too low")
return(False)
else:
print("INVALID")
return(False)
# [ ] call check_guess with user input
letter = input("Enter a letter to guess:")
letter = letter.capitalize()
user_guess = input("Enter a guess:")
user_guess = user_guess.capitalize()
check_guess(letter, user_guess)
def check_guess(letter , guess):
if guess.isalpha():
if guess == letter:
print(guess , "is correct!")
return(True)
elif guess > letter:
print(guess , "is too high")
return(False)
elif guess < letter:
print(guess , "is too low")
return(False)
else:
print("INVALID")
return(False)
def letter_guess(letter_answer , count):
if letter_answer.isalpha():
letter_answer = letter_answer.capitalize()
guess = input("Enter a guess:")
guess = guess.capitalize()
didIguessit = check_guess(letter_answer , guess)
if didIguessit == True:
return(True)
else:
count = count + 1
if count < 3:
print ("next guess")
letter_guess(letter_answer , count)
else:
print("User could not guess letter in 3 tries :(")
return(False)
else:
print("INVALID")
letter_answer = input("Enter a letter to guess:")
letter_guess(letter_answer, 0)
# [ ] complete pet conversation
about_pet = input("Tell me something about your pet:")
about_pet = about_pet.lower()
if "dog" in about_pet:
print("My dog once took an entire bite out of a candle.")
print("Thanks for telling me about your dog!")
if "cat" in about_pet:
print("One of my elementary school friends had a cat named Billy Joel.")
print("Thanks for telling me about your cat!")
if "snake" in about_pet:
print("I think one of my cousins have a bunny too.")
print("Thanks for telling me about your bunny!")