Python is an easy-to-learn programming language with a clear way of writing code. All desktop computers can run Python programs. Many PCs and Macs already have Python installed.
Python is a popular and flexible programming language that can be used for many things like data science, building websites, automating tasks, and more.
Python code is easier to read and write, which is great for people who are just starting to learn how to code.
Even though Python comes with most Linux and Mac computers today, the version might be out of date. Installing the most recent version is always a good idea.
How you can install and run Python on your computer.
- Step 1: Go to the website and download the latest version of Python.
- Step 2: Run the installer file and install Python.
Check Python environment variables during installation. Python will be added to environment variables, allowing you to run it from anywhere.
- Step 3: To check if you have python installed:
- On a Windows PC, enter the following in cmd.exe: C:\Users\Your Name>python –version
- On a Linux or Mac, open the command line or the Terminal and type: $ python –version
Run Python in Command Line
When testing a small amount of Python code, it is sometimes faster and easier not to write it in a file. Python can be run as a command line, which makes this possible.
Type the following into the command line of Windows, Mac, or Linux:
Or you also type “py” to run python like this:
Run this code
Code language: Python (python)
Microsoft Windows [Version 10.0.25231.1000] (c) Microsoft Corporation. All rights reserved. C:\Users\ACER>python Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. a=2 b=4 c=a+b print(c) 6 exit() C:\Users\ACER>
To exit this mode, type exit() and press enter.
Run a Python file
Open any text editor (notepad, Visual Studio Code) and write your first Python file, called helloworld.py
Code language: PHP (php)
Save your file (On the menu File, choose Save). Open the command line, find the folder where you saved the file, and type:
Code language: CSS (css)
And here is the result:
Congratulations! You just made your first Python program.
As you can see, this wasn’t too hard of a job. This is why the Python programming language is so great.