Python for Absolute Beginners Transcripts
Chapter: Code that interacts with users
Lecture: Concept: Conditional statements
0:00 That program we wrote, that was pretty involved.
0:02 Yeah we only used a few core concepts
0:04 but they were really important things that we covered
0:06 and we kind of built this little kind of game challenge
0:09 type thing for our customers that was cool.
0:11 When we want to have some kind of conditional logic
0:15 branching logic, do this or that
0:18 based on some condition
0:19 we used the if the, elif, and the else keywords.
0:22 So in this case we're going to get a number
0:24 some random number and a guess from the user.
0:26 You can imagine how that goes
0:28 from the previous example we just did
0:30 and we're going to test, is the guess too low.
0:33 If it is, we're going to print out a message
0:34 hey the guess is too low.
0:35 If the guess is too high, we're going to say else, if, elif
0:39 is the other test, is the guess too high
0:41 then it's too high.
0:42 If it's not too low, it's not too high
0:44 it must be Goldilocks, it's just right
0:46 so they must be equal.
0:48 We're going to say yes you got it.
0:49 There were however many numbers of M&Ms in the jar.