Lesson 2
Python Basics
Master the core concepts of Python programming for beginners.
Lesson content
Variables and Data Types
Python is dynamically typed, meaning you don't need to declare variable types explicitly. Python automatically determines the type based on the value assigned.
Common Data Types
- str (String): Represents text
- int (Integer): Whole numbers
- float (Float): Decimal numbers
- bool (Boolean): True or False
- list: Ordered, mutable collection
- tuple: Ordered, immutable collection
- dict: Key-value pairs
Operators
- Arithmetic: +, -, *, /, //, %, **
- Comparison: ==, !=, <, >, <=, >=
- Logical: and, or, not
- Assignment: =, +=, -=, *=, /=
Code example
Practical Python code
# Data types and variables
x = 10 # int
y = 3.14 # float
name = "Python" # str
is_fun = True # bool
# Arithmetic operations
sum_result = x + y
print(f"Sum: {sum_result}")
# String operations
message = name + " is awesome!"
print(message)