You are on page 1of 56

Core Python

DEMO LAB

Chapter 1

1
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Trainer Profile
Work Experience : (Currently Working in CANADA with 6 Years of Experience in MNC as a Network Consultant , Network Engineer and network
deployment Engineer)

Trained More than 35000 people CCNA, CCNP (R&S) and CCNA ,CCNP (SP), CCNA, CCNP (Enterprise), Security, AWS, Python and SDWAN)

Recently worked with Dimension Data Indian Pvt Ltd


• Deployed many projects in Deutsche Bank.
• Working as a Both Implementation and Trouble Shooting Engineer.

Certificate Examinations
• CCIE (RS – Written Certified)
• CCNP Certified (Cisco Certified Network Professional) (Cisco ID- CSCO12744986) (R & S).
• CCNA Certified (Cisco Certified Network Associate) (Cisco ID- CSCO12744986) (R & S).
• CCNP Enterprise Certified.
• CCNA Enterprise Certified.
• CCNP Security Certified.
• CCNA Security Certified.
• AWS Solution Architect Professional Certified.

Academic
•I secured the first place in M.Tech Computer Engineering. (Gold Medalist: University First)
•I secured the first place in BE (Information Technology) from GTU.

2
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Who can learn Python

• If you are from technical background Like Computer Engineering then it is very
easy for you to learn python.
• If you know any other programming language like C, C++ or Java then it is again
very easy to understand python.
• If you are from a non-technical background then also you can learn but you have
to start from basics.
• This syllabus is designed in such a way that any beginner can learn the python.
• People are talking about automation python, but for that you must have a strong
command on basic python concept then and only then you can create a long
script for automation.
• Yes, you can do automation with python, but before that you have to learn core
python.

3
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 1 – Introduction
• History
• Features
• Setting up path
• Working with Python
• Basic Syntax
• Variable and Data Types
• Operator

4
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 2- Conditional Statements


• If
• If- else
• Nested if-else

5
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 3 - Looping
• For
• While
• Nested loops

6
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 4- Control Statements


• Break
• Continue
• Pass

7
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 5- String Manipulation


• Accessing Strings
• Basic Operations
• String slices
• Function and Methods

8
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 6 - Lists
• Introduction
• Accessing list
• Operations
• Working with lists
• Function and Methods

9
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 7 - Tuple
• Introduction
• Accessing tuples
• Operations
• Working
• Functions and Methods

10
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 8- Dictionaries
• Introduction
• Accessing values in dictionaries
• Working with dictionaries
• Properties
• Functions

11
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 9- Functions
• Defining a function
• Calling a function
• Types of functions
• Function Arguments
• Anonymous functions
• Global and local variables

12
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 10 - Modules
• Importing module
• Math module
• Random module
• Packages
• Composition

13
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 11: Input-Output


• Printing on screen
• Reading data from keyboard
• Opening and closing file
• Reading and writing files
• Functions

14
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 12 - Exception Handling


• Exception
• Exception Handling
• Except clause
• Try ? finally clause
• User Defined Exceptions

15
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 13 - OOPs concept


• Class and object
• Attributes
• Inheritance
• Overloading
• Overriding
• Data hiding

16
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Core Python Syllabus

Chapter 14: Regular expressions


• Match function
• Search function
• Matching VS Searching
• Modifiers
• Patterns

17
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON INTRODUCTION

• Python is an object-oriented programming language created by Guido Rossum in


1989. It is ideally designed for rapid prototyping of complex applications. It has
interfaces to many OS system calls and libraries and is extensible to C or C++.
Many large companies use the Python programming language include NASA,
Google, YouTube, BitTorrent, etc.
• Python programming is widely used in Artificial Intelligence, Natural Language
Generation, Neural Networks and other advanced fields of Computer Science.
Python had deep focus on code readability & this class will teach you python
from basics.

18
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON INTRODUCTION

• Python is a general purpose, dynamic, high level and interpreted programming


language. It supports Object Oriented programming approach to develop
applications. It is simple and easy to learn and provides lots of high-level data
structures.
• Python is easy to learn yet powerful and versatile scripting language which makes
it attractive for Application Development.
• Python's syntax and dynamic typing with its interpreted nature, makes it an ideal
language for scripting and rapid application development

19
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
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.

20
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON FEATURES

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. 21
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON FEATURES

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.

22
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON HISTORY

• Python laid its foundation in the late 1980s.


• The implementation of Python was started in the December 1989 by Guido Van
Rossum at CWI(Centrum Wiskunde & Informatica) in Netherland.
• In February 1991, van Rossum published the code (labeled version 0.9.0) to
alt.sources.
• In 1994, Python 1.0 was released with new features like: lambda, map, filter, and
reduce.
• Python 2.0 added new features like: list comprehensions, garbage collection system.
• On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed
to rectify fundamental flaw of the language.
• ABC programming language is said to be the predecessor of Python language which
was capable of Exception Handling and interfacing with Amoeba Operating System.

23
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON APPLICATIONS AREA

Python is known for its general purpose nature that makes it applicable in almost
each domain of software development. Python as a whole can be used in
anysphere of development.
Here, we are specifying applications areas where python can be applied.
1) Web Applications
We can use Python to develop web applications. It provides libraries to handle
internet protocols such as HTML and XML, JSON, Email processing, request,
beautifulSoup, Feedparser etc. It also provides Frameworks such as Django,
Pyramid, Flask etc to design and develop web based applications. Some important
developments are: PythonWikiEngines, Pocoo, Python BlogSoftware etc.

24
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON APPLICATIONS AREA

2) Desktop GUI Applications


Python provides Tk GUI library to develop user interface in python based
application. Some other useful toolkits wxWidgets, Kivy, pyqt that are useable on
several platforms. The Kivy is popular for writing multitouch applications.
3) Software Development
Python is helpful for software development process. It works as a support language
and can be used for build control and management, testing etc.
4) Scientific and Numeric
Python is popular and widely used in scientific and numeric computing. Some
useful library and package are SciPy, Pandas, IPython etc. SciPy is group of packages of
engineering, science and mathematics.

25
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON APPLICATIONS AREA

5) Business Applications
Python is used to build Bussiness applications like ERP and e-commerce systems.
Tryton is a high level application platform.
6) Console Based Application
We can use Python to develop console based applications. For example: IPython.
7) Audio or Video based Applications
Python is awesome to perform multiple tasks and can be used to develop
multimedia applications. Some of real applications are: TimPlayer, cplay etc.
8) 3D CAD Applications
To create CAD application Fandango is a real application which provides full features of
CAD.

26
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON APPLICATIONS AREA

9) Enterprise Applications
Python can be used to create applications which can be used within an Enterprise
or an Organization. Some real time applications are: OpenErp, Tryton, Picalo etc.
10) Applications for Images
Using Python several application can be developed for image. Applications
developed are: VPython, Gogh, imgSeek etc.

There are several such applications which can be developed using Python

11) Now Automation

27
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
Python - Network Programming Introduction

28
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

• Variable is a name which is used to refer memory location. Variable also known as
identifier and used to hold value.
• In Python, we don't need to specify the type of variable because Python is a type
infer language and smart enough to get variable type.
• Variable names can be a group of both letters and digits, but they have to begin
with a letter or an underscore.
• It is recommended to use lowercase letters for variable name. Rahul and rahul
both are two different variables

29
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

• Note - Variable name should not be a keyword.


• Declaring Variable and Assigning Values
• Python does not bound us to declare variable before using in the application. It
allows us to create variable at required time.
• We don't need to declare explicitly variable in Python. When we assign any value
to the variable that variable is declared automatically.

30
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

The equal (=) operator is used to assign value to a variable.


Eg:
a=10
name=”Vishal”
salary=15000
print (a)
print (name)
print (salary)

31
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

The equal (=) operator is used to assign value to a variable.


Eg:

32
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

• Multiple Assignment
• Python allows us to assign a value to multiple variables in a single statement
which is also known as multiple assignment.

• We can apply multiple assignments in two ways either by assigning a single value
to multiple variables or assigning multiple values to multiple variables. Lets see
given examples.

33
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

1. Assigning single value to multiple variables


Eg:
x=y=z=50
print (x)
print (y)
print (z)
Output:
>>>
50
50
50
>>>
34
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

1. Assigning single value to multiple variables


Eg:

35
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

2.Assigning multiple values to multiple variables:


Eg:
a,b,c=10,20,30
print (a)
print (b)
print (c )
Output:
>>>
10
20
30
>>>
The values will be assigned in the order in which variables appears.
36
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON VARIABLES

2.Assigning multiple values to multiple variables:


Eg:

37
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Operators are particular symbols that are used to perform operations on operands.
It returns result that can be used in application.
Example
4+5=9
Here 4 and 5 are Operands and (+) , (=) signs are the operators. This expression
produces the output 9.

38
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

• Types of Operators
• Python supports the following operators
• Arithmetic Operators.
• Relational Operators.
• Assignment Operators.
• Logical Operators.
• Membership Operators.
• Identity Operators.
• Bitwise Operators

39
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Arithmetic Operators
The following table contains the arithmetic operators that are used to perform
arithmetic operations.

40
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Relational Operators
The following table contains the relational operators that are used to
check relations.

41
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Assignment Operators
The following table contains the assignment operators that are used to assign
values to the variables.

42
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Logical Operators
The following table contains the logical operators that are used to perform logical
operations.

43
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Example
a=5>4 and 3>2
print (a)
b=5>4 or 3<2
print (b)
c=not(5>4)
print (c)
Output:
>>>
True
True
False
>>>

44
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Example

45
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Membership Operators
The following table contains the membership operators.

46
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Example
a=10 b=20
list=[10,20,30,40,50];
if (a in list):
print("a is in given list")
else:
print("a is not in given list")
if(b not in list):
print("b is not given in list")
else:
print("b is given in list")

47
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Output:
>>>
a is in given list
b is given in list
>>>

48
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

49
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Identity Operators
The following table contains the identity operators

50
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Example
a=20
b=20
if( a is b):
print ( a,b have same identity )
else:
print (a, b are different)
b=10
if( a is not b):
print (a,b have different identity )
else:
51
Whatsapp/Call: +91 75675 04045 (INDIA) |
print (a,b have same identity )+1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Output
>>>
a,b have same identity
a,b have different identity
>>>

52
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON OPERATORS

Output

53
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON COMMENTS

• Python supports two types of comments:


1) Single lined comment:
In case user wants to specify a single line comment, then comment must start with
?#?
Eg:
# This is single line comment.

54
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
PYTHON COMMENTS

2) Multi lined Comment:


Multi lined comment can be given inside triple quotes.
eg:
''''' This
Is
Multipline comment'''

eg:
#single line comment
print "Hello Python"
'''''This is
55
Whatsapp/Call: +91 75675
multiline 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com
comment'''
Thank You

56
Whatsapp/Call: +91 75675 04045 (INDIA) | +1 902-919-7413 (CANADA) | Mail: info@hazynetwork.com |www.hazynetwork.com

You might also like