my_var = "Hello" # this is a string
my_var = 5 # this is an integer
limit: int = 100
name: str = "John"
# list of integers
my_list: list[int | float | bool] = [1, 2.3, True]1 - Types and Type hints
python
Compiled vs Interpreted Language
Compiled languages: Code is translated ahead of time into machine code (via a compiler), then executed directly by the CPU → Faster runtime, errors caught earlier. Example: C, C++
Interpreted languages: Code is executed line-by-line at runtime by an interpreter. → Slower, but more flexible and easier to debug. Example: Python, JavaScript
Dynamic vs Static typing
def verify_password(submitted_password: str, stored_harsh: str = "123456") -> bool:
return TrueIn Python, a class can also be a data type:
class Car:
def __init__(self, name: str, cost: int, brand: str):
self.name = name
self.cost = cost
self.brand = brand
my_car: Car = Car("Morning", 10000, "Kia")Python also support inferred typing.