How to Start Writing Python Code Today (A No-Fluff Guide)

Table of Contents
I've seen so many tutorials that make you read five paragraphs about what Python is before they show you a single line of code. It drives me crazy. Let's skip all of that.
Install Python, learn the six things that actually matter, and build something that runs. You can do this in under an hour.
Step 0: Install Python
Download it from python.org. On Windows, check the box that says "Add Python to PATH" during installation. Verify it worked: open a terminal and type python --version — you should see Python 3.12.x or higher.
The Six Things You Actually Need
1. Variables and Types
Python infers types — you don't declare them. Just pick a name and assign a value:
name = "Ava" # str — text
age = 19 # int — whole number
height = 1.72 # float — decimal
is_ready = True # bool — True or False
score = None # NoneType — "no value yet"
# f-strings: the clearest way to build strings
print(f"Hello {name}, you are {age} years old.")
# Output: Hello Ava, you are 19 years old.
# Type checking (useful when debugging)
print(type(age)) # <class 'int'>
When None matters: Use None as a default for optional values — it's Python's way of saying "not set yet". Check for it with if value is None: not if value == None:.
2. Conditions
Python uses indentation (4 spaces) instead of curly brackets. This forces readable code:
age = 20
if age >= 21:
print("Can drink in the US")
elif age >= 18:
print("Can vote, can't drink yet")
else:
print("Not yet")
# One-liner (ternary) — only for simple cases
status = "adult" if age >= 18 else "minor"
print(status) # adult
The elif is short for "else if". You can chain as many elif blocks as you need.
3. Lists and Loops
A list holds multiple values in order. Square brackets, comma-separated:
colors = ["red", "green", "blue"]
# Loop through every item
for color in colors:
print(f"I like {color}")
# Loop with index
for i, color in enumerate(colors):
print(f"{i}: {color}")
# 0: red
# 1: green
# 2: blue
# Add, remove, check
colors.append("yellow") # add to end
colors.remove("red") # remove by value
print("green" in colors) # True
# List comprehension — Pythonic way to build a new list
upper = [c.upper() for c in colors]
print(upper) # ['GREEN', 'BLUE', 'YELLOW']
4. Dictionaries
Dictionaries store key-value pairs. The most useful data structure in Python:
user = {
"name": "Ava",
"age": 19,
"skills": ["Python", "SQL"],
}
# Access
print(user["name"]) # Ava
print(user.get("email", "N/A")) # N/A — safe access with default
# Modify
user["age"] = 20
user["email"] = "ava@example.com"
# Iterate
for key, value in user.items():
print(f"{key}: {value}")
# Check if key exists
if "email" in user:
print("User has email")
Dictionaries are what you'll use constantly when working with JSON, API responses, config files, and database rows.
5. Functions
Functions let you name a block of code and call it anywhere. They're the core of code reuse:
def greet(name: str, title: str = "friend") -> str:
"""Returns a greeting string. title defaults to 'friend'."""
return f"Hi, {title} {name}!"
print(greet("Ava")) # Hi, friend Ava!
print(greet("Ava", title="Dr.")) # Hi, Dr. Ava!
# Type hints (str, -> str) are optional but highly recommended
# They make your code easier to read and catch bugs in editors
# Functions can return multiple values (as a tuple)
def min_max(numbers: list[int]) -> tuple[int, int]:
return min(numbers), max(numbers)
low, high = min_max([3, 1, 4, 1, 5, 9])
print(f"min={low}, max={high}") # min=1, max=9
6. Error Handling
Errors happen. Handle them explicitly instead of letting your program crash:
def divide(a: float, b: float) -> float:
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b
try:
result = divide(10, 0)
except ValueError as e:
print(f"Error: {e}") # Error: Cannot divide by zero
except ZeroDivisionError:
print("Zero division caught")
finally:
print("This always runs") # cleanup code goes here
# Safe type conversion
user_input = "abc"
try:
number = int(user_input)
except ValueError:
print(f"'{user_input}' is not a valid number")
The finally block runs whether or not an exception occurred — use it for cleanup (closing files, releasing connections).
Build Something Real: A CLI Password Generator
Theory solidifies when you build. Here's a complete, working project that uses all six concepts:
import random
import string
def generate_password(
length: int = 16,
use_symbols: bool = True,
use_numbers: bool = True,
) -> str:
"""
Generate a random password.
Args:
length: Number of characters (default 16)
use_symbols: Include !@#$%^&* (default True)
use_numbers: Include 0-9 (default True)
Returns:
A random password string
"""
# Build character pool
chars = list(string.ascii_letters) # a-z, A-Z
if use_numbers:
chars += list(string.digits) # 0-9
if use_symbols:
chars += list("!@#$%^&*")
if len(chars) == 0:
raise ValueError("No character types selected")
# Shuffle and pick
password = [random.choice(chars) for _ in range(length)]
random.shuffle(password) # extra shuffle for randomness
return "".join(password)
def main():
print("=== Password Generator ===\n")
# Get user input with validation
while True:
try:
length = int(input("Password length (8-64, default 16): ") or "16")
if not 8 <= length <= 64:
raise ValueError("Length must be between 8 and 64")
break
except ValueError as e:
print(f"Invalid input: {e}. Try again.")
use_symbols = input("Include symbols? (y/n, default y): ").strip().lower() != "n"
use_numbers = input("Include numbers? (y/n, default y): ").strip().lower() != "n"
# Generate multiple options
print("\nYour passwords:")
for i in range(5):
pwd = generate_password(length, use_symbols, use_numbers)
print(f" {i + 1}. {pwd}")
print("\nTip: Copy one and store it in a password manager.")
if __name__ == "__main__":
main()
Run it: python password_generator.py
This uses: variables, conditions (if use_numbers), lists (chars += list(...)), a loop (for i in range(5)), a function with type hints, and error handling (try/except).
How to Actually Learn This
Don't just copy — break it
After running the password generator, break it on purpose. Delete a colon. Mess up the indentation by one space. Type int(user_input without the closing parenthesis. Read the error message carefully — Python tells you exactly where it went wrong and why.
I learned more from breaking code than from writing it correctly the first time. Error messages aren't enemies; they're the most specific debugging hints you'll ever get.
After you've broken and fixed the generator, try these progressions:
- Add a feature — Let the user exclude ambiguous characters like
0,O,l,1 - Save to file — Write the generated passwords to
passwords.txtusingopen() - Check strength — Print a strength rating (Weak/Medium/Strong) based on character variety
- Make it a module — Import
generate_passwordfrom another file
Each step introduces a new Python concept naturally, in context.
Common Beginner Mistakes
Mistake: Comparing with == instead of is
# Wrong
if user_input == None:
...
# Right
if user_input is None:
...
Mistake: Modifying a list while iterating it
# Wrong — skips items
for item in my_list:
if item < 0:
my_list.remove(item)
# Right — iterate a copy
for item in my_list[:]:
if item < 0:
my_list.remove(item)
Mistake: Using mutable default arguments
# Wrong — the list persists across calls
def add_item(item, collection=[]):
collection.append(item)
return collection
# Right
def add_item(item, collection=None):
if collection is None:
collection = []
collection.append(item)
return collection
Mistake: print debugging in loops
# This floods your terminal — use a counter instead
for i, item in enumerate(large_list):
if i % 100 == 0:
print(f"Processing item {i}/{len(large_list)}")
What to Build Next
You've got the basics. The best next steps — roughly in order:
| Project | New concepts it teaches |
|---|---|
| Temperature converter CLI | User input, unit math, more conditions |
| Word frequency counter | Reading files, dictionaries, sorting |
| Simple to-do list | Persistent state, JSON file I/O |
| Number guessing game | While loops, random, game state |
Web scraper (with httpx) | Third-party libraries, HTTP, HTML parsing |
| REST API with FastAPI | Functions as routes, async, type hints at scale |
Each one is achievable in 1-3 hours and teaches real patterns you'll use in production.
Frequently Asked Questions
Should I learn Python 2 or 3?
Python 3 only. Python 2 reached end-of-life in 2020 and is completely unsupported. If you find a tutorial using print "hello" (no parentheses), it's teaching Python 2 — ignore it.
Do I need an IDE or can I use a text editor? Start with VS Code and the Python extension — it gives you syntax highlighting, error detection, and a debugger for free. Once you're comfortable, explore PyCharm for larger projects or Neovim for terminal-focused workflows.
How long until I can get a job writing Python? With consistent daily practice (1-2 hours/day), most people can build portfolio-worthy projects in 3-6 months. The key is building real things, not just following tutorials. Employers care about your GitHub projects more than which course you took.
Is Python fast enough for real applications? Fast enough for ~95% of applications. Python powers Instagram (1B+ users), YouTube, Dropbox, and most ML/AI tooling. For CPU-bound performance bottlenecks, you use C extensions (NumPy, Pandas) or move that specific piece to Rust/Go.
Wrapping Up
Every programmer I know started exactly here — one tiny project at a time, breaking things constantly, reading error messages. You're not behind. You're just getting started.
Pick one project from the table above. Build it. Break it. Fix it. Build the next one.
You Might Also Like
Free In-Browser Developer Tools
Clean AI CLI logs, build cron expressions, decode JWTs, and calculate chmod permissions offline.
Related Articles

A Practical pytest Tutorial That Actually Fixes Early Gotchas
Master pytest for production Python: fixtures, parameterization, monkeypatch mocking, custom markers, and clean test suite architecture.
Read more
The Python Fundamentals You Actually Need to Start
Master foundational Python paradigms: memory references, mutable vs immutable types, scoping rules, generators, and clean object-oriented patterns.
Read more
Serverless Analytics Warehouse with BigQuery & Cloud Run: From GA4 Streams to Automated SEO Alerts
How to build an automated serverless analytics warehouse with BigQuery, Google Analytics 4, and Cloud Run: schema modeling, scheduled SQL transformations, zero-idle cost, and automated SEO query alerts.
Read more