Python BasicsπΉ
Variables = Store data for use in a program
x = 1
print(x) # Output: 1
πΉ
Data Types = Classification of data (Boolean, String, Number)
number = 10
if number > 0:
print("The number is true") # Output: true
πΉ
Operators = Symbols for performing operations (+, -, *, /, %, etc.)
print(1 + 2) # Output: 3
print(2 - 1) # Output: 1
πΉ
Control Statements = Manage program execution flow
β
Conditional Statements β "if-then" logic
score = 85
if score >= 90:
print("Excellent")
elif score >= 75:
print("Good job")
else:
print("Keep trying")
β
Loop Statements β Repeat actions (for, while loops)
count = 1
while count <= 5:
print(count)
count += 1
πΉ
Functions = Reusable blocks of code
def my_function():
print("Hello from a function")
my_function() # Output: Hello from a function