How To Get Started With Python

how to get started with python

How To Get Started With Python? To get started with Python programming language, first of all, you need to install Python on your PC or laptop.

What exactly is a python?

Install Python

First things first, Python will come pre-installed on many PCs and Macs. So if you want to check whether python is installed on a windows pc or not, search in the search bar for python or run the following on the command line (cmd.exe):

C:\Users\Your Name>python --version

And if you want to check on Linux or Mac whether python is installed on Linux and Mac, open the command line on Linux, or open Terminal on Mac and type the following:

python --version

Finally, if you find that you don’t have Python installed on your computer, you can get it for free from the official website: https://www.python.org/

Now Start Python

Python is an interpreted programming language, this means that as a developer you write Python (.py) files in a text editor. And then you put those files into the Python interpreter and execute them. This is how to run a python file on the command line.

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

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

Let’s start by creating our first Python file, helloworld.py, which can be done in any text editor.

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

It’s as simple as that. First, save your file. And second, open your command line, and then go to the directory where you saved your file, and run:

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

The output should look like this:

Hello, World!

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

Python Command Line

When testing a little bit of Python code, it is sometimes quicker and easier not to write the code in a file. Python can be executed as a command line, which makes this possible.

Now open the command line on Windows, Mac, or Linux, then enter Python.

C:\Users\Your Name>python

If the “python” command doesn’t work, you can try by typing “py” which is an extension of a python file.

C:\Users\Your Name>py

Now, you can write any Python code, including our earlier hello world example:

C:\Users\Your Name>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, World!")

This will output “Hello, World!” on the command line, as you can see below:

C:\Users\Your Name>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, World!")
Hello, World!

When you are finished with the Python command line, simply write the exit command to leave the Python command line interface.

exit()
Scroll to Top