## Learning Objectives

By the end of this session, you will:

- Know the common Python data types: integer, float, string ,boolean
- Work with Python’s built-in data structures: list, tuple, dictionary, set
- Access and update values using indexing and keys

---

## Python Data Types

Python has a few simple types that are used all the time:

```{python}
age = 65                           # Whole number (int)
population = 223000000.0           # Decimal number (float)
country = "Nigeria"                # Text (str)
is_african = True                   # True or False (bool)

print(type(age))
print(type(population))
print(type(country))
print(type(is_african))
```

---

## Strings (Text)

Strings store words or sentences. You can look at parts of them:

```{python}
country = "Nigeria"

print(country[0])      # First letter
print(country[-1])     # Last letter
print(country[0:5])    # First 5 letters: 'Niger'
print(country[0:])     # Letters from position 0 onwards
```

---

## Lists (Ordered Groups)

A list is a group of items in a specific order. Lists can grow or change.

```{python}
countries = ["Nigeria", "Ghana", "Kenya"]

print(countries[0])        # First item
print(countries[-1])       # Last item
print(countries[1:3])      # Items from index 1 to 2

print(countries)
```
```{python}
countries.append("Ethiopia")  # Add a new item

print(countries)
```
```{python}
countries[1] = "Rwanda"       # Change an item

print(countries)
```

---

## Tuples (Fixed Groups)

A tuple is like a list, but you **can’t change** it after it’s created.

```{python}
location = (9.05785, 7.49508)                # Abuja’s coordinates

print("Latitude:", location[0])
print("Longitude:", location[1])
```

Tuples are useful for fixed things like coordinates or dates.

---

## Dictionaries (Labeled Data)

Dictionaries let you store data using a name (key) and value:

```{python}
gdp = {
    "Nigeria": 2229,
    "Ghana": 2183,
    "Kenya": 1801
}

print(gdp)
```
```{python}
print(gdp["Nigeria"])          # Look up Nigeria’s value
```
```{python}
gdp["Nigeria"] = 2300          # Update value
gdp["Ethiopia"] = 1000         # Add new country

print(gdp)
```

---

## Sets (Unique Values)

Sets are like unordered lists, but they **remove duplicates** automatically.

```{python}
languages = {"English", "French", "Swahili", "English"}

print(languages)              # "English" appears only once
```
```{python}
languages.add("Hausa")        # Add new language

print(languages)
```
```{python}
print("Swahili" in languages) # Check if Swahili is included
```

---

## Putting It All Together

We can use these structures together. Example: a list of countries with info.

```{python}
countries_info = [
    {"name": "Nigeria", "population_m": 223},
    {"name": "Ghana", "population_m": 34}
]

for country in countries_info:
    print(country["name"], "has", country["population_m"], "million people")
```

---

## Quick Review

Let’s check what we’ve used:

```{python}
print(type(3))                   # int
print(type(3.0))                 # fl
print(type("Africa"))            # str
print(type(True))                # bool
print(type([1, 2, 3]))           # list
print(type((1, 2)))              # tuple
print(type({"a": 1}))            # dict
print(type({"x", "y", "z"}))     # set
```

---