Python Getting Started
Last updated
Last updated
Most modern PCs and Macs come with Python pre-installed. To verify if Python is already installed on your system, follow these steps:
Open the start menu.
Search for "Python."
In the Command Line (cmd.exe), run the following command:
Open the command line (Terminal for Mac).
Run the following command:
If you discover that Python is not installed on your computer, you can easily obtain it for free from the official website: .
Python is an interpreted programming language, which means that you create Python (.py) files using a text editor and then execute these files in the Python interpreter.
To run a Python file from the command line, use the following syntax:
It's as simple as that. Save your file, open your command line, navigate to the directory where you saved the file, and execute the following command:
The output should display:
Congratulations, you've successfully written and executed your first Python program!
Sometimes, when testing a small piece of Python code, it's quicker and easier to run it directly from the command line. Python allows you to do this by opening an interactive Python session.
To start the Python command line, enter the following on the Windows, Mac, or Linux command line:
If the "python" command doesn't work, you can try "py" instead:
From the Python command line, you can run Python code interactively, as shown earlier with our "Hello, World!" example:
This will display "Hello, World!" in the command line.
To exit the Python command line interface when you're done, simply type:
With this knowledge, you're ready to embark on your Python programming journey. Happy coding!
In this example, "" is the name of your Python file.
Let's create our first Python file, named "." You can use any text editor to do this.