Practice Python

Beginner Python exercises

05 February 2014

Character Input Solutions

Exercise 1

Because I cannot include every single submission I get, I will choose one or two that are example answers and include those within each post.

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.

Solution

name = input("What is your name: ")
age = int(input("How old are you: "))
year = 2014 - age + 100
print(name + ", you will be 100 years old in the year " + str(year))

Enjoying Practice Python?


Explore Yubico
Explore Yubico
comments powered by Disqus