Python Installation Guide

Python Installation Guide

Many PCs and Macs come pre-installed with Python. To check if Python is already installed on your Windows PC, search for “Python” in the start bar or run the following command in the Command Line (cmd.exe):

C:UsersYour Name>python --version

On Linux or Mac, open the command line or Terminal and type:

python --version

If Python is not installed, you can download it for free from the official website: Python.org.

Python Quickstart

Python is an interpreted programming language, allowing you to write Python (.py) files in a text editor and execute them using the Python interpreter. To run a Python file from the command line, use:

C:UsersYour Name>python helloworld.py

Here’s a simple “helloworld.py” example:

# helloworld.py
print("Hello, World!")

Save the file, open the command line, navigate to the file’s directory, and run the command. You should see:

Hello, World!

Congratulations, you’ve executed your first Python program.

The Python Command Line

You can test short snippets of Python code directly in the command line. To access the Python command line on Windows, Mac, or Linux, type:

C:UsersYour Name>python

If “python” doesn’t work, try “py.” Once in the Python command line, you can execute Python code interactively. For example:

# Python command line
>>> print("Hello, World!")

This will output:

Hello, World!

To exit the Python command line, type:

>>> exit()


One response to “Python Installation Guide”