The Python Fundamentals You Actually Need to Start

Table of Contents
Python Variable
Python Variable
Indentation
Indentation
f-string
f-string
Python Fundamentals: No Bullshit Guide
Everything you build in Python is just a combination of describing data (variables) and controlling what happens next (loops & conditions). Here are the foundational blocks.
The Golden Rule of Python
Indentation is law. Python uses whitespace (spaces/tabs) to define code blocks instead of {}. Get your indentation right, or nothing works.
The Core Building Blocks
| Concept | Syntax | Example | Common Mistake |
|---|---|---|---|
| Variables | name = value | age = 25 | name = "5" + 5 (TypeError) |
| Type Conversion | int(), float(), str() | int(input()) | forgetting to convert input() |
| Comparison | ==, !=, <, > | if score == 90: | if score = 90: (assignment!) |
1. Variables & Types
You don't declare types, but you must respect them. Mixing types blindly (like "5" + 5) is the #1 beginner mistake.
int(whole numbers),float(decimals)str(text strings),bool(True/False)
2. Input & Formatting
input() always returns a string. If you need a number, you must convert it immediately using int() or float().
age = int(input("Age: "))
print(f"You will be {age + 1} next year.")
3. Control Flow (if/elif/else)
Make decisions using comparisons (==, !=, <, >). Always use == for checking equality!
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
4. Loops (for & while)
Repeat actions without going insane.
- Use
forwhen you know exactly how many times to loop (e.g., iterating a list). - Use
whilewhen looping until a condition changes. Watch out for infinite loops!
Collections & Reusability
| Collection | Syntax | Key Feature | Use When |
|---|---|---|---|
| List | [1, 2, 3] | Ordered, mutable, allows duplicates | Sequence of items |
| Tuple | (1, 2, 3) | Ordered, immutable | Fixed collection, dictionary keys |
| Set | {1, 2, 3} | Unordered, unique, O(1) lookup | Membership testing |
| Dict | {'a': 1} | Key-value pairs, O(1) lookup | Mapping keys to values |
Lists
Lists ([]) are the easiest way to store multiple items. Remember that indexing starts at 0.
nums = [10, 20, 30]
print(nums[0]) # 10
Functions
Stop rewriting the same code! Use def to create reusable blocks of logic.
def greet(name):
return f"Hi, {name}!"
Embrace the Errors
Python will yell at you with SyntaxError or ValueError. This is normal. Learning to read the Traceback is the real secret to mastering Python.
Next Steps
Practice
Experiment
dir([]) and dir({}) to see built-in methods.Read Errors
SyntaxError or ValueError, read the traceback carefully — it tells you exactly what went wrong and where.Continue Learning
Ready for the next step? Check out Setting Up Your Python Environment for virtual environments and package management, or jump to Python Tricks & Patterns for practical patterns that save time.
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

Python's Underscores: Conventions, Not Access Modifiers
Python uses underscores as naming conventions, not enforced access modifiers—understanding the difference prevents confusing code and helps you write better APIs.
Read more
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
Python Libraries I'd Bet On for 2026
I burned too many weekends on the wrong Python libraries so you don't have to. Here's what I actually use to ship things that stay working.
Read more