हिंदी

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. - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

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.

संक्षेप में उत्तर
Advertisements

उत्तर

Program:
#Program to tell the user when they will turn 100 Years old
name = input("Enter your name: ")

# age converted to integer for further calculation
age = int(input("Enter your age: "))

#calculating the 100th year for the user considering 2020 as the current year
hundred = 2020 + (100 - age)

#printing the 100th year
print("Hi", name,"! You will turn 100 years old in the year", hundred)

OUTPUT:
Enter your name: John
Enter your age: 15
Hi John! You will turn 100 years old in the year 2105
shaalaa.com
Operators - Arithmetic Operators (-,+,*,/,%)
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 5: Getting Started with Python - Exercise [पृष्ठ ११८]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
अध्याय 5 Getting Started with Python
Exercise | Q 19. | पृष्ठ ११८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×