Python Getting Started

Installing Python

Python is available for most of the operating systems including Windows, Linux/UNIX, Mac OS X. To install Python for your operating system, you can download the latest version from http://www.python.org/downloads/.

Before downloading Python, check if Python is already installed on your computer. To check that Python is installed, you can run the following commands.

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

C:\Users\Your Name>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46)
Type "help", "copyright", "credits" or "license" for more information.

>>>

For Linux or OS X operating systems, you can use python3 command instead of python command. Python is installed by default in these operating systems and python command refers to the Python 2 version.

When you install the Python 3 version, you should use python3 command to execute Python 3.

If python command gives you the following error, then you can download and install Python from http://www.python.org/downloads/.

C:\Users\Your Name>python --version
'python' is not recognized as an internal or external command,
operable program or batch file.

In the installation screen make sure that Add Python 3.8 to PATH is checked.

Python 3 Installation

Python Command Line Interpreter

Since you have installed Python on your system, now you can test Python syntax from the command line. To launch Python Interpreter, just type python from the command line and press Enter. Python Interpreter opens with a shell-like interface.

We will use print() function to test Python Interpreter. print() is a built-in function and it takes one (or more) object arguments and prints these arguments to the console.

In the following example, we are passing two string arguments (“Hello” and “World!” ) to print() function. The function prints “Hello World!” to console.

C:\Users\Your Name>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46)
Type "help", "copyright", "credits" or "license" for more information.

>>> print("Hello", "World!")
Hello World!

>>>

Note that there is a space between two words. That is because space is the default separator character. However, you can override separator with sep parameter.

>>> print("Hello", "World!", sep='---')
Hello---World!

>>> 

SHARE