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