The “hello world program” is used in programming languages to set up a minimal programming environment and execute the first trivial program in it. It helps you get your environment going and take your first steps towards a more complicated program. This short tutorial will show you the fastest possible way to write your first hello world program — as a Python one-liner!
Before I show you how to install Python on your computer, follow the following steps to run your first Python
"hello world" program in your browser!
Run Your Hello World One-Liner in Your Browser Shell
Step 1: Here’s an interactive browser-based shell:
The shell runs any Python program in your browser.
Step 2: Type the print function in your browser shell with opening and closing parentheses that are initially empty:
print() function takes a string and prints it to your shell. This way, you can generate outputs in your program. Think about it: a Python program is only a means to an end. It transform an input to an output. One way of creating an output is to print program values to the shell. In our hello world one-liner, the output is the textual data (=string)
Step 3: Pass the
'hello world' string into the
print() function between the parentheses.
Congratulations, your first hello world one-liner is ready! Now, there’s only one thing left:
Step 4: Run the hello world one-liner program by hitting the “Run” symbol ▶.
Can you see the output generated by your program? When running your program in the interactive shell, the result should be the following output:
Make sure that you see this output in your shell before you move on!
Install Python on Your Computer
Now, you know how to run your first program. If you want to start your first serious project though, you’ll need Python on your local machine.
Follow these seven steps to install Python on your computer (Windows):
- Visit website “Python Releases for Windows”: https://www.python.org/downloads/windows/
- Click link “Download Windows x86-64 executable installer” under “Stable Releases” header.
- A popup opens. Click “Save File”.
- Wait until the download completes and double click on the installer file to run it.
- Another popup appears. Select “Add Python to Path” and click “Install Now”.
- Wait until the installation completes “Setup was successful”.
- You can now use Python on your Windows computer: use the Windows Search for “IDLE” and open the standard Python editor to start coding.
The steps are almost identical for MacOS and Linux, you can figure them out easily. In this video, I’ll guide you through the process in a step-by-step manner:
Related Article: 7 Steps to Set Up Python on Windows
Learn the Python Basics
An excellent way to start learning Python is through Python cheat sheets. They focus on the relevant parts and introduce the most important concepts in the shortest possible time. Here’s such a Python cheat sheet for you:
You can download this and more cheat sheets in my interactive Python email course (that’s also 100% free). Check it out for continuous improvement in Python by reading a series of course email lessons I’ll send you into your INBOX. Free Python cheat sheets are included!
*** Join FREE Python Cheat Sheet Email Academy ***
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.