• 6 hours
  • Easy

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 4/11/24

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

Context:

In this very first exercise, you will dive into the world of Python by displaying a message and performing a calculation. It's the perfect starting point for your journey into this programming language!

You will write directly into a Python file named  main.py  . Then, you can execute this script in VS Code to observe the result.

Instructions:

  • Use the print function to display the phrase "I learn Python!".

  • Calculate the result of  17 + 35 * 2  and display the result (You can place the calculation directly within the print function to display it).

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.

Example of certificate of achievement
Example of certificate of achievement