Table of Contents
1. Why Python Is a Great First Language
2. Install Python on Your Computer
3. Write Your First Python Program
4. Understand What the Code Is Doing
5. Try More Beginner-Friendly Examples
6. Common Mistakes and What to Learn Next
Why Python Is a Great First Language
Python is one of the best programming languages for beginners because the syntax is clean, readable, and close to plain English. Instead of fighting complicated rules, you can focus on understanding how programming works.
Python is also widely used in web development, automation, data analysis, artificial intelligence, scripting, and testing. That means the time you spend learning Python now can help you with many different kinds of projects later.
Readable: Python code is usually short and easy to scan.
Practical: You can build useful scripts very quickly.
Popular: There is a huge community and plenty of learning material.
If this is your first time writing code, that is fine. We will start with the basics and move step by step.
Install Python on Your Computer
Before you can run Python code, you need Python installed on your machine. The safest place to download it is the official website.
Related: Python for Beginners: Master Variables & Data Types
Step 1: Download Python
Go to python.org/downloads, choose the latest stable Python 3 release, and download the installer that matches your operating system.
Step 2: Install It
Windows: Open the downloaded installer and make sure you check Add python.exe to PATH before clicking Install Now.
macOS: Open the installer package and follow the standard setup steps.
Linux: Python is often preinstalled. If it is not, you can usually install it with your package manager.
Step 3: Verify the Installation
Open Command Prompt, PowerShell, or Terminal and run:
python --version
If that does not work, try:
python3 --version
If Python is installed correctly, you should see a version number such as Python 3.12.2.
If Python Is Not Recognized
On Windows, reinstall Python and make sure Add python.exe to PATH is checked.
Close and reopen your terminal after installation.
Try python3 if python does not work.
Write Your First Python Program
The traditional first program in almost every language is Hello, World!. It is simple, but it confirms that your setup works and shows you how code is written and executed.
Option 1: Run Python in the Terminal
Type the following command to open the Python interpreter:
python
If needed, use this instead:
python3
Then type this line and press Enter:
print("Hello, World!")
Option 2: Save It as a File
Step 1: Open your text editor or IDE and create a new file.
Step 2: Paste the code below:
print("Hello, World!")
Step 3: Save the file as hello_world.py.
Step 4: Open a terminal in the same folder.
Step 5: Run the script with this command:
python hello_world.py
If everything is working, you should see:
Hello, World!
Understand What the Code Is Doing
Here is the same line again:
print("Hello, World!")
Let us break it into parts:
print: a built-in Python function that displays output.
(): the place where you pass the value into the function.
"Hello, World!": a string, which means plain text wrapped in quotes.
So this line tells Python to display the text Hello, World! on the screen.
One important beginner rule: text must be inside quotation marks. If you write print(Hello, World!) without quotes, Python will raise an error because it will try to treat the words as something other than text.
Try More Beginner-Friendly Examples
Once Hello, World! works, try changing the code a little. Small experiments help you learn faster than reading alone.
Example 1: Print Your Name
print("Hello, Aisha!")
Replace Aisha with your own name and run the code again.
Example 2: Print Multiple Lines
print("Welcome to Python")
print("I am learning how to code")
print("This is fun")
Each print() statement displays one line of output.
Example 3: Use a Variable
name = "Rahul"
print("Hello, " + name)
A variable stores a value so you can reuse it later. Here, the variable name stores text.
Example 4: Do Simple Math
print(2 + 3) print(10 - 4) print(6 * 5) print(8 / 2)
Python can work as a calculator too. This is one of the fastest ways to start understanding how programming handles numbers.
Example 5: Ask for Input
name = input("What is your name? ")
print("Nice to meet you, " + name)
The input() function waits for the user to type something, then stores that value in a variable.
Mini Challenge
Try to write a short program that asks for the user's name, stores it in a variable, and prints a custom greeting.
If you can do that, you have already started using input, variables, and output together.
Common Mistakes and What to Learn Next
Common Beginner Mistakes
Forgetting quotation marks around text.
Saving the file without the .py extension.
Running the command from the wrong folder.
Typing phyton or another misspelling instead of python.
Not adding Python to PATH on Windows.
What to Learn After This
After you are comfortable with these basics, move on to:
variables and data types, taking user input, if statements, loops, and functions.
The goal is not to memorize everything at once. Focus on writing small programs, changing them, and observing what happens. That is how real coding skill starts to build.
Your first Python program may be tiny, but it is still an important milestone. Once you can run one line of code successfully, you can keep building from there.
