How to Create Your First Python Script: A Beginner's Guide


Introduction
Python is one of the most popular and beginner-friendly programming languages today.
Whether you are aiming to become a web developer, data scientist, or automation expert, learning Python is a fantastic first step.
In this tutorial, we will walk you through how to create your very first Python script — even if you have no prior programming experience!
Step 1: Install Python
Before you can write Python code, you need to install Python on your computer.
- Download the latest stable version (e.g., Python 3.12).
- Install it by following the on-screen instructions.
- Important: During installation, make sure you check the box that says "Add Python to PATH."
✅ Once installed, open your command prompt (Windows) or terminal (Mac/Linux) and type:
bashCopyEditpython --version
If you see a version number, Python is installed successfully!
Step 2: Choose a Code Editor
You need a place to write your Python code.
Some beginner-friendly options:
- VS Code (Recommended) – Free, lightweight, and powerful.
- PyCharm – Great for larger projects.
- Sublime Text or Atom – Simple and fast.
👉 Download VS Code here: https://code.visualstudio.com/
Step 3: Create Your First Python Script
Now, let’s write your first script!
- Open your code editor (e.g., VS Code).
- Create a new file and save it as first_script.py (the .py extension tells the computer it’s a Python file).
✍️ Inside first_script.py, type the following code:
pythonCopyEdit# This is my first Python script print("Hello, World!")
Step 4: Run Your Python Script
Running your script is easy!
- Windows:
- Open Command Prompt.
- Navigate to the folder where you saved first_script.py.
- Run the command:
bashCopyEditpython first_script.py
- Mac/Linux:
- Open Terminal.
- Navigate to the folder.
- Run:
bashCopyEditpython3 first_script.py
🎉 You should see:
CopyEditHello, World!
printed on your screen. Congratulations! You just ran your first Python program.
Step 5: Understand the Code
Let’s break down the tiny script you wrote:
- # This is a comment: Anything after # is ignored by Python. It's just for you to leave notes.
- print("Hello, World!"): This is a function that tells Python to display the text inside the quotation marks.
Simple and powerful!
What's Next?
Now that you've written your first script, here are a few simple ideas to practice:
- Create a script that adds two numbers.
- Write a program that asks for your name and says hello.
- Build a simple calculator.
The more you practice, the faster you will learn Python.
At OGTECH, we will continue providing easy-to-follow tutorials to help you become a confident Python developer!
Conclusion
Starting with Python is much easier than you might think.
Today you learned how to install Python, write your first script, and run it successfully.
Keep experimenting, building small projects, and most importantly — have fun!
Stay tuned to OGTECH for more hands-on tutorials, coding tips, and practical guides for beginners.