Python for Beginners: Your First Script

A Hands-On Guide to Writing and Running Your First Python Program

Get started with Python programming by writing your very first script. This tutorial walks you through installing Python and running a simple program to kickstart your coding journey.

Programming
Author
Affiliation
Published

February 5, 2024

Modified

March 11, 2025

Keywords

Python for beginners, first Python script, Python installation, learn Python

Introduction

Welcome to your first Python script tutorial! In this guide, you’ll learn how to set up Python on your computer and write a simple script that outputs a friendly greeting. This tutorial is designed for beginners, so no prior programming experience is required.



Step 1: Installing Python

There are several ways to install Python. We recommend one of the following methods:

Option 1: Download Python Directly

  1. Visit the official Python website.
  2. Download the latest version for your operating system.
  3. Run the installer and follow the on-screen instructions. Make sure to check the box that adds Python to your system PATH.

Option 2: Install Anaconda

  1. Download the Anaconda Distribution, which bundles Python along with many useful packages for data science.

  2. Run the installer and follow the setup instructions.

  3. Verify the installation by opening your terminal or command prompt and typing:

    conda --version

    You should see the Conda version number displayed.

Step 2: Writing Your First Script

Once Python is installed, it’s time to write your first script!

  1. Open a Text Editor:
    You can use any text editor (such as VS Code, Notepad++, or even the built-in text editor on your system). Save your file with a .py extension (e.g., hello.py).

  2. Write the Code:
    Type the following code into your file:

    Python Code

    # This is your first Python script.
    print("Hello, World!")
  3. Save the File:
    Save your file as hello.py in a directory of your choice.

Step 3: Running Your Script

Now that you have written your script, it’s time to run it:

  1. Open Your Terminal or Command Prompt:
    Navigate to the directory where you saved hello.py.

  2. Run the Script:
    Type the following command:

    python hello.py

    If everything is set up correctly, you should see the output:

    Hello, World!

Conclusion

Congratulations on writing and running your first Python script! This simple exercise is the first step in your programming journey. As you continue learning, you’ll explore more complex topics and build increasingly sophisticated programs.

Further Reading

Happy coding, and enjoy your journey into Python programming!

Back to top

Reuse

Citation

BibTeX citation:
@online{kassambara2024,
  author = {Kassambara, Alboukadel},
  title = {Python for {Beginners:} {Your} {First} {Script}},
  date = {2024-02-05},
  url = {https://www.datanovia.com/learn/programming/python/basics/python-for-beginners-your-first-script.html},
  langid = {en}
}
For attribution, please cite this work as:
Kassambara, Alboukadel. 2024. “Python for Beginners: Your First Script.” February 5, 2024. https://www.datanovia.com/learn/programming/python/basics/python-for-beginners-your-first-script.html.