From the course: Programming Foundations: Fundamentals

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Running Python on the command line on Mac

Running Python on the command line on Mac - Python Tutorial

From the course: Programming Foundations: Fundamentals

Running Python on the command line on Mac

- One way to execute or run your Python code is by using the command line. Let's open up Terminal and try out a few commands. Let's go ahead and launch the Python interpreter. We'll use the Python three command. Now we're inside of our Python prompt. This means the computer's ready to take our instructions. Let's try out a simple math problem. Two plus two. First, we'll try it with what is two plus two? Uh oh, we get a syntax error. We call it that syntax refers to the rules of a programming language. Syntax errors happen when you write code that breaks the expected rules. In this case, we wrote our code in plain English, but the interpreter doesn't understand English, only Python. Let's try this again. This time, we'll take two plus two, and just like that, we get four. That's because two plus two is a valid Python expression. Let's try another one. Two plus, and then enter. Once again, another syntax error.…

Contents