Skip to content

Python Tutorial

Official Documentation

This tutorial is based on Python official documentation. For the most up-to-date information, visit: https://docs.python.org/3/

Welcome to the comprehensive Python tutorial! This guide will take you from beginner to advanced level.

What is Python?

Python is a versatile, high-level programming language known for its simplicity and readability. It's used in web development, data science, AI/ML, automation, and much more.

┌─────────────────────────────────────────────────────────────────┐
│                    🐍 Why Python?                                │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│   READABLE            VERSATILE           POWERFUL               │
│   ────────            ─────────           ────────               │
│                                                                  │
│   📖 Code reads      🌐 Web apps         🚀 Used by             │
│   like English       📊 Data Science     Google, Netflix,       │
│                      🤖 AI/ML            Instagram, Spotify     │
│   Easy to learn      🔧 Automation                              │
│   and understand     🎮 Game Dev         Large ecosystem        │
│                                          of libraries           │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

What Can Python Do?

Use CaseExamplesPopular Libraries
Web DevelopmentAPIs, websitesDjango, Flask, FastAPI
Data ScienceAnalysis, visualizationPandas, NumPy, Matplotlib
Machine LearningAI models, predictionsTensorFlow, PyTorch, scikit-learn
AutomationScripts, botsSelenium, BeautifulSoup
Desktop AppsGUI applicationsTkinter, PyQt
DevOpsInfrastructure, CI/CDAnsible, Fabric

Simple Example

python
# This is Python - simple and readable!
print("Hello, Python!")

# Variables are easy
name = "Alice"
age = 25

# No semicolons, no type declarations needed
if age >= 18:
    print(f"{name} is an adult")
else:
    print(f"{name} is a minor")

# Lists are powerful
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(f"I like {fruit}")

Tutorial Structure

This tutorial is organized into three levels to help you learn progressively:

🟢 Beginner Level (Start Here!)

LessonTopicWhat You'll Learn
01 - BasicsVariables & Data TypesHow to store and work with information
02 - Control FlowConditionals & LoopsHow to make decisions and repeat actions
03 - FunctionsFunctions & ScopeHow to create reusable code blocks

🟡 Intermediate Level

LessonTopicWhat You'll Learn
04 - Data StructuresLists, Tuples, DictsHow to work with collections of data
05 - StringsString ManipulationHow to work with text effectively
06 - File I/OFile HandlingHow to read and write files

🔴 Advanced Level

LessonTopicWhat You'll Learn
07 - ModulesModules & PackagesHow to organize and reuse code
08 - OOPObject-Oriented ProgrammingHow to build with classes and objects
09 - ExceptionsError HandlingHow to handle errors gracefully
10 - AdvancedAdvanced TopicsDecorators, generators, and more

Getting Started

Installing Python

bash
# Download from python.org or use winget
winget install Python.Python.3.12
bash
# Using Homebrew
brew install python@3.12
bash
# Ubuntu/Debian
sudo apt update
sudo apt install python3.12

Verify Installation

bash
python --version
# or
python3 --version

Running Python Code

┌─────────────────────────────────────────────────────────────────┐
│                  4 Ways to Run Python                            │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. INTERACTIVE MODE (REPL)                                      │
│     $ python                                                     │
│     >>> print("Hello")                                           │
│     Hello                                                        │
│                                                                  │
│  2. RUN A SCRIPT                                                 │
│     $ python my_script.py                                        │
│                                                                  │
│  3. IDE (VS Code, PyCharm)                                       │
│     Click "Run" or press F5                                      │
│                                                                  │
│  4. JUPYTER NOTEBOOK                                             │
│     Great for learning and data science                          │
│     $ jupyter notebook                                           │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Quick Reference

Python Cheat Sheet

python
# Variables
name = "Python"        # String
age = 30               # Integer
price = 19.99          # Float
is_active = True       # Boolean

# Lists
items = [1, 2, 3]
items.append(4)

# Dictionary
person = {"name": "Alice", "age": 25}
print(person["name"])

# Functions
def greet(name):
    return f"Hello, {name}!"

# Conditionals
if age >= 18:
    print("Adult")
elif age >= 13:
    print("Teen")
else:
    print("Child")

# Loops
for i in range(5):
    print(i)

while count > 0:
    count -= 1

Python vs Other Languages

FeaturePythonJavaScriptJava
TypingDynamicDynamicStatic
SyntaxClean, indentedBraces {}Braces {}
SemicolonsNot requiredOptionalRequired
Learning curveEasyMediumSteep
Use casesGeneral purposeWebEnterprise

Video Tutorials

Recommended Video Resources

Learn Python through these excellent video tutorials from the community.

Free Courses

CourseCreatorDescription
Python Full CoursefreeCodeCamp4+ hour comprehensive course
Python Tutorial for BeginnersProgramming with Mosh6-hour complete course
Python Crash CourseTraversy Media1-hour crash course
Python in 100 SecondsFireshipQuick 100-second explanation

Official Resources

ResourceDescription
Python.org TutorialOfficial Python tutorial
Real PythonHigh-quality Python tutorials

Topic-Specific Videos

TopicVideoDuration
OOP in PythonPython OOP Tutorial~1 hour
File HandlingPython File I/O~20 min
Web ScrapingPython Web Scraping~1.5 hours
Data AnalysisPandas Tutorial~1 hour

Next Steps

Ready to start learning? Head to Python Basics to begin your journey!

Prerequisites

  • No prior programming experience required
  • Basic computer skills
  • A text editor or IDE (VS Code recommended)