Python Control Structures
Control Structures
2 types:
Sequential Control Structure
Default flow of a program
Statements execute one after another, in the order they are written
Example:
x = 5
y = x + 2
print (y)
Selection (Decision-Making) Control Structure
Executes different blocks of code based on conditions
Uses logical or relational expressions
if, if-else, elif, switch/case
Example:
x=int(input(“Enter a number “))
if x > 0:
print(“Positive”)
else:
print(“Non-Positive”)