Great job this week with finishing the first weekly problem! 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.
Exercise (click to see the full post and explanation)
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.
Sample solution
Note how a sample correct solution makes liberal use of the
int and
str functions - changing from one
type to another.
A note on printing out the solution n times...
ReplyDeleteafter the line `age = int(input("How old are you: "))`,
times = int(input("How many times should I print this out? "))
print( name + " will be 100 years old in the year " + year) * times )
Also, since operator precedence isn't a huge part of the calculation of the year, `str(2014- age + 100 )` would also suffice :)
Nice stuff, keep up the good work :D