Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Take a user's name and birth year. Safely make that year an integer, then calculate when they'll turn 25, 50, 75, and 100. Tell 'em!
Course
Related Videos
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hey there, let's try a bit of Python
practice around taking input from users,
0:04
try and accept blocks, and conditions.
0:09
There's a workspace attached to this
video where you can write your code, or
0:12
you can do it locally by downloading
the workspace through the File menu.
0:15
All right,
let's see what you need to do and
0:20
these instructions are deceptively simple.
0:22
This challenge has three major steps, but
0:25
of course there's probably some minor
steps you'll need to discover on your own.
0:27
First, you need to get input
from the user for their name and
0:30
what year they were born.
0:34
You wanna make sure that they give
you a year that's an integer.
0:35
We don't have Star Trek's
floating point dates just yet.
0:37
Then you'll need to figure out what
year they'll turn 25, 50, 75, and 100.
0:40
It's gonna require some math.
0:46
And lastly, you need to print
out when those years are.
0:48
So I'm kinda leaving this part up to you,
0:51
at least a little bit,
I don't care how you format your message.
0:54
Go ahead and format them however you want.
0:57
It'd be good though if you use their name,
since you asked for it, and
0:59
said something like, Kenneth,
you'll be 50 in the year 2031.
1:02
And don't put out any ages or
years that are already passed.
1:06
These should only be days that
they have to look forward to.
1:09
All right, I'm gonna let you get to it and
I'll see you in the next video
1:12
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up