∙ It was developed by Guido Van Rossum in the late 80’s and early 90’s at
National Research Institute for mathematics and computer science in the
Netherlands.
∙ It is a successor to ABC language.
∙ Its version 0.9.0 was released in 1991 with features functions, data types. ∙
Python version 1.0 was released in 1994 with functional programming tools
such as lambda, map, and reduce.
∙ 2.0 released in 2000 with features List comprehension, Unicode and garbage
collector.
∙ 3.0 released in 2008 by removing duplicate programming constructs and
modules.
∙ Latest python version is 3.7.4 (as on 15/8/2019)
Note:
∙ Surprisingly Python is older than Java, java script and R.
∙ Why is it called Python? When he began implementing Python, Guido van
Rossum was also reading the published scripts from “Monty Python's Flying
Circus”, a BBC comedy series from the 1970s. Van Rossum thought he
needed a name that was short, unique, and slightly mysterious, so he
decided to call the language Python.
Python Features:
Python provides lots of features that are listed below.
1) Easy to Learn and Use
Python is easy to learn and use. It is developer-friendly and high level
programming language.
2) Expressive Language
Python language is more expressive means that it is more
understandable and readable.
3) Interpreted Language
Python is an interpreted language i.e. interpreter executes the code line
by line at a time. This makes debugging easy and thus suitable for beginners.
4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux,
Unix and Macintosh etc. So, we can say that Python is a portable language. 5)
Free and Open Source
Python language is freely available at offical web address.The source
code is also available. Therefore it is open source.
6) Object-Oriented Language
Python supports object oriented language and concepts of classes and
objects come into existence.
7) Extensible
It implies that other languages such as C/C++ can be used to compile
the code and thus it can be used further in our python code. 8) Large
Standard Library
Python has a large and broad library and provides rich set of module and
functions for rapid application development.
,9) GUI Programming Support
Graphical user interfaces can be developed using Python.
10) Integrated
It can be easily integrated with languages like C, C++, JAVA etc.
Literal Constants:
The Literal Constant can be 10,10.5,’A’ and “hello”. These can be directly used
in the program. Constant is a fixed value that does not change. Let us see
Number and string constants in C.
Numbers:
It is a numerical value. We can use four types’ numbers in python. They
are Binary numbers, Integral numbers, floating point numbers and
complex numbers.
Binary Numbers made up of with 0’s and 1’s.In python every Binary number
begins with either 0b or 0B (zero b).Eg:0b1110 , 0B1111
Integral numbers can be whole numbers or integer number or octal number or
Hexadecimal Number.
a) Integer numbers like 10, 34567, 123456778889999907788,-
9876.Integer can be small, long, positive or negative. In python integer
numbers are identified by word int. Integer number never have a decimal
point.
b) Octal numbers start with either 0o or 0O(zero capital O).Octal number is
made of digits(0-7).Eg:0o57 is a valid octal number,0o876 is not a valid
octal number. Octal numbers identified by oct word.
c) Hexa decimal numbers start with either 0x or 0X.It is made of digits(0-9)
and letters(A-Z or a-z).Eg:oxface oXbeaf,ox975b are valid but
0xbeer,ox5vce are not valid. Hexa decimal numbers identified by hex
word.
Floating point numbers are like 5.678,91.45e-2,91.4E-2(it equals to
91.4*10- 2).In python Floating numbers are identified by word float which
has a decimal point.
Complex numbers have real ,imaginary part like a+bj
Eg:1+5j ,7-8J
Complex numbers are identified by the word by complex.
Note: Commas are not allowed in numerical. Eg: 3,567 -8,90876 are
invalid numbers.
⮚ No size limit for integer number that can be represented in python but
floating point number have a range of 10-323 to 10308 with 15 digits
precision.
⮚ Issues with floating point numbers:
Arithmetic Overflow Problem: It occurs when a result is too large in
, size to be represented. Eg: 2.7e200*4.3e200 you will get infinity.
Arithmetic Underflow Problem: It occurs when a result is too small in
size to be represented. Eg: 2.7e-200/4.3e200 you will get infinity. Loss
of precision: Any floating number has a fixed range and precision, the
result is just approximation of actual or true value. Slight loss in
accuracy is not a concern in practically but in scientific computing ,it is
an issue.
Strings
A string is a group of characters.
• Using Single Quotes ('): For example, a string can be written as 'HELLO'.
• Using Double Quotes ("): Strings in double quotes are exactly same as those in
single quotes. Therefore, 'HELLO' is same as "HELLO".
• Using Triple Quotes (''' '''): You can specify multi-line strings using triple
quotes. You can use as many single quotes and double quotes as you want in a
string within triple quotes.
Examples:
Escape Sequences
Some characters (like ", \) cannot be directly included in a string. Such
characters must be escaped by placing a backslash before them.
Example:
, Example 2:print(“Welcome to \\Vmeg\\”)
Output:Welocme to \Vmeg\
Example 3: print(“Welcome to \’Vmeg\’ ”)
Output: Welocme to ‘Vmeg’
Example 4: print(“Welcome to\b Vmeg ”)
Output:Welcom to Vmeg
Example 5: print(“Welcome to\r Vmeg ”)
Output:
Use of Triple Quotes:
The triple quotes can be single or double i.e. ‘’’ or “””
1) Triple quotes can be used for multi line string literals
Example: print(‘’’ Hello
How are
You?’’’)
Output:Hello
How are
You?
Example: print(“””Hello
How are
You?”””)
Output:Hello
How are
You?