How to Write Your First Python Program
Python is one of the easiest programming languages to start with. Let’s go step-by-step—from installing Python to writing your first lines of code.
✅ Step 1: Install Python
👉 On Windows/Mac/Linux:
-
Go to the official website: https://python.org
-
Download the latest version (Python 3.x)
-
Run the installer
-
Make sure to check “Add Python to PATH” during installation
✅ Tip: Python also comes pre-installed on many Linux and macOS systems.
✅ Step 2: Choose How to Write Code
You can write Python code using:
-
IDLE (comes with Python)
-
VS Code (free, powerful code editor)
-
Online editors like Replit or Google Colab
✅ Step 3: Open Your Editor and Create a File
-
Create a new file named:
hello.py
-
In that file, type the following:
✅ Step 4: Run the Program
🖥 On your computer:
-
Open a terminal or command prompt
-
Navigate to the folder where you saved
hello.py
-
Run the file by typing:
You should see:
🎉 Congratulations! You’ve just written and run your first Python program!
✅ Step 5: Try a Simple Calculator
Add this to your file:
You just used variables and a math operation in Python!
🧠 What You Just Learned
Concept | Explanation |
---|---|
print() |
Displays text on the screen |
Variables (a ) |
Stores values like numbers or text |
+ operator |
Adds two values |
🎯 What to Learn Next
Here are a few next steps to keep growing:
-
Variables and Data Types
-
User Input –
input("Enter your name: ")
-
Conditions –
if
,else
-
Loops –
for
,while
-
Functions –
def my_function():
🚀 Bonus: Try This Interactive Program
It asks the user for their name and greets them—your first interactive program!
🧑💻 Final Thought
You just took your first step into programming! Keep practicing small programs daily, and you’ll improve fast.