Write a program that asks the user how old he/she is, currently, then prints out the year (e.g. 2059) when that same user will turn 100 years old. View keyboard shortcutsEditViewInsertFormatToolsTable12ptParagraph
Question
Write a program that asks the user how old he/she is, currently, then prints out the year (e.g. 2059) when that same user will turn 100 years old. View keyboard shortcutsEditViewInsertFormatToolsTable12ptParagraph
Solution
Sure, here is a simple Python program that does what you asked for:
import datetime
# Get the current year
current_year = datetime.datetime.now().year
# Ask the user for their age
age = int(input("How old are you currently? "))
# Calculate the year when the user will turn 100
year_when_100 = current_year + (100 - age)
# Print the result
print("You will turn 100 years old in the year", year_when_100)
This program first gets the current year using the datetime module. Then it asks the user to input their current age. It calculates the year when the user will turn 100 by adding the difference between 100 and the user's current age to the current year. Finally, it prints out the result.
Similar Questions
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 that they will turn 100 years old. Note: for this exercise, the expectation is that you explicitly write out the year (and therefore be out of date the next year).
Write a program that asks for a number and then reports if it is divisible by 3.It will continue to ask again until the user enters 0.View keyboard shortcutsEditViewInsertFormatToolsTable12ptParagraph
Create a function that accepts a parameter / variable (input1) that will contain text. Count how many times a 4 digit year is mentioned in input1. Print the years in descending order alongwith how many times that year is mentioned in input1.* Example:input1 = "In the year 2005, a technological revolution set in motion changes that would ripple through time. By 2012, the seeds of innovation planted earlier blossomed into significant breakthroughs, propelling us into a new era. Now, in 2023, we stand on the threshold of another transformation, building upon the foundations set in past and enriched by the progress of 2023. As this year unfolds, it bears the promise of reshaping industries and lives, a testament to the continuous interplay of progress across different moments in time."* Expected Output:2012 appears 1 time(s)2023 appears 2 time(s)2005 appears 1 time(s)
Complete the main method in the AgeChecker class by Declaring and instantiating a Scanner objectPrint the "What is your age?" message to the consoleDeclaring the int age variable, assigning it the output of nextInt()If the value of age is greater than 40 then print "You are old". Otherwise, print "You are young"
Based on your understanding of the reading assignment, please rewrite the following question.How often do you brush your teeth?View keyboard shortcutsEditViewInsertFormatToolsTable12ptParagraph
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.