Getting Started With Python

Home > Python Tutorial > Getting Started With Python



The Python Installation

Python often comes pre-installed in a lot of different Macs and Pcs. However, if you are not sure about whether you already have Python pre-installed in your Pcs or Macs then you can try searching for Python in the start bar of your Windows Pc or you can run a particular type of command on the command line. And that particular type of command is mentioned below.

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

If you own a Linux or a Mac then you cannot use the command mentioned above. Instead, you will be required to use the command which is mentioned below.

python --version

If Python is not pre-installed on your Pcs, Macs, or Linux then you can download this software for free by clicking on the following link https://www.python.org/.  

The Python Quickstart

We have mentioned this previously in the Python tutorial that Python is a programming language that is often categorized with the term interpreted.

This term interpreted basically means over here that if you want to execute any Python file then you as a developer would have to write that Python files (.py) in a text editor and then put it in the Python interpreter to successfully execute it. Python files are run on a command line for example.

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

Here the name of the file is hellowworld.py Now, if you want to write your first python file then just open any text editor and write say “Hello, World!” This can be written in the below-mentioned manner

print (“Hello, World!”)

Now after writing that, you just need to simply save your file. You can then choose to run your file by opening the command line, navigate to the directory where you have saved your helloworld.py file and then simply run it.

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

The output that you get to see after running the command must be something like

Output Hello, World!

If you get a similar output then you need to pat yourself on the back as you have just successfully written and executed your first Python program.  

The Command Line of Python

It is also important for you to be aware of a quicker and easier way of testing a short amount of code in Python.

This little trick is made possible because of the fact that you can also choose to run Python simply as a command line too.

To try out this little method you can start by typing the following on your Mac, Linus, or Windows command line.

C: \Users\Your Name>python

After writing this on the command line, you can choose to write any kind of short codes that you want to. For example

C: \Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 07:07:55) [MSC v.1990 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information. 
>>> print (“Hello, World!”)

Once you have written all that then you can find the “Hello, World!” written in the command line.

>>>>print (“Hello, World!”)
Output Hello, World!

And once you are done with the Python command line then you can simply type the following to quit the interface of Python command line.

exit( )