Lesson 5Using Python Control Statements
Python supports a variety of control structures that determine how content in a program will work and interact. This module explores those control structures that make creating algorithms possible.
CONTROL STRUCTURES REVIEW
Computers understand only machine language, which uses only binary code (represented as 0s and 1s for humans), but it is hard for humans to write code in binary. As a result, programmers create algorithms within a specified programming language (such as Python) that instruct the computer on the specific actions to take to reach the desired outcome. As programmers code and subsequently compile the code, the compiled code translates from the high-level language (in this case, Python) to the machine-level language that can be understood by the computer. This translation from high-level to low-level language allows the computer to execute the directions given.
In order for a problem to be “computable,” an algorithm must be constructed. If programmers are unable to build an algorithm, we say that the problem cannot be computed. However, if the problem is solvable, the instructions can be presented using three important control structures:
- Sequence
- Selection
Get Job Ready Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.