Skip to content

Latest commit

 

History

History

1.02-lesson-python-control-flow

Review python iteration, control flows, and functions

Unit 1, Lesson 4

Materials We Provide

Topic Description Link
Lesson Jupyter notebook with instructions and empty cells for codealong Link
Exercises Jupyter notebook of 5 challenging exercises Link
Solutions Sample solutions to codealong Link
Exercise Solutions Solution code for 5 challenging exercises Link

Learning Objectives

  • Explore Python control flow and conditional programming.
  • Implement For and While loops to iterate through data structures.
  • Apply if, else conditional statements.
  • Demonstrate error-handling using try, except statements.
  • Combine control flow and conditional statements to solve the classic "FizzBuzz" code challenge.

Student Requirements

Before this lesson(s), students should already be able to:

  • Know python data types: string, int, float, boolean, tuple, list, dictionary

Lesson Outline

Total Time: 90 min

  • Conditional statements (if/else statements)
    • Eat some broccoli ice cream
    • Get feedback on our health test
  • For Loops
    • Greet our instructors
    • Loop through a range
    • Loop through unpacked tuples
  • While Loops
    • Creating a loop that stops randomly
    • Create an infinite loop
  • Error Handling
    • Stop ourselves from accidentally dividing by zero, which would really wreak havoc

Additional Resources

For more information on this topic, check out the following resources:

  • Automate the Boring Stuff with Python: Free book/blog here.