python functions

# 6.189: Introduction to Programming in Python

## Handout: Python Basics

### 1. Variables and Data Types
- **Variables**: Containers for storing data values.
- **Data Types**: Common types include:
  - `int` (integer)
  - `float` (decimal number)
  - `str` (string of characters)
  - `bool` (Boolean: `True` or `False`)

### 2. Operators
- **Arithmetic Operators**: `+`, `-`, `*`, `/`, `//`, `%`, `**`
- **Comparison Operators**: `==`, `!=`, `<`, `>`, `<=`, `>=`
- **Logical Operators**: `and`, `or`, `not`


### 3. Control Flow
#### Conditional Statements:
```python
if condition:
    # Code executes if condition is True
elif another_condition:
    # Code executes if another_condition is True
else:
    # Code executes if no conditions are met


 ## Loops:
**For Loop:**
```python
for i in range(5):
    print(i)  # Prints numbers 0 to 4


**While Loop:**
```python
x = 0
while x < 5:
    print(x)
    x += 1  # Increments x by 1


### 4. Functions
- Functions allow reusable blocks of code.
```python
def greet(name):
    return f"Hello, {name}!"

print(greet("Alice"))


### 5. Lists and Dictionaries
- **Lists**: Ordered collection of items.
```python
fruits = ["apple", "banana", "cherry"]
print(fruits[0])  # Output: apple
person = {"name": "John", "age": 30}
print(person["name"])  # Output: John

Quiz

To mark this module as complete, you must finish this quiz. Once submitted, you'll need to wait 2 hours before attempting it again.