Index
1. Introduction to Python
2. Variables and Data Types
3. Operators
4. Control Flow
5. Functions
6. Collections
7. Modules and Packages
8. File Handling
9. Error Handling
10. Object-Oriented Programming
1. Introduction to Python
What is Python?
- High-level, interpreted programming language
- Created by Guido van Rossum, first released in 1991
- Features of Python:
- Easy to read and write
- Extensive standard library
- Dynamic typing
- Cross-platform compatibility
Example:
print("Hello, World!")
2. Variables and Data Types
- Variables:
- Containers for storing data values
- Dynamic typing
, - Declaration: No need for explicit declaration
Example:
x=5
name = "Alice"
- Data Types:
- Numbers:
- Integer (`int`)
- Floating Point (`float`)
- String (`str`):
- Text data
- Boolean (`bool`):
- True or False
- NoneType:
- Represents the absence of value
Example:
x = 42 # int
y = 3.14 # float
name = "Bob" # str
is_valid = True # bool
nothing = None # NoneType
3. Operators
- Arithmetic Operators:
- Addition (`+`)
- Subtraction (`-`)
- Multiplication (`*`)
- Division (`/`)
- Modulus (`%`)
- Exponentiation (`**`)
- Floor Division (`//`)
Example:
a = 10
b=3
print(a + b) # 13