Python was named after the British comedy group Monty Python by its creator Guido van Rossum. It is a high-level, general-purpose programming language that is easy to learn and use. Python code can run on many platforms like Windows, Linux, and Mac. It has a large standard library and rich set of tools and modules for rapid application development. Python supports multiple programming paradigms like object-oriented, functional, and procedural programming. It is widely used in areas like machine learning, web development, GUI programming, software development, and IoT. Some major companies that use Python extensively include Netflix, Google, Facebook, Amazon, and YouTube.
2. WHY NAME PYTHON?
Developed by Van Rossum and named as python to honor British comedy group
Monty python.
Idle was also chosen to honor Eric idle. Monty pythons founding member
3. WHY PYTHON?
Faster growing language in terms of:
Number Of developers who are using it.
Numbers of library we use.
Area you can implement it.
Machine learning , GUI , S/w development , web development , IOT.
Beginner friendly.
5. INTRODUCTION
Python is easy to learn and use. It is developer-friendly and high level
programming language.
Python language is more expressive means that it is more understandable and
readable.
Python is compiled and interpreted.
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.
6. INTRODUCTION
Python language is freely available at official web address. The source-code is
also available. Therefore it is open source.
Python has a large and broad library and provides rich set of module and
functions for rapid application development.
It can be easily integrated with languages like C, C++, JAVA etc.
python have different implementation: PYPY ,CPYTHON ( c ) , IRONPYTHON
(.net), JYTHON (java)
8. INSTALLATION
To download and install Python visit the official
website of Python and choose your version.
http://www.python.org/downloads/
Once the download is complete, run the exe
for install Python. Now click on Install Now.
To download and install pycharm (IDE) visit
the official website of jetbrains and choose
your version.
https://www.jetbrains.com/pycharm/download/
9. PYTHON DATA TYPES
Integers
There is effectively no limit to how long an integer value can be. Of course, it is
constrained by the amount of memory your system has.
>> print(10)
10
>> x=10
>> Print(x)
10
10. INTEGER(BINARY , OCTAL , HEXADECIMAL)
Prefix Interpretation Base
0b (zero + lowercase letter 'b')
0B (zero + uppercase letter 'B')
Binary 2
0o (zero + lowercase letter 'o')
0O (zero + uppercase letter 'O')
Octal 8
0x (zero + lowercase letter 'x')
0X (zero + uppercase letter 'X')
Hexadecimal 16
11. FLOATING POINT NUMBERS
The float type in Python designates a floating-point number. float values are
specified with a decimal point. Optionally, the character e or E followed by a
positive or negative integer may be appended to specify scientific notation:
>>> 4.2
4.2
>>> type(4.2)
<class 'float'>
>>> .4e7
4000000.0
>>> 4.2e-4
0.00042
12. COMPLEX NUMBERS
Complex numbers are specified as <real part> + <imaginary part> j.
>>> 2+3j
(2+3j)
>>> type(2+3j)
<class 'complex'>
13. STRING
• Strings are sequences of character data. The string type in Python is called str.
• String literals may be delimited using either single or double quotes. All the
characters between the opening delimiter and matching closing delimiter are part
of the string:
>>> print("I am a string.")
I am a string.
>>> type("I am a string.")
<class 'str‘
>>> print('I am too.')
I am too.
>>> type('I am too.')
<class 'str'>
14. VARIABLE
• A variable can be seen as a container to store certain values. While the program
is running, variables are accessed and sometimes changed, i.e. a new value will
be assigned to the variable.
• In Java or C, every variable has to be declared before it can be used. Declaring a
variable means binding it to a data type.
• Declaration of variables is not required in Python. If there is need of a variable,
you think of a name and start using it as a variable.
• Another remarkable aspect of Python: Not only the value of a variable may
change during program execution but the type as well.
15. VARIABLE
i = 42
>>> i = i + 1
>>> print i
43
>>>i = 42 # data type is implicitly set to integer
>>>i = 42 + 0.11 # data type is changed to float
>>>i = "forty" # and now it will be a string
16. PYTHON OPERATORS
• Python Arithmetic Operators :Arithmetic operators are used with numeric values to
perform common mathematical operations.
• Python Assignment Operators :Assignment operators are used to assign values to
variables.
• Python Comparison Operators :Comparison operators are used to compare two values.
• Python Logical Operators : Logical operators are used to combine conditional
statements.
• Python Identity Operators : Identity operators are used to compare the objects, not if
they are equal, but if they are actually the same object, with the same memory location.
• Python Membership Operators : Membership operators are used to test if a sequence is
presented in an object.
17. ARITHMETIC OPERATORS
OPERATOR NAME EXAMPLE
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
% Modulus x % y
** Exponentiation x ** y
// Floor division x // y
18. ASSIGNMENT OPERATORS
OPERATOR EXAMPLE SAME AS
= x = 5 x = 5
+= x += 3 x = x + 3
-= x -= 3 x = x - 3
*= x *= 3 x = x * 3
/= x /= 3 x = x / 3
%= x %= 3 x = x % 3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x = x & 3
|= x |= 3 x = x | 3
^= x ^= 3 x = x ^ 3
19. COMPARISON OPERATORS
Operator Name Example
== Equal x == y
!= Not equal x != y
> Greater than x > y
< Less than x < y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
20. IDENTITY OPERATORS
Operator Description Example
is
Returns true if both
variables are the same
object
x is y
is not
Returns true if both
variables are not the
same object
x is not y
21. MEMBERSHIP OPERATORS
Operator Description Example
in
Returns True if a
sequence with the
specified value is
present in the object
x in y
not in
Returns True if a
sequence with the
specified value is not
present in the object
x not in y
22. ARRAY
Arrays are used to store multiple values in one single variable.
An array is a special variable, which can hold more than one value at a time.
>>> cars = ["Ford", "Volvo", "BMW"]
>>>print(cars)
['Ford', 'Volvo', 'BMW']
23. ACCESS THE ELEMENTS OF AN ARRAY
You refer to an array element by referring to the index number.
>>>x = cars[0]
>>>print(x)
Ford
# Modify the value of the first array item:
>>>cars = ["Ford", "Volvo", "BMW"]
>>>cars[0] = "Toyota"
>>>print(cars)
Toyota
24. THE LENGTH OF AN ARRAY
Use the len() method to return the length of an array (the number of elements in an
array).
>>>cars = ["Ford", "Volvo", "BMW"]
>>>x = len(cars)
>>>print(x)
3
25. ADDING ARRAY ELEMENTS
You can use the append() method to add an element to an array.
cars = ["Ford", "Volvo", "BMW"]
cars.append("Honda")
print(cars)
['Ford', 'Volvo', 'BMW', 'Honda']
26. REMOVING ARRAY ELEMENTS
You can use the pop() method to remove an element from the array.
cars = ["Ford", "Volvo", "BMW"]
cars.pop(1)
print(cars)
['Ford', 'BMW']
27. REMOVING ARRAY ELEMENTS
You can use the pop() method to remove an element from the array
You can also use the remove() method to remove an element from the array.
>>>cars = ["Ford", "Volvo", "BMW"]
>>>cars.pop(1)
>>>print(cars)
['Ford', 'BMW']
>>>cars.remove("BMW")
>>>print(cars)
['Ford‘]
28. ARRAY METHODS
Method Description
append() Adds an element at the end of the list
clear() Removes all the elements from the list
copy() Returns a copy of the list
count() Returns the number of elements with the specified value
extend()
Add the elements of a list (or any iterable), to the end of the
current list
index() Returns the index of the first element with the specified value
insert() Adds an element at the specified position
pop() Removes the element at the specified position
29. RECURSION
• In Python, a function is recursive if it calls itself and has a termination condition.?
• Why a termination condition?
• Limitations of recursions:
• Every time a function calls itself and stores some memory. Thus, a recursive
function could hold much more memory than a traditional function. Python stops
the function calls after a depth of 1000 calls.
30. SOME AMAZING FACTS
• Van Rossum worked for google and dropbox.
• Real life application:
• NETFLIX (75%) , FACEBOOK , AMAZON , YouTube
• Google , Firefox , NASA , IBM , Walt Disney , Drop Box
• Google trends [ oct 6 , 2013 – sep 20 , 2018]
•
PYTHON
JAVA
C
C++