• 6 hours
  • Easy

Free online content available in this course.



Got it!

Last updated on 5/9/23

Run Your First Python Program

Why Use Python?

Python is a widely-used and easy to learn programming language. It’s great for beginners and experts alike because of its simple, readable syntax and wide range of uses. Whether you want to be a web developer, data scientist, marketer, or analyst, Python can help make it easier to get your job done.

As you jump into your first time coding 🥳  it is easy to get overwhelmed or intimidated by what might seem foreign at first. Just remember that at some point, even the most highly-skilled Python experts were in the same position as you.

Coding in Python may seem foreign, but it’s just a skill like any other. Whether it’s Excel, a new spoken language, or gardening, new skills require time and effort. I always tell people that the most challenging part about coding is not the syntax or logic; it’s putting in the effort to learn and getting over the voice in your head telling you that you’re not good enough. So with that in mind, remember that if anything feels too hard or confusing, that’s OK - keep pushing yourself, and you’ll get it!

Install Python on Your Computer

Installing Python is super simple! Head over to python.org, choose your operating system (Mac/Windows/etc.), and click the download button to install Python on your computer.  

Run Your First Python Program

Now that you’ve installed Python, you’re ready to run your first Python code!

  1. Open up Terminal if you are in Mac OS or Command Prompt if you are in Windows. (If you haven't used Terminal very much yet, feel free to refer to this chapter in our Learn the Command Line on Terminal course for a refresher on opening the program.)

  2. Type in python, and you should see information about Python come up with a  >>>

    signaling where to type in your code. 

  3.  Next, type in print("hello, world!") and press enter; see what it returns.

Follow along the screencast below to learn more.

You did it! You ran your first Python code. In this screencast, we opened up a terminal, started up a Python console (or shell), and printed out “hello, world” to the console.  

As you saw, you can run each line of Python code directly in the terminal. You can also write your code in a separate text editor and then run it using terminal commands. There are many text editors you can use, but a good starter one is Sublime Text

Check out the following screencast to see how to run Python code saved in a text editor using your terminal.

Tell all your friends you know how to code in Python! 🙌

Level-Up: Work With the Python Shell

The best way to learn Python is by doing! From here on out you will find Level-Up activities at the end of every chapter specific to what you just learned.

To practice executing your first Python code, try the following exercise on Replit. 😁

Then, check your work by:

  • submitting your project,

  • navigating back to the course team page (click on the exercise title on the top left of your screen, then the team name "OCpythonbasics")

  • clicking on "Fork the solution".

Let’s Recap!

  • Python is a popular language among beginner and expert developers because of its readability and wide range of uses.

  • The hardest part about coding is pushing yourself to overcome the mental challenges - but you can do it!

  • You can run a Python script in your terminal directly or in a text editor and run that code.

Now that you’ve successfully installed and run Python code, we’ll go into more specifics on storing data in Python using variables.

Ever considered an OpenClassrooms diploma?
  • Up to 100% of your training program funded
  • Flexible start date
  • Career-focused projects
  • Individual mentoring
Find the training program and funding option that suits you best
Example of certificate of achievement
Example of certificate of achievement