# 30 Days Of Python — User Guide

## 1. Quick Start

**30 Days Of Python** is a structured, 30-day programming challenge that teaches Python from absolute beginner to intermediate level through daily lessons with hands-on exercises. Each day introduces a focused topic — from variables and operators through web scraping, APIs, and data analysis — with annotated code examples and practice problems.

**Key features:**

- 30 progressive daily lessons covering the full Python fundamentals spectrum
- Hands-on `.py` example files for every topic with inline comments explaining each line
- Practice exercises and challenges at the end of each day
- Sample Flask web application demonstrating Python for web development
- Real-world datasets (CSV, JSON, TXT) for data manipulation exercises
- Available in 7 languages: English, Chinese, Korean, German, Spanish, Persian, Portuguese
- Covers modern Python libraries including NumPy, Pandas, Flask, and MongoDB

**Prerequisites:** Python 3.6 or higher installed on your system.

**Get started in 2 minutes:**

```bash
git clone https://github.com/Asabeneh/30-Days-Of-Python.git
cd 30-Days-Of-Python
python 01_Day_Introduction/helloworld.py
```

```text
Hello World!
5
1
6
5
1
6
2.0
3.0
3.5
3
1
3
9
<class 'int'>
<class 'float'>
<class 'complex'>
<class 'str'>
<class 'list'>
<class 'dict'>
<class 'set'>
```

> [!TIP]
> Start with Day 1 and progress sequentially. Each day builds on the previous day's concepts — skipping days may leave gaps in your understanding.

**What to try next:**

- Open the Day 1 markdown lesson (`01_Day_Introduction`) for the full walkthrough
- Move to Day 2 to learn about variables and built-in functions
- Check the `python_for_web/` directory for the Flask web application example

## 2. Installation

### System Requirements

| Requirement | Minimum | Recommended |
|---|---|---|
| Python | 3.6+ | 3.10+ |
| Git | Any recent version | Latest |
| Disk space | ~50 MB | ~100 MB |
| OS | Windows, macOS, Linux | Any |

### Getting the Repository

=== "HTTPS"
    ```bash
    git clone https://github.com/Asabeneh/30-Days-Of-Python.git
    ```

=== "SSH"
    ```bash
    git clone git@github.com:Asabeneh/30-Days-Of-Python.git
    ```

=== "GitHub CLI"
    ```bash
    gh repo clone Asabeneh/30-Days-Of-Python
    ```

### Verifying Python Installation

```bash
python --version
```

```text
Python 3.13.0
```

> [!IMPORTANT]
> On some systems, Python 3 is invoked with `python3` instead of `python`. If `python --version` shows Python 2.x or is not found, try `python3 --version`.

### Installing Dependencies for the Web Project

The Day 26 Flask web application requires additional packages:

```bash
cd python_for_web
pip install -r requirements.txt
```

| Package | Version | Purpose |
|---|---|---|
| `Flask` | 1.1.1 | Web framework |
| `Jinja2` | 2.10.3 | Template engine (Flask dependency) |
| `Werkzeug` | 0.16.0 | WSGI utilities (Flask dependency) |
| `Click` | 7.0 | CLI interface (Flask dependency) |
| `itsdangerous` | 1.1.0 | Data signing (Flask dependency) |
| `MarkupSafe` | 1.1.1 | String escaping (Flask dependency) |

### Optional Dependencies for Later Days

These packages are covered in the later lessons but are not included in a requirements file. Install them as you reach the relevant day:

| Day | Package | Install Command |
|---|---|---|
| Day 22 (Web Scraping) | `beautifulsoup4`, `requests` | `pip install beautifulsoup4 requests` |
| Day 24 (Statistics) | `numpy` | `pip install numpy` |
| Day 25 (Pandas) | `pandas` | `pip install pandas` |
| Day 27 (MongoDB) | `pymongo` | `pip install pymongo` |
| Day 28-29 (APIs) | `requests`, `flask` | `pip install requests flask` |

> [!WARNING]
> The `requirements.txt` in `python_for_web/` pins older versions of Flask and its dependencies. If you encounter compatibility issues with newer Python versions, consider creating a virtual environment (covered in Day 23) and installing the pinned versions there.

### Post-Install Verification

Run the Day 1 example to confirm everything works:

```bash
python 01_Day_Introduction/helloworld.py
```

If you see `Hello World!` followed by arithmetic results, your setup is complete.

## 3. Configuration

This project requires no configuration for most lessons. The only configurable setting is in the Flask web application:

| Variable | Type | Default | Description |
|---|---|---|---|
| `PORT` | Environment variable | `5000` | Port number for the Flask web server |

To change the port:

```bash
export PORT=8080
python python_for_web/app.py
```

> [!NOTE]
> The Flask app runs with `debug=True` by default. This is appropriate for learning but should never be used in production. See the Admin Guide for deployment considerations.

## 4. Core Usage

### Following the 30-Day Curriculum

The course is organized into 30 daily directories, each containing:

- A **markdown lesson** (`XX_topic.md`) with explanations, diagrams, and examples
- A **Python script** (`day_X.py` or similar) with executable example code
- **Exercises** at the end of each lesson to practice

**Daily workflow:**

1. Read the day's markdown file for concepts and explanations
2. Run the corresponding `.py` file to see examples in action
3. Complete the exercises at the end of the lesson
4. Move to the next day

### Curriculum Overview

| Day | Topic | Key Concepts |
|---|---|---|
| 1 | Introduction | Python shell, Hello World, data types, `print()`, `type()` |
| 2 | Variables & Built-in Functions | Variable declaration, `len()`, `input()`, type casting |
| 3 | Operators | Arithmetic, comparison, logical, assignment, identity, membership |
| 4 | Strings | String creation, formatting, methods (`capitalize`, `split`, `replace`, etc.) |
| 5 | Lists | Creating, accessing, slicing, modifying, sorting lists |
| 6 | Tuples | Immutable sequences, tuple operations |
| 7 | Sets | Set creation, union, intersection, difference |
| 8 | Dictionaries | Key-value pairs, dictionary methods |
| 9 | Conditionals | `if`, `elif`, `else`, nested conditions |
| 10 | Loops | `for`, `while`, `break`, `continue`, `range()` |
| 11 | Functions | Defining, parameters, return values, default/arbitrary args |
| 12 | Modules | Importing modules, creating custom modules |
| 13 | List Comprehension | Compact list creation, filtering, lambda |
| 14 | Higher-Order Functions | `map()`, `filter()`, `reduce()`, closures |
| 15 | Type Errors | Common Python type errors and debugging |
| 16 | Date & Time | `datetime` module, formatting, `timedelta` |
| 17 | Exception Handling | `try`, `except`, `finally`, custom exceptions |
| 18 | Regular Expressions | `re` module, patterns, `match()`, `search()`, `findall()` |
| 19 | File Handling | Reading, writing, appending files (txt, json, csv) |
| 20 | Package Manager | `pip`, creating packages, `__init__.py` |
| 21 | Classes & Objects | OOP basics, inheritance, methods, polymorphism |
| 22 | Web Scraping | `beautifulsoup4`, `requests`, extracting data |
| 23 | Virtual Environment | `venv`, `virtualenv`, isolated environments |
| 24 | Statistics | `numpy`, statistical calculations |
| 25 | Pandas | DataFrames, Series, data manipulation |
| 26 | Python for Web | Flask basics, routes, templates |
| 27 | MongoDB | `pymongo`, CRUD operations, MongoDB Atlas |
| 28 | APIs | Consuming APIs with `requests`, JSON handling |
| 29 | Building APIs | Creating REST APIs with Flask |
| 30 | Conclusions | Review and next steps |

### Running Code Examples

Each day's Python file can be run directly:

```bash
python 03_Day_Operators/day-3.py
```

```text
Addition:  3
Subtraction:  1
Multiplication:  6
Division:  2.0
Division:  3.0
Division:  3.5
Division without the remainder:  3
Modulus:  1
Division without the remainder:  2
Exponential:  9
```

> [!TIP]
> Use the Python interactive shell (`python` or `python3`) to experiment with individual code snippets from the lessons. Copy-paste examples and modify them to deepen understanding.

### Working with Custom Modules (Day 12)

The repository includes two example modules that demonstrate Python's import system:

**`mymodule.py`** (root directory):

```python
from mymodule import generate_full_name, sum_two_nums, person, gravity
```

**`12_Day_Modules/main.py`** demonstrates importing:

```bash
cd 12_Day_Modules
python main.py
```

```text
Asabneh Yetayeh
10
100
981.0
{'firstname': 'Asabeneh', 'age': 250, 'country': 'Finland', 'city': 'Helsinki'}
Asabeneh
```

### Working with the Package Example (Day 20)

The `mypackage/` directory demonstrates creating Python packages with `__init__.py`:

```text
mypackage/
├── __init__.py
├── arithmetics.py    # add_numbers, subtract, multiple, division, remainder, power
└── greet.py          # greet_person
```

```python
from mypackage.arithmetics import add_numbers, subtract, power
from mypackage.greet import greet_person

print(add_numbers(1, 2, 3))          # 6
print(subtract(10, 3))               # 7
print(power(2, 8))                   # 256
print(greet_person('John', 'Doe'))   # John Doe, welcome to 30DaysOfPython Challenge!
```

> [!NOTE]
> The `20_Day_Python_package_manager/` directory contains a similar set of functions (`arithmetic.py` and `greet.py`) used for the Day 20 lesson. These mirror the `mypackage/` code — both demonstrate the same package creation concepts.

### Running the Flask Web Application (Day 26)

```bash
cd python_for_web
pip install -r requirements.txt
python app.py
```

```text
 * Serving Flask app "app" (lazy loading)
 * Environment: production
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
```

The application provides these pages:

| Route | Method | Description |
|---|---|---|
| `/` | GET | Home page listing web technologies |
| `/about` | GET | About page |
| `/post` | GET, POST | Text analyzer input form |
| `/result` | GET | Analysis result page |

Open `http://localhost:5000` in your browser to explore.

### Working with the Sample Data Files

The `data/` directory contains datasets used in later lessons:

| File | Format | Used In | Content |
|---|---|---|---|
| `countries_data.json` | JSON | Day 19, 28 | Country information |
| `cats.json` | JSON | Day 28 | Cat breeds API data |
| `donald_speech.txt` | TXT | Day 18 | Text for regex exercises |
| `michelle_obama_speech.txt` | TXT | Day 18 | Text for regex exercises |
| `romeo_and_juliet.txt` | TXT | Day 19 | Text for file handling |
| `hacker_news.csv` | CSV | Day 25 | Hacker News posts |
| `weight-height.csv` | CSV | Day 25 | Anthropometric data for Pandas |

The `files/` directory contains smaller examples:

| File | Format | Purpose |
|---|---|---|
| `csv_example.csv` | CSV | File reading exercise |
| `json_example.json` | JSON | JSON parsing exercise |
| `xml_example.xml` | XML | XML parsing exercise |
| `reading_file_example.txt` | TXT | Basic file I/O |

### Using the Course in Other Languages

Translations are available in dedicated directories:

| Language | Directory | Coverage |
|---|---|---|
| Chinese | `Chinese/` | Days 2–30 |
| Korean | `Korean/` | Days 2–5, 7–8, 10 |
| German | `German/` | Days 2–30 |
| Spanish | `Spanish/` | Days 1–30 (with code files) |
| Persian | `Persain/` | Days 2–30 |
| Portuguese | `Portuguese/` | Day 2 |
| Ukrainian | `Ukrainian/` | README only |

> [!WARNING]
> Translation coverage varies significantly. German, Spanish, and Chinese have the most complete translations. Korean and Portuguese cover only a subset of days.

## 5. Common Tasks

### Setting Up a Virtual Environment for the Course

```bash
python -m venv venv
```

=== "Linux/macOS"
    ```bash
    source venv/bin/activate
    ```

=== "Windows"
    ```bash
    venv\Scripts\activate
    ```

Then install any packages you need:

```bash
pip install flask beautifulsoup4 requests numpy pandas pymongo
```

### Creating Your Own Module

Following the Day 12 pattern:

1. Create a file named `my_math.py`:
   ```python
   def circle_area(radius):
       import math
       return math.pi * radius ** 2
   ```
2. Import and use it:
   ```python
   from my_math import circle_area
   print(circle_area(10))  # 314.159...
   ```

### Creating Your Own Package

Following the Day 20 / `mypackage` pattern:

1. Create a directory with `__init__.py`:
   ```text
   my_utils/
   ├── __init__.py
   └── helpers.py
   ```
2. Add functions to `helpers.py`
3. Import: `from my_utils.helpers import my_function`

### Practicing String Methods

The Day 4 example file demonstrates every major string method. Run it and compare output:

```bash
python 04_Day_Strings/day_4.py
```

Key methods covered: `capitalize()`, `count()`, `endswith()`, `find()`, `format()`, `isalnum()`, `isalpha()`, `isdecimal()`, `isdigit()`, `isidentifier()`, `islower()`, `isupper()`, `isnumeric()`, `join()`, `strip()`, `replace()`, `split()`, `title()`, `swapcase()`, `startswith()`.

### Practicing List Operations

Run the Day 5 example file for a comprehensive walkthrough of list operations:

```bash
python 05_Day_Lists/day_5.py
```

Operations demonstrated: creating, indexing, negative indexing, slicing, modifying, membership testing (`in`), `append()`, `insert()`, `remove()`, `del`, `clear()`, `copy()`, concatenation (`+`), `extend()`, `count()`, `index()`, `reverse()`, `sort()`.

### Scraping a Web Page (Day 22)

The repository includes a sample scraped dataset (`22_Day_Web_scraping/scrapped_data.json`). To practice web scraping yourself:

```bash
pip install beautifulsoup4 requests
python -c "
from bs4 import BeautifulSoup
import requests
url = 'https://example.com'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
print(soup.title.string)
"
```

> [!CAUTION]
> Always check a website's `robots.txt` and terms of service before scraping. The Day 22 lesson teaches techniques — use them responsibly.

### Connecting to MongoDB (Day 27)

You need a MongoDB instance (local or Atlas). After installing `pymongo`:

```bash
pip install pymongo
```

Follow the Day 27 lesson (`27_Day_Python_with_mongodb/27_python_with_mongodb.md`) for MongoDB Atlas setup instructions including screenshots.

### Building a REST API (Day 29)

The Day 29 lesson walks through creating a Flask-based REST API. The concepts build on the Day 26 Flask introduction.

## 6. Troubleshooting

### Error: `ModuleNotFoundError: No module named 'mymodule'`

**Cause:** Running `12_Day_Modules/main.py` from the wrong directory. The `mymodule.py` file must be accessible from the current directory.

**Solution:**

1. Navigate to the `12_Day_Modules/` directory:
   ```bash
   cd 12_Day_Modules
   python main.py
   ```
2. Or run from the repo root with the module path:
   ```bash
   python -m 12_Day_Modules.main
   ```

**Prevention:** Always `cd` into the directory containing the script before running it, or ensure `mymodule.py` is in your Python path.

### Error: `ModuleNotFoundError: No module named 'flask'`

**Cause:** Flask and its dependencies are not installed.

**Solution:**

```bash
cd python_for_web
pip install -r requirements.txt
```

**Prevention:** Create a virtual environment and install dependencies before running the Flask application.

### Error: `SyntaxError: invalid syntax` in Day 1

**Cause:** Running Python 2 instead of Python 3.

**Solution:**

```bash
python3 01_Day_Introduction/helloworld.py
```

**Prevention:** Verify your Python version with `python --version` — it should show 3.6+.

### Error: 404 on Day 22 Ukrainian translation

**Cause:** Known issue — the Ukrainian Day 2 file has a broken link. (See GitHub issue #769.)

**Solution:** Use the English version or another available translation.

### Content Issues in Exercises

**Issue:** Several community-reported content errors exist:

- Day 7: Uses "list" where it should say "set" (#823)
- Day 4: Duplicated exercises (#565), incorrect boolean comment in line 159 (#797, #796)
- Day 14: Wrong question text (#808)
- Day 1: Minor code mistake (#807)

> [!NOTE]
> These are known upstream issues in the repository. They do not affect the core learning material. Check the GitHub issues page for the latest status and corrections.

**Solution:** When you encounter a discrepancy, check the lesson's markdown file for the corrected explanation, or consult the GitHub issues.

### Flask App: Form Submission Does Not Show Results

**Cause:** The `/post` route captures form content but redirects to `/result` without passing the data. The `result.html` template renders independently.

**Solution:** This is a teaching example showing the request/redirect pattern. To make it functional, you would need to pass the analyzed data to the result template (an exercise for the learner).

### Package Import Errors with `mypackage`

**Cause:** Running from a directory where `mypackage/` is not visible.

**Solution:** Run from the repository root:

```bash
python -c "from mypackage.arithmetics import add_numbers; print(add_numbers(1,2,3))"
```

```text
6
```

> [!WARNING]
> Python module imports are sensitive to the working directory. Always ensure you are in the correct directory or have configured your `PYTHONPATH`.

## 7. FAQ

**Q: Do I need prior programming experience to start this course?**

No. Day 1 starts from absolute zero — installing Python and printing "Hello World." The course is designed for complete beginners.

**Q: Can I skip days or do them out of order?**

The course is designed to be sequential, with each day building on prior concepts. However, if you already know basic Python (Days 1–10), you could start from Day 11 (Functions) or later. Days 22–29 are relatively independent topic explorations.

**Q: Which Python version should I use?**

Python 3.6 or higher. The code examples use f-strings (introduced in 3.6) and other modern Python features. Python 2 is not supported.

**Q: How long does each day actually take?**

Each day's material typically takes 1–3 hours depending on the topic complexity and how many exercises you complete. Days 25–29 (Pandas, Flask, MongoDB, APIs) tend to be longer.

**Q: Are the translations maintained as actively as the English version?**

The Chinese, German, and Spanish translations are the most complete (covering Days 2–30). Korean and Portuguese have partial coverage. Translation updates may lag behind the English version.

**Q: Why does the Flask app use such old package versions?**

The `requirements.txt` pins Flask 1.1.1 and its dependencies, which were current when the project was created. These versions work correctly for learning purposes. For production use, upgrade to the latest Flask release.

**Q: Can I use this material for teaching or workshops?**

Check the repository's license for terms. The project is designed as a self-paced learning challenge but the structured daily format works well for classroom settings.

**Q: Where are the exercises?**

Exercises are at the end of each day's markdown file (e.g., `04_Day_Strings/04_strings.md`). They are not in the `.py` files — the `.py` files contain the lesson examples.

**Q: What is the `old_files/` directory?**

It contains earlier versions of the README that have been superseded by the per-day directory structure. You can safely ignore them.

**Q: How do I report errors or contribute corrections?**

Open an issue on the GitHub repository at `https://github.com/Asabeneh/30-Days-Of-Python/issues`. Several community members have reported content corrections (see Troubleshooting section).

---

_Generated May 2026 from Asabeneh/30-Days-Of-Python at 80e4ac4. AI-generated documentation. The library is checked by sampling (three repositories so far); this guide was not individually reviewed. Verify against the project before relying on it. Unofficial; not affiliated with or reviewed by the project._
