age calculator exercise completed

This commit is contained in:
cheeks 2025-06-26 21:15:50 -04:00
parent 7b30662605
commit 9c2b04b11e
2 changed files with 46 additions and 0 deletions

19
age_calc.py Normal file
View File

@ -0,0 +1,19 @@
while True:
try:
age = input("Enter your age: ")
if int(age) > 0 and int(age) < 13:
print("You're a kid!")
elif int(age) >= 13 and int(age) <= 19:
print("You're a teenager!")
elif int(age) >= 20 and int(age) <= 64:
print("You're an adult!")
elif int(age) >= 65 and int(age) <= 160:
print("You're a senior!")
elif int(age) > 160:
print("C'mon bruv, you should be ded by now.")
except ValueError:
print("Invalid input, please try again.")
except Exception as e:
print("Try again!")

27
guessNum.py Normal file
View File

@ -0,0 +1,27 @@
import random
generated_num = random.randint(1, 100)
def get_Num():
return input("Guess the number between 1 and 100: ")
numbers_guessed = []
tries = 0
while True:
guess = get_Num()
if int(guess) == generated_num:
print(f"Correct! You guessed the number in {tries} tries.")
break
elif int(guess) != generated_num:
tries += 1
if int(guess) in numbers_guessed:
print(f"Already tried {guess}.")
continue
elif int(guess) < generated_num:
print("Too low")
elif int(guess) > generated_num:
print("Too high")
numbers_guessed.append(int(guess))