Python Basics Guide

A beginner's guide covering an overview of Python, its main features, and basic usage.
Markdown sourceยทAnything to add or correct?

Python

1. What Is Python?

Python is a high-level programming language released by Guido van Rossum in 1991. The name comes from the British comedy troupe Monty Python's Flying Circus. Its design philosophy is captured by "readability counts," and it uses indentation to mark code blocks rather than braces.

2. Main Features

FeatureDescription
Concise syntaxShort and intuitive, readable like English. Example: print("Hello")
Dynamically typedNo need to declare types; values are inferred at runtime
Large-scale data processingPowerful data libraries such as NumPy and Pandas
Web developmentRich web frameworks such as Django and Flask
AI/MLCore ecosystem for machine learning, including TensorFlow and PyTorch

3. Basic Usage

You can run a script saved in a file like this:


python my_script.py

Variables and Data Types


name = "Alex"        # str
age = 52             # int
height = 175.5       # float
is_student = True    # bool
languages = ["Python", "C++"]  # list

Conditionals and Loops


if age >= 60:
    print("senior")
elif age >= 30:
    print("middle-aged")
else:
    print("young")

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

4. Functions and Modules

Functions are defined with def, and parameters can have default values.


def greet(name, greeting="Hello"):
    return f"{greeting}, {name}!"

print(greet("Alex"))          # Hello, Alex!
print(greet("Alex", "Hi"))    # Hi, Alex!

Standard Library

ModulePurpose
osFile and directory handling
jsonParsing and generating JSON
urllib.requestHTTP requests
datetimeDates and times
mathMathematical functions

5. Virtual Environments and Project Structure

A typical project layout looks like this:


my_project/
โ”œโ”€โ”€ venv/
โ”‚   โ”œโ”€โ”€ bin/python
โ”‚   โ””โ”€โ”€ lib/site-packages/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ main.py
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

Typical setup and run commands:


python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python src/main.py

6. Summary

  • Python is a language that values concise, readable syntax.
  • It is used across many fields: data analysis, web, and AI/ML.
  • Using virtual environments prevents dependency conflicts between projects.
  • A rich standard library lets you get a lot done without external packages.

Written: September 22, 2026