Python Getting Started
Python Install
Installing Python on Windows:
Go to the official Python website (https://www.python.org/downloads/) and download the latest version of Python for Windows.
Run the downloaded installer file and select the "Add Python X.X to PATH" option during the installation process.
Choose the "Customize installation" option to select specific components to install.
Click "Install" and wait for the installation to complete.
Verify the installation by opening the command prompt and typing "python --version". This should display the version of Python installed on your system.
Installing Python on Mac:
Open the Terminal application on your Mac.
Install Homebrew by running the command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, run the command
brew install python
to install Python.Verify the installation by opening the terminal and typing "python --version". This should display the version of Python installed on your system.
Alternatively, you can also download the official Python installer for Mac from the Python website and follow the installation steps similar to that of Windows.
Many PCs and Macs will have Python already installed.
To check if you have Python installed on a Windows PC, search in the start bar for Python or run the following on the Command Line (cmd.exe):
C:\Users\Your Name>python --version
To check if you have Python installed on a Linux or Mac, then on Linux open the command line or on Mac open the Terminal and type:
python --version
Steps to run the first program in Python
To run your first program in Python, you can follow these steps:
Open a text editor, such as Notepad or Sublime Text.
Type in the following code:
print("Hello, World!")
Save the file with a .py extension, such as "hello.py".
Open a command prompt or terminal window.
Navigate to the directory where you saved your Python file using the
cd
command.Type the command
python
hello.py
to run the file. This will execute the code in the file and print the message to the console.Congratulations, you have successfully run your first program in Python!
Subscribe to my newsletter
Read articles from Satyam Aaditya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by