Installing Python For Newbie

Gopal Khadka
2 min readJan 16, 2023

Python install

If you are either Linux or macOS user, then it is possible that python is already installed on your device. To check, open your terminal and write:

python --version

It is same to check for Windows pc. To install python , visit the official website: https://www.python.org/

Writing your first program in python

There are two ways to write your first program in python.

1. Preferred way

Open file explorer and create a file with extension .py extension and open it in text editor. Write the below code:

print("Hello world")

Open the folder in terminal and write :

python helloworld.py

Note: helloworld.py is the name of your file. If it is not, write your file name instead of it. It will below output:

Hello world

2. Terminal way

Open terminal and type:

python

If it did not work, you can try writing: py

What this will do is open python default interpreter in the terminal.If you have many versions of python, you can use pythonX to use a specific version of python, where X can be replaced with version no. After you enter this, you will see something like this:

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, World!")

You can use the same method as above to write your first line of code. After you hit enter, you will get the same output. If you want to test short code, you can try this method. Otherwise, method 1 is preferred one but with use of code editors and IDEs, you can do it in easier and better way.

If you want to exit your terminal, then write:

exit

Congrats on writing your first line of code. Now you are officially python programmer. Welcome to the club.

--

--