Learn Python – Lesson 1

Python is an object oriented high level programming language. It is primarily used for developing web applications and programs involving complex mathematical calculations. It is also used for systems scripting.

Python is highly portable and Python programs can be developed under any Operating System. But this series is for windows users only – Windows 7 and above.

I will keep this series on a hands on mode – so you can get your hands dirty quickly and learn practical stuff in short time.

Let us get started.

Download python for windows

Run the installer and complete installation.

Open a command window and type “python”. You should be greeted with something like below

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Where 3.8.0 is the current Python version number(at the time of this article) and it may be different for your installation.

If you get an error like “Python command not found” then look at the PATH environment variable. You may need to edit/add path to your Python installation directory there. For example i have the following paths in my windows 10 environment variables –

c:\python\Scripts, c:\python

Where c:\python is the installation directory of Python in my Windows PC.

first python program

A Python program is saved in file with .py extension. Then the program can be run in command as below –

python filename.py

Where filename.py is the name of the saved program file

But for testing you may want to run code blocks in command line directly. To do that, open a command window. Type Python and enter. You will be greeted with >>> which means now you can enter Python commands.

Type the following and enter.

print("Hello Python!")

Output: Hello Python!

That was easy right! So that was your first Python program.

To run this program from a file, follow these steps –

Create a file with .py extension. Say hello.py is the filename.

Enter following line in file

print("Hello Python!")

Save and run the program in command line with –

python hello.py

Output: Hello Python!

Note: Parenthesis was not required in Python 2. From Python 3 if you do not use parenthesis then the interpreter will raise an error.