Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Python Basics: Conditional Logic and Control Flow (Summary)

In this course, you learned about conditional statements and conditional logic. You saw how to compare values using comparison operators like <, >, <=, >=, !=, and ==. You also saw how to build complex conditional statements using and, or, and not.

Next, you saw how to control the flow of your program using if statements. You learned how to create branches in your program using ifelse and ifelifelse. You also learned how to control precisely how code is executed inside an if block using break and continue.

You learned about the tryexcept pattern to handle errors that may occur during runtime. This is an important construct that allows your programs to handle the unexpected gracefully and keep users happy that the program didn’t crash.

Finally, you applied the techniques that you learned in this course and used the random module to build some coin toss simulations.

For more information on the concepts covered in this course, check out the following tutorials:

Or you can explore the following video courses:

To continue your Python learning journey, check out the other Python Basics courses. You might also consider getting yourself a copy of Python Basics: A Practical Introduction to Python 3.


Sample Code (.zip)

1.6 KB


Course Slides (.pdf)

3.0 MB

00:00 You’ve made it to the end of the course. Well done. In this course, you’ve been comparing lots of values, with numbers and strings and saying if they’re greater than or less than. You’ve used logical operators to combine these comparisons, like and or or or to invert them with not.

00:18 You’ve learned about how to control the flow of your programs by creating branches with if blocks by using loop keywords, like break, and how to combine all this with conditional statements and loops to gain massive control over how your program behaves. And finally, you’ve also learned about errors and exceptions and how to handle them with a try … catch pattern.

00:43 Make sure you practice these constructs a bunch and get them to become second nature. Since these constructs are used all the time when you’re coding, almost all coding languages have nearly identical structures to control the flow of your program. So by learning these well, you are well on your way to becoming a programmer.

01:05 If you’re looking for some additional resources about the topics covered in this course, take a look at the if, else, elif Conditional Statements in Python tutorial, which has an article and a video course.

01:20 You can also check out the article and video courses for the and, or, and not Boolean operators if you want a really deep dive into all the possibilities with them.

01:33 You can also check out the dedicated articles and video courses on for loops, on while loops, and exceptions.

bwhitehd on Jan. 11, 2023

There is nothing in the course slides but a single page with a picture. This should be updated.

Ian RP Team on Jan. 12, 2023

Thanks for letting us know about this oversight! We’ve updated the slides.

Become a Member to join the conversation.