Python Basics Guide
A beginner's guide covering an overview of Python, its main features, and basic usage.
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
| Feature | Description |
|---|---|
| Concise syntax | Short and intuitive, readable like English. Example: print("Hello") |
| Dynamically typed | No need to declare types; values are inferred at runtime |
| Large-scale data processing | Powerful data libraries such as NumPy and Pandas |
| Web development | Rich web frameworks such as Django and Flask |
| AI/ML | Core 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
| Module | Purpose |
|---|---|
os | File and directory handling |
json | Parsing and generating JSON |
urllib.request | HTTP requests |
datetime | Dates and times |
math | Mathematical 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
AI Knowledge Hub