Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 2: Guess that number game
Lecture: Intro to the app
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Hello and welcome to app number 2 this time we are going to build a game, a guess what number I am thinking of game, and it's going to look like this.
0:10
The program will start up and it will randomly choose a number between 0 and 100 and then it will interact with the user
0:16
going back and forth until they figure out what that number is. It will ask them to enter a number and it will say,
0:21
no, that's too low, no that's too high, and then finally you can see the user was able to figure out, hey, 71 was the number the program selected.
0:29
So, this is a pretty straight forward app, but you are going to learn a lot while we build it. So what specifically?
0:36
Well, we are going to focus on boolean statements and switching between code blocks. So we are going to start up by talking about boolean expressions,
0:46
things like x > y, y is not nothing, the users entered some valid text those kinds of things. And we'll use that in two basic places,
0:55
one is going to be an if, else if categories so if the number is greater than the one you guessed you want to print one thing
1:02
otherwise you might want to print something else like the number is too high no in other case print the number is too low but also in while loops
1:08
because we want our app to go around and around until the person, the user has selected the right number they've guessed the right number.
1:16
We are going to use a conditional test to keep going until the numbers match. Closely related to this boolean concept
1:23
is something I'm calling truthiness. You'll see that objects within Python are embued with a truth or falseness
1:30
we'll leverage that as a key building block in our boolean expressions. We'll also learn about type conversion
1:35
users will enter text but we need to actually work with numbers. Previously we composed strings by using the plus symbol
1:43
but Python has an extremely rich formatting API and we'll start looking at it here we are going to just get into the very basics of function
1:51
as a way to compose our app into more understandable and maintainable building blocks and part of that is going to be understanding code blocks
1:58
which are a little, let's say unique in Python.