000001 Lecture 2: Control Flow and Indentation in Python

4 views3 pages
20 Mar 2023
Department
Course
Professor

Document Summary

A program"s control flow is the order in which the program"s code executes. The control flow of a python program is regulated by conditional statements, loops, and function calls. The problem with sequential statements is that if the logic has broken in any one of the lines, then the complete source code execution will break. a=20. >>> print("subraction is :", c) subraction is : 10: selection: in python, the selection statements are also known as decision control statements or branching statements. The selection statement allows a program to test several conditions and execute instructions based on which condition is true. Decision control statements are: simple if if-else, nested if if-elif-else. Simple if: if statements are control flow statements that help us to run a particular code, but only when a certain condition is met or satisfied. A simple if only has one condition to check.