Python is one of the simplest languages that can be learnt easily by anyone even by beginners. The first version of Python was designed in the year 1991 by Guido van Rossum. It was developed by the Python Software Foundation. Python is a high level programming language which is generally used for many purposes (Multi-purpose). Ir runs on various OS including Windows, Linux and Mac OS.
Its not good to learn the history and its uses of python at the very beginning. So, we'll go right away to installation and programming in python.How to Download and install Python?
You can download python for free from its official website www.python.org
. After going to the home page, click the "download" link which is at the left side. Then, you will be taken to a page with several links. Be sure to download the latest version and the one for your OS (also check whether it is for a 32 bit or for a 64 bit computer).
After downloading python, install it onto your system which is very simple and it takes less than a minute.Doing your first program in Python:
You can start your python programming in IDLE Python (GUI)
. Ok! Let's start out first program i.e. printing "Hello World!"Example 1:
>>> print ("Hello world") (press enter)Example 2:
>>> print ("4362999") (press enter)
These are the simplest programs in printing anything on your screen in Python ! How about doing maths calculations? That's too very simple!Example 3:
>>> 45 + 89 (press enter)Example 4:
>>> 34 * 678 (press enter)Example 5:
>>> 345 / 23 (press enter)Example 6:
To find out the exponential value of a number, just type the two numbers with **
in between them. Consider the following example:
>>> 3**4 (press enter)
In the above example, 3**4
refers to 3^4
To find out the remainder of a value divided by another one we should use the %
symbol. Consider the following example!
>>> 65 % 7 (press enter)
While we divide 65 by 7, the remainder that we will get is 2
. That's what done in the above example.
Well, that's too easy to do calculations like that in Python. This makes python unique and also many programmers have python as their favorite programming language.Assignation of values to variables:
You know what a variable is. No problem if you don't. A variable is a character or a string whose value is not constant and can be changed later. Speaking technically, a variable is a place where we can store values or data. We can do that in python and its very simple.Example 8:
>>> a = 45 (press enter)
>>> print (a) (press enter)
In the above example, we are first assigning the value of a
as 45. Doing so will save the value 45 in a
After that, when we give the print function, with a
as the parameter (value inside the bracket) the value of a
45 is printed.Note:
Note that while writing the name of any variable inside the parenthesis, the double quotations are neglected.Making the user to assign value to a variable:Example 9:
>>> a = input ("Enter the value here : ") (press enter)
Enter the value here : 23 (press enter)
In the above example, the input () function is used to receive the value to be assigned to the variable a
from the user. The value that you give inside the parameter is displayed before getting the value from the user.
The value which we give is going to be assigned for the variable. Here, 23 is the input value and hence 23 is assigned to the variable a
Hence, later in the program, you do no need to type the number each and every time but the variable name is enough. It also forbids us from doing mistakes by typing the wrong number.
Hope its enough for this lesson! Please read the successive articles to learn more!
To learn the second lesson, please visit: Python Programming tutorials with examples - Lesson 2
Thanks for reading!
*** Please do not forget to leave your comments about this article ***