Learn more about Python & It’s installation

Many PC and Macs already have installed Python but you can also check that is there any version of Python is installed or not in your computer.

python

Check whether Python is installed or not.

To check whether Python is installed or not on your pc so what could you do you can search cmd.exe in the search bar by clicking on the start button to open the command prompt and run the following command in the command prompt.

C:\Users\usman>python --version

To check if you have installed Python on a Linux or Mac, then on Linux, open the command line, or on Mac open the Terminal and type

python --version

If you find that you do not have Python installed on your computer, then you can download it for free from the following website: https://www.python.org/

Python Quick Start

Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor and then put those files into the Python interpreter to be executed.

The way to run a Python file is like this on the command line:

C:\Users\usman>python hellousman.py

Where “helloworld.py” is the name of your Python file.

Let’s write our first Python file, called helloworld.py, which can be done in any text editor.

helloworld.py

print("Hello, usman!!")

Simple as that. Save your file. Open your command line, navigate to the directory where you saved your file, and run:

C:\Users\Your Name>python hellousman.py

The output is:

Hello, usman!!

Congratulations, you have written and executed your first Python program.

The Python Command Line !!

To test a short amount of code in Python sometimes it is quickest and easiest not to write the code in a file. This is made possible because Python can be run as a command line itself.

Type the following on the Windows, Mac, or Linux command line:

C:\Users\usman>python

Or, if the “python” command did not work, you can try “py”:

C:\Users\usman>py

From there you can write any Python, including our hello world example from earlier in the tutorial:

C:\Users\usman>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, usman")

Which will write “Hello, World!” in the command line:

C:\Users\usman>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello, usman")
Hello, usman

Whenever you are done in the Python command line, you can simply type the following to quit the Python command line interface:

exit()

Link: https://Codelikechamp.com

Medium Link: Follow me on Medium

Linkedin Link: Follow me on Linkedin

🤞 Don’t miss any latest posts!

Please subscribe by joining our community for free and stay updated!!!

IF YOU HAVE ALREADY SUBSCRIBED JUST CLOSE THIS FORM !

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top