Exercise 1:
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year they will turn 100 years old.
Note: For this exercise, the expectation is that you explicitly write out the year (and therefore it will be out of date the next year).
Solution 1:
name = input("Please, enter your name here: ")
age = input("Please, enter your age here: ")
age = int(age)
current_year = input("Please, enter the current year here: ")
current_year = int(current_year)
year_turning_100 = current_year - age + 100
print(name, "you will be 100 years old in", year_turning_100)
Example Output:
Please, enter your name here: Mofasa
Please, enter your age here: 34
Please, enter the current year here: 2025
Mofasa you will be 100 years old in 2091
By Youssaf Menacer, PhD
Comments
Post a Comment