Python is the programming language I’d recommend to almost anyone starting out. Its code reads close to plain English, it’s free, and it’s used for everything from websites and automation to data analysis and AI. It sits at number one in the TIOBE index of programming language popularity (October 2026), and in the 2025 Stack Overflow Developer Survey it was the most used language among people learning to code (71.8%).
In this guide I’ll show you how to install Python, explain the core ideas with short examples, and finish with a small project you can build in an afternoon.
What can you do with Python?
| Use | Examples |
|---|---|
| Automation | Rename hundreds of files, fill spreadsheets, send reports |
| Web development | Back ends with frameworks like Django and Flask |
| Data analysis | Clean and chart data with pandas and Matplotlib |
| AI and machine learning | Build and use models with libraries like PyTorch and scikit-learn |
| Scripting and tools | Small utilities that save you time every day |
If your goal is to build interactive websites, you’ll also want JavaScript. See my JavaScript for beginners guide. Python is often the easier first language, and many people learn both.
Step 1: Install Python
- Go to python.org › Downloads and download the latest stable version. Python 3.15 was released in October 2026.
- Windows: run the installer. If it offers an option to add Python to PATH, tick it, so you can run Python from the command line.
- macOS: run the installer package from python.org (macOS may include an older system Python, but use the one you install).
- Linux: Python is usually already installed. Check with
python3 --version.
Open a terminal (Command Prompt or PowerShell on Windows, Terminal on Mac) and type:
python3 --versionOn Windows, python --version or py --version may work instead. You should see the version number.
Code editor: install a free editor such as Visual Studio Code with the Python extension. It highlights mistakes and lets you run code with one click.
Can’t install anything? Online editors such as Google Colab or Replit let you run Python in a browser.
Step 2: Your first program
Create a file called hello.py and add:
print("Hello, world!")Run it from the terminal in the same folder:
python3 hello.pyYou’ve just written your first program. print() displays text on the screen.
Step 3: The basics
Variables
A variable stores a value under a name.
name = "Asha"
age = 25
height = 1.62
is_student = TruePython works out the type for you: text (str), whole numbers (int), decimals (float) and true/false values (bool).
Getting input
name = input("What's your name? ")
print("Nice to meet you, " + name + "!")f-strings: mixing text and values
city = "Kolkata"
temperature = 31
print(f"It's {temperature}°C in {city} today.")Maths
price = 499
quantity = 3
total = price * quantity # 1497
average = total / quantity # 499.0
remainder = 10 % 3 # 1Conditions
Python uses indentation (four spaces) to group code. This is one of its defining features.
score = 72
if score >= 80:
print("Excellent")
elif score >= 50:
print("Pass")
else:
print("Try again")Lists
fruits = ["mango", "banana", "apple"]
fruits.append("orange")
print(fruits[0]) # mango
print(len(fruits)) # 4Loops
for fruit in fruits:
print(fruit)
count = 3
while count > 0:
print(count)
count = count - 1Dictionaries
A dictionary stores pairs of keys and values.
student = {"name": "Rahul", "grade": "A", "age": 17}
print(student["name"]) # Rahul
student["age"] = 18Functions
def add_tax(price, rate=0.18):
return price + price * rate
print(add_tax(1000)) # 1180.0
print(add_tax(1000, 0.05)) # 1050.0Step 4: Build a small project
Let’s build a simple expense tracker that saves your spending to a file and shows a total. Create expenses.py:
import csv
from datetime import date
FILE = "expenses.csv"
def add_expense():
item = input("What did you buy? ")
amount = float(input("How much did it cost? "))
with open(FILE, "a", newline="") as f:
writer = csv.writer(f)
writer.writerow([date.today(), item, amount])
print("Saved!")
def show_total():
total = 0
try:
with open(FILE, newline="") as f:
for row in csv.reader(f):
print(f"{row[0]} {row[1]:<20} {float(row[2]):>8.2f}")
total += float(row[2])
except FileNotFoundError:
print("No expenses yet.")
print(f"Total spent: {total:.2f}")
while True:
choice = input("\n1 = add expense, 2 = show total, q = quit: ")
if choice == "1":
add_expense()
elif choice == "2":
show_total()
elif choice == "q":
break
else:
print("Please choose 1, 2 or q.")Run it with python3 expenses.py. It creates expenses.csv, which you can also open in Excel or Google Sheets.
What you’ve used: variables, input, functions, a while loop, conditions, f-string formatting, reading and writing files, the csv and datetime modules from Python’s standard library, and error handling with try/except. That’s a solid foundation.
Step 5: Learn to read errors
Errors are normal. Python tells you what went wrong and on which line:
- SyntaxError: a typo, such as a missing colon or bracket.
- IndentationError: inconsistent spaces. Use four spaces, not tabs.
- NameError: you used a variable before creating it, or misspelled it.
- TypeError: you mixed types, such as adding text and a number. Use
str()orint()to convert. - ValueError: for example,
float("abc")when the user types letters.
Read the last line of the error message first; it usually tells you the problem.
Step 6: Install packages with pip
Python’s real power comes from its libraries. Use pip to install them, ideally inside a virtual environment so each project has its own packages:
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install requestsThe official Python tutorial has a chapter on virtual environments and packages if you want the details.
What to learn next
- Practice daily. Short, regular sessions beat occasional long ones.
- Automate something real, such as renaming photos or tidying a spreadsheet.
- Learn Git to save versions of your code.
- Pick a direction: web (Django or Flask), data (pandas), or automation.
- Read the official tutorial at docs.python.org once you’re comfortable with the basics. It’s written for people who already know a little programming, so it makes a great second step.
Can AI help you learn Python?
Yes, as a tutor. Ask AI tools to explain an error, a line of code or a concept in simpler words. But write the code yourself first. If you copy code you don’t understand, you won’t be able to fix it when it breaks, and you won’t really learn.
Frequently asked questions
Is Python good for beginners? Yes. Its simple syntax lets you focus on learning programming ideas instead of fighting the language.
How long does it take to learn Python? The basics in this guide take a few weeks of regular practice. Becoming confident enough to build real projects usually takes a few months.
Python or JavaScript first? Python if you’re interested in automation, data or AI; JavaScript if you mainly want to build interactive websites. Both are good first languages.
Is Python free? Yes. Python and most of its libraries are free and open source.
Related guides on WebTechHelp
- Java vs Python: which should you learn?
- Why data types are crucial in programming
- HTML and CSS for beginners
- JavaScript for beginners
Sources
- Python.org: Python 3.15.0 release
- Python documentation: The Python Tutorial
- Stack Overflow: 2025 Developer Survey, Technology
- TechRepublic: TIOBE Index for October 2026


