Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    14Topics
    |
    15 Quizzes
  2. Python: Control Flow
    12Topics
    |
    12 Quizzes
  3. Python: Errors
    5Topics
    |
    5 Quizzes
Lesson 2 of 3
In Progress

Python: Control Flow

Yasin Cakal 5 Oct 2021

Consider going for a walk.

You look outside and say, “How is the weather today?”

If this is the case, you must dress up properly before you walk outside. Is it windy? Is it going to rain? Should you eat before you go? Do you need to bring water with you? Did you remember to charge your phone?

These questions and choices direct the course of your decision to walk; each step and result is a product of the day’s conditions and surroundings. Your computer, like you, follows a similar pattern when it executes code. A program will run and proceed through its checklists, determining whether this condition is met, whether that condition is met, and then executing the code and returning that value.

This is the program’s control flow. Python scripts execute in a top-down fashion, until there is nothing left to run. It is your responsibility to include gateways, also known as conditional statements, that inform the computer when certain code blocks should be executed. If these conditions are met, this function will be executed.

This lesson will teach you how to construct conditional statements using boolean expressions and manage control flow in your code.

%d bloggers like this: