In this blog post, you will understand that How to Write a program in Python that asks the user to enter their name and age. Print out a message that tells them which year he/she will become 100 years old.
.
Source Code
.
name = str(input(“Enter Your Name : “))
age = int(input(“Enter Your Age : “))
years = str((2020-age)+100)
print(name+”will be 100 years old in the year of “+years)
.
Above Python Program Explanation below :
In the above program,
.
first, we had taken two inputs from the user,
.
Enter Your Name
Enter Your Age
In the first input, we have taken the name of the user for that we have to use str (String),
.
the second thing we have taken the Age of user for that we have to use int (Integer).
.
After that, we had done some calculations
.
years=str((2020-age)+100)
.
The above statements is used to find in which year he/she will become 100 years old.
.
We have use str before that calculation because to add str + int (Concatenation)
Top comments (3)
Hi Can you teach python?
Yes💻
Thank you very much