Bummer! You have been redirected as the page you requested could not be found.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Practice Comparisons in Python!
You have completed Practice Comparisons in Python!
Preview
Let's discuss the challenge and show a working sample of the final program.
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, Ken here.
0:04
In this Python practice session, you'll
get a chance to practice working with data
0:06
types, making comparisons and
reinforcing your skills with if and
0:10
else if statements,
it reinforces what you've learned.
0:15
If you find this practice session
too challenging to complete,
0:20
you might need to review that course.
0:23
I've put a few links in the teacher's
notes for some resources.
0:25
We'll be using workspaces for
this practice, so
0:29
go ahead and open the attached workspace.
0:31
If we open up challenge.py here,
we see some starter code to get us going.
0:33
The challenge we'll be solving is
actually a common one that you might
0:41
see in your career and
it's known as fizz buzz.
0:44
Wait what?
0:47
Fizz buzz?
0:48
Programmers come up with
some funny names for things.
0:50
Actually it comes from a kid's
math game to teach division.
0:53
Check the teachers notes for more.
0:58
Anyway here's the concept of Fizz Buzz.
1:00
We'll ask a user to input a number.
1:03
If the number is divisible by the number
3 remember the module operator we
1:06
print Fizz.
1:11
If it's divisible by
the number 5 we print Buzz.
1:13
If it's divisible by both 3 and
5 we print Fizz Buzz.
1:17
We'll be adding in some
additional features, as well,
1:22
like printing the user's name.
1:25
Don't worry.
1:28
You've got this.
1:29
We've covered all the skills
needed to do this challenge.
1:31
Right now, the code is asking users for
their name and a number.
1:34
I've included some to-do code comments for
items for you to complete.
1:39
I'd like you to read through the to
do comments and complete each one.
1:43
Let's see the completed program in action.
1:47
Remember, to run a Python file,
1:50
we use the Python command along with
the file name we'd like to run.
1:52
We do python, challenge.py.
2:04
Program prompts me for a name.
2:11
My name is Ken.
2:13
Remember.
2:16
Let's try number 6.
2:17
I then prints out my name.
2:18
The number I put in and
the appropriate Fizz Buzz response.
2:22
We see that the number 6 is a Fizz,
it's divisible by 3.
2:26
That's great.
2:30
Let's run it again to see responses for
different numbers.
2:32
Ken.
2:37
We do 10, it's a Buzz.
2:39
Cool!
2:42
Number 8 that's neither
2:48
Let's try 45, which should be,
yep, there it is.
2:53
It's a FizzBuzz and that's it.
2:58
If you get stuck along the way,
check out the teacher's notes for
3:01
links to videos that cover the concepts
needed to complete the session.
3:04
If you're not able to fully
complete the program don't worry.
3:08
When we get back together I'll walk you
through on my approach in the next video.
3:11
See you soon.
3:16
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