How to Install Python and Write Your First Program
By Admin_CodeByHer

How to Install Python and Write Your First Program

Introduction
Python is one of the most beginner-friendly programming languages in the world. Its simplicity, versatility, and widespread use make it ideal for students and beginners who want to start coding. Before you can write Python programs, you need to install it on your computer and set up a development environment. In this guide, we will walk you step-by-step through installing Python and writing your very first program.

1. Downloading Python

Python is free and open-source. To get started:

  1. Visit the official Python website: python.org.
  2. Choose the latest version compatible with your operating system (Windows, Mac, or Linux).
  3. Download the installer file.

Tip: Always download the latest stable version to ensure compatibility with modern libraries and tools.

2. Installing Python

For Windows:

  1. Run the installer you downloaded.
  2. Important: Check the box that says “Add Python to PATH” before clicking “Install Now.”
  3. Wait for the installation to complete.

For Mac:

  1. Open the downloaded .pkg file.
  2. Follow the instructions to install Python.

For Linux:

Python often comes pre-installed on Linux. To check, open the terminal and type:

python3 --version

If it’s not installed, use your package manager:

sudo apt-get install python3

3. Verifying the Installation

After installing Python, verify the installation by opening your terminal or command prompt and typing:

python --version

or for some systems:

python3 --version

You should see the Python version number displayed, confirming that Python is installed correctly.

4. Setting Up a Development Environment

You can write Python code in multiple ways:

  1. IDLE: Python comes with IDLE, a simple editor for beginners.
  2. VS Code: A lightweight, powerful code editor with extensions for Python.
  3. PyCharm: A professional IDE suitable for beginners and advanced users.
  4. Jupyter Notebook: Great for data science and interactive coding projects.

For absolute beginners, IDLE or VS Code is recommended.

5. Writing Your First Python Program

Let’s write a simple program that prints a message:

  1. Open your Python editor (IDLE or VS Code).
  2. Type the following code:
print("Hello, World!")
  1. Save the file as hello.py.
  2. Run the program:
    • In IDLE, click Run → Run Module.
    • In the terminal, navigate to the folder and type:
python hello.py

Output:

Hello, World!

Congratulations! You have successfully written and run your first Python program.

6. Understanding the Code

  • print() is a built-in Python function that outputs text to the screen.
  • "Hello, World!" is a string—a sequence of characters enclosed in quotes.
  • Every line of code in Python is executed in order, making it easy to understand and debug.

7. Next Steps for Beginners

After writing your first program, you can try these beginner-friendly exercises:

  1. Modify the program to print your name instead of “Hello, World!”
  2. Ask the user for their name and greet them:
name = input("Enter your name: ")
print(f"Hello, {name}!")
  1. Practice simple math operations:
a = 5
b = 3
print("Sum:", a + b)
  1. Experiment with multiple print statements to display different messages.

8. Tips for a Smooth Start

  • Write code daily, even small programs.
  • Use online resources for exercises: FreeCodeCamp, Codecademy, HackerRank.
  • Don’t fear errors; debugging is a natural part of learning.
  • Keep a folder with all your beginner projects for reference.

Conclusion

Installing Python and running your first program is the first step in your coding journey. With Python set up correctly, you can now explore programming concepts, build projects, and gradually become confident in coding. Start small, practice consistently, and take your first steps toward becoming a Python developer today.

  • No Comments
  • March 17, 2026

Leave a Reply

Your email address will not be published. Required fields are marked *