Skip to content

Instantly share code, notes, and snippets.

@shak360
Created May 20, 2017 08:18
Show Gist options
  • Save shak360/2834d9102ea3e2a57db6debccc489987 to your computer and use it in GitHub Desktop.
Save shak360/2834d9102ea3e2a57db6debccc489987 to your computer and use it in GitHub Desktop.
# 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.
# Add on to the previous program by asking the user for another number
# and printing out that many copies of the previous message.
# Print out that many copies of the previous message on separate lines.
# (Hint: the string "\n is the same as pressing the ENTER button)
import datetime
now = datetime.datetime.now()
currentYear = int(now.year);
nameOfPerson = input("Enter your name: ");
ageOfPerson = int(input("Enter your age: "));
print (nameOfPerson, ageOfPerson);
yearPersonTurns100 = [(currentYear - ageOfPerson) + 99];
print ("The year in which you will turn 100 is {}".format(yearPersonTurns100))
printNumber = int(input("How many times would you like this message to be printed out?"))
if (printNumber != 0):
for i in range(1,printNumber):
print ("The year in which you will turn 100 is {}".format(yearPersonTurns100))
print ("Have a nice day!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment