Python is a high-level, interpreted programming language known for its readability.
It is widely used in web development, data science, automation, and more.
Python emphasizes clean and simple syntax.
print("Hello, World!")
- Easy to learn
- Large community
- Extensive libraries
Variables store data values.
Python has dynamic typing.
Common data types include integers, floats, strings, and booleans.
x = 10
name = "Alice"
- int
- float
- str
Control flow determines the order in which code executes.
Python uses indentation to define blocks.
if x > 5:
print("Greater than 5")
for i in range(5):
print(i)
- if statements
- for loops
- while loops
Functions are reusable blocks of code.
They help organize programs into modular sections.
def greet(name):
return "Hello " + name
- Defined using def
- Can accept parameters
- Can return values
Python supports object-oriented programming (OOP).
Classes define blueprints for objects.
Objects are instances of classes.
class Person:
def __init__(self, name):
self.name = name
- Classes
- Objects
- Inheritance