Conditionals and Control Flow

April Speight · 2020

Python can make decisions when executing code based on the logic added to a script. The logic determines what should happen if the code encounters a situation that is either true or false. In Python, the situation is called a condition. A script can contain one or many conditions all with their own set of actions. Comparison operators are used to compare two values. When using a comparison operator, Python will return a Boolean value of either true or false. Logical operators can be used to evaluate whether two or more expressions are true or not true. These operators can also be used to compare conditions that consist of strings. This chapter describes the use of if statements, if-else statements, and if-elif-else statements in Python. It also includes a project to create a Python program that tells what to wear based on the weather conditions.

Read the paper · More papers on PaperTik