Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.
Question
Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.
✨ Free AI Tools for You
Powered by Chatterbot AI
Answer
Here's a Python program to accomplish that task:
# Program to calculate the year when the user will turn 100 years old
# Taking user's name as input
name = input("Enter your name: ")
# Taking user's age as input and converting it to an integer
age = int(input("Enter your age: "))
# Calculating the current year
from datetime import datetime
current_year = datetime.now().year
# Calculating the year in which the user will turn 100
year_turning_100 = current_year + (100 - age)
# Printing the message with the calculated year
print(f"Hello {name}! You will turn 100 years old in the year {year_turning_100}.")
When you run this program, it will ask for the user's name and age, and then it will calculate and print the year in which they will turn 100 years old.
India's 1st AI Doubt Solver for CBSE, JEE, and NEET
Ask a Question for Freeand then it's just ₹212 a month