Python Syllabus Notes
1. Installing Python
- Download Python from the official website.
- Install it on your system.
- Open Python interpreter and execute basic commands like:
```python
print("Hello, Python!")
```
2. Using an IDE
- Install PyCharm or VS Code.
- Create a new Python project.
- Write and execute Python programs.
```python
print("Using an IDE")
```
3. Basic Python Operations
- Printing output:
```python
print("Hello World!")
```
- Arithmetic operations:
```python
a, b = 10, 5
print(a + b, a - b, a * b, a / b)
```
4. Data Types & Student Grade Tracker
- Data Types: `int`, `float`, `str`, `bool`, `list`, `dict`.
- Example:
```python
student = {"name": "John", "grades": [85, 90, 78]}
avg = sum(student["grades"]) / len(student["grades"])
print(f"{student['name']}'s Average Grade: {avg}")
```
5. Flow Control in Python
- Conditional statements:
```python
x = 10
if x > 5:
print("Greater than 5")
```
- Loops:
```python
for i in range(5):
print(i)
```
6. Conditional Expressions
- `and`, `or`, `not` operators:
```python
x, y = True, False
print(x and y, x or y, not x)
```
7. Python Conditions & Loop Control
- Nested Conditions:
```python
x = 10
if x > 5:
if x < 15:
print("Between 5 and 15")
```
- `break`, `continue`, `pass`:
```python
for i in range(5):
if i == 2:
continue # Skips 2
print(i)
```
8. Data Structures
- Lists:
```python
my_list = [1, 2, 3]
print(my_list[0])
```
- Dictionaries:
```python
my_dict = {"name": "Alice", "age": 25}
print(my_dict["name"])
```