Your First Program: Setup and Hello World
Your First Program: Setup and Hello World
Welcome to your coding journey! This lesson guides you through setting up your development environment and running your first program. Writing your first "Hello World" program is a programming tradition—it's the simplest way to verify that your tools work and understand the basic structure of code.
Why "Hello World"?
Every programmer, regardless of language, typically writes a Hello World program first. This simple program does one thing: displays text on your screen. It teaches you three essential skills: how to write code, how to run code, and how to understand output. Success here builds confidence for more complex programs ahead.
Setting Up Your Environment
Before you write code, you need the right tools. Your development environment includes a text editor (where you write code) and a compiler or interpreter (which translates your code into instructions the computer understands).
For beginners, popular choices include:
- Python: Uses an interpreter; great for absolute beginners because the syntax is readable
- JavaScript: Runs in web browsers; accessible and immediately visible
- Java or C++: More structured; teaches programming fundamentals thoroughly
For this lesson, we'll focus on Python because it's beginner-friendly. Visit python.org and download the latest version for your operating system (Windows, Mac, or Linux). During installation, check the box that says "Add Python to PATH"—this lets your computer find Python from anywhere.
Your First Program
Once installed, open a text editor (Notepad, VS Code, or any code editor) and type this line:
print("Hello, World!")
Save this file as hello.py. The .py extension tells your computer it's a Python file.
Running Your Program
To execute your program, you need to use your computer's command line:
- Windows: Open Command Prompt
- Mac/Linux: Open Terminal
Navigate to the folder where you saved hello.py using the cd command, then type:
python hello.py
Press Enter. You should see Hello, World! appear on your screen. Congratulations—you've written and run your first program!
Understanding What Happened
Let's break down what occurred:
- You wrote code: The line
print("Hello, World!")is an instruction - Python interpreted it: The Python interpreter read your code
- It executed: The
printfunction displayed your text - You saw output: The message appeared on screen
The print() function is a built-in tool in Python that displays whatever you put inside the parentheses. The text must be surrounded by quotes (single or double) so Python knows it's text, not a command.
Common Mistakes
- Forgetting quotes:
print(Hello, World!)will cause an error because Python won't recognize the text - Wrong file extension: Save as
.py, not.txt - Typos in "print": Python is case-sensitive;
Printwith a capital P won't work
Next Steps
Experiment! Modify your program to print different messages. Change the text inside the quotes and run it again. This hands-on practice builds muscle memory and confidence. You've now crossed the threshold from curious observer to active programmer—you've written working code that your computer executed. This foundation supports everything you'll learn next.