How to Write Your First Python Program

How to Write Your First Python Program

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:

  1. Go to the official website: https://python.org

  2. Download the latest version (Python 3.x)

  3. Run the installer

  4. 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:

python
print("Hello, world!")

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:

bash
python hello.py

You should see:

Hello, world!

🎉 Congratulations! You’ve just written and run your first Python program!


Step 5: Try a Simple Calculator

Add this to your file:

python
a = 5
b = 3
sum = a + b
print("The sum is:", sum)

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:

  1. Variables and Data Types

  2. User Inputinput("Enter your name: ")

  3. Conditionsif, else

  4. Loopsfor, while

  5. Functionsdef my_function():


🚀 Bonus: Try This Interactive Program

python
name = input("What's your name? ")
print("Welcome to Python, " + name + "!")

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.

Related posts

Leave a Comment