DEV Community

Cover image for Intro to Python: Day 18 - Running Your First Python Program
James Hubert
James Hubert

Posted on

Intro to Python: Day 18 - Running Your First Python Program

Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or my twitter for updates and feel free to reach out if you have questions. Thanks for your support!

To run a program in Python, luckily it's quite a bit easier than learning to run your first program in Javascript, for which you have to learn Node.

Simply make sure Python is installed on your computer by opening a terminal and typing python or on Mac/Linux systems it is likely python3, which it is for me. If you get an error, go to the Python website and download it to your machine. Once installed, running python3 should print the following:

Python 3.9.6 (default, Oct 18 2022, 12:41:40) 
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
Enter fullscreen mode Exit fullscreen mode

To run your own Python program simply create a folder, and save a Python file in it by using the extension .py. For example, main.py.

Let's start traditionally and write a Hello World program.

#main.py
print("Hello world!")
Enter fullscreen mode Exit fullscreen mode

When you save this program and in the command line run python3 main.py from the project directory, your string will print to the screen. Huzzah!

This means it is installed and the three > mean it can accept input. You can stop the interpreter by pressing CTRL + D on a Mac.

When you verify Python is installed (

If you like projects like this and want to stay up to date with more, check out my Twitter @stonestwebdev, I follow back! See you tomorrow for another project.

Top comments (0)