SlideShare a Scribd company logo
1 of 26
Here in this class we will deal with Network
Automation with the help of Python
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Python 3 for Network Engineers
Software to RUN network Automation
• Pycharm – By. Jetbrains – Download Community version
• GNS3VM
• GNS3
• Virtual Box
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Basics of Python
• Understand a point, Coding is not all about how much you know, its
all about what are the stuffs you can based on how much you know.
• Lets get started quickly. We will have 2 sessions in this course.
• 1st session will introduce the possible commands and explanation
• 2nd session we will jump into Python for Network Engineers
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
What Python can do
• We can create games, software’s etc
• However we will focus on Python feature that’s helping the network
engineer to make our job easy.
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#1Hello World
Python
Programming
Printing “ Hello world “
• Print is a command which is used to print any strings or characters or values etc.
Command :
>>>print (“Hello World”)
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#2Variables
Python
Programming
Variables and Multiple assignments
• Variables :
• Variables are basically memory locations where we can store values.
• Commands :
>>>age = 20
>>>sentence = “my name is vishnu”
>>>bob = 20
>>>john = 24
>>>steve = 30
>>> bob,john,steve = 20,24,30
>>>name,age = “vishnu”,28 ------ Am storing string and integer at the same place.
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Variables and Multiple assignments Practice
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#3Arithmetic
Operations
Python
Programming
Arithmetic Operations
• Last slides we saw what are variables and stuffs. Lets do some maths with Python.
• We have Addition, Subtraction, Multiplication, Division
Commands : For adding and subtracting numbers
>>>a=10
>>>b=20
>>>a+b
Commands : For adding two or more strings
>>>firstname = “Vishnu”
>>>lastname = “Vardhan”
>>>details = “age is 28”
>>>firstname + lastname + details
or
>>>firstname + “ “ + lastname+ “ “ +details
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Arithmetic Operations
• Oh good that now you got how to add two different names by using “+”. But if you try to use “-” then it
will not work for strings.
• You can use “*” (Multiplication) with Strings
• String supported operations are = + and *
• String non supported operations are = % and -
Arithmetic Operations Script
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#4Strings
Python
Programming
String Functions - Slicing
• Functions are the additional power commands given to Strings we have lot, let us start with Slicing.
Command:
>>>sentence=“Welcome to network rhinos classes”
>>>sentence[0]
‘W’
>>>sentence[4]
‘o’
?? What if you want full length character.
>>>sentence[0:6] ------ Make note Blank spaces also count
‘Welcome’
>>>sentence[:6]
‘Welcome’
>>>sentence[0:-2]
‘Welcome to network rhinos class’
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
String Lab and intro to docs.python.org
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Errors while slicing
• What if you try to slice a value or character with a wrong index value.
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Placeholders in String
• As of not we have covered Integers, Arithmetic's, Strings and some functions.
• Lets get our self familial with Placeholders
• ?? What is Placeholders :
• Taking a place of something.
>>>name = “Bob”
>>>details = “is 15 years old”
‘Bob is 15 years old’
I can simply use something called placeholder to say hey instead of placeholder use this value ( %s )
>>>detail=“%s is 15 years old”
>>>detail%name
‘Bob is 15 years old’
** Here you can see the %s is being replaced by name in the output.
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Placeholders in string Lab
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#5Lists
Python
Programming
Introductions Lists
• Pythons first Data structures.
• What is Lists :
It can be set of items which are ordered with index and each least value has items. You can think of Shopping lists.
Like Item 1= banana , Item 2=apple etc etc.,
Lists are always enclosed in square braces and separated by commas
Command :
>>>shoplist=[“Apples”,”Oranges”,”Bananas”,”Choclates”]
>>>shoplist
[‘Apples’,’Oranges’,’Bananas’,’Choclates’]
In list index value works for a list number unlike in strings it worked for a character.
>>>shoplist[0]
‘Apples’
>>>shoplist[1]
‘Oranges’
>>>shoplist[0:2] # To see first 2 items
Apples, Oranges
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Adding a new value to the Lists
• What if you missed something on the list and you want to add it later.
Command :
>>>shoplist.append[“Blueberrys”]
>>>shoplist
[‘Apples’,’Oranges’,’Bananas’,’Choclates’,Blueberrys]
• What if you want to change something in the list.
Command :
>>>shoplist[0] = “Coconets”
>>>shoplist
[‘Coconets’,’Oranges’,’Bananas’,’Choclates’,Blueberrys]
• To remove from a lists.
Command :
>>>del shoplist[1]
[‘Coconets’,’Bananas’,’Choclates’,Blueberrys]
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
• You can also add two lists by just using a “+”
Counting number of items
Command :
>>>len(shoplist)
4
• Finding maximum number on a lists :
Command:
>>>list1=[1,2,3,4,5,6,7]
>>>max(list1)
7
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
#6Dictionary
Python
Programming
Dictionaries
• Dictionaries are the are the list but with a meaning to each item.
• For example I want to create student and age dictionary.
• We will be using “:” between them key and meaning.
Command :
>>>students= {“Bob”:12 , “Steve”:15,”Mark”:20}
>>>students[“Bob”]
12
• What if we want to update the students age. Simply use the above command with = <age>
Command :
>>>students[“Bob”]=25
>>>students[“Bob”]
25
Deleting : >>>del students[“Bob”]
Counting : >>>len(students)
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
Lab
www.networkrhinos.com | Vishnu (Founder) | +91-9790901210

More Related Content

Similar to Network Automation with Python

.Net 4.0 Threading and Parallel Programming
.Net 4.0 Threading and Parallel Programming.Net 4.0 Threading and Parallel Programming
.Net 4.0 Threading and Parallel ProgrammingAlex Moore
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for BioinformaticsJosé Héctor Gálvez
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientistsLambda Tree
 
Learning python
Learning pythonLearning python
Learning pythonFraboni Ec
 
Learning python
Learning pythonLearning python
Learning pythonJames Wong
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersKingsleyAmankwa
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!Fariz Darari
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnArnaud Joly
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txvishwanathgoudapatil1
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schoolsDan Bowen
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdfgmadhu8
 

Similar to Network Automation with Python (20)

.Net 4.0 Threading and Parallel Programming
.Net 4.0 Threading and Parallel Programming.Net 4.0 Threading and Parallel Programming
.Net 4.0 Threading and Parallel Programming
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
 
Python for R developers and data scientists
Python for R developers and data scientistsPython for R developers and data scientists
Python for R developers and data scientists
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learning python
Learning pythonLearning python
Learning python
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
 
Python: The Dynamic!
Python: The Dynamic!Python: The Dynamic!
Python: The Dynamic!
 
Python
PythonPython
Python
 

More from Vishnu Vardhan

Chapter 25. implementing i pv6 routing
Chapter 25. implementing i pv6 routingChapter 25. implementing i pv6 routing
Chapter 25. implementing i pv6 routingVishnu Vardhan
 
5. configuring multiple switch with files
5. configuring multiple switch with files5. configuring multiple switch with files
5. configuring multiple switch with filesVishnu Vardhan
 
Chapter 4. using the command line interface
Chapter 4. using the command line interfaceChapter 4. using the command line interface
Chapter 4. using the command line interfaceVishnu Vardhan
 
Chapter 3.1 subnetting
Chapter 3.1 subnetting Chapter 3.1 subnetting
Chapter 3.1 subnetting Vishnu Vardhan
 
Chapter 3. fundamentals of wan and ip routing
Chapter 3. fundamentals of wan and ip routingChapter 3. fundamentals of wan and ip routing
Chapter 3. fundamentals of wan and ip routingVishnu Vardhan
 
Chapter 2. fundamentals of ethernet la ns
Chapter 2. fundamentals of ethernet la nsChapter 2. fundamentals of ethernet la ns
Chapter 2. fundamentals of ethernet la nsVishnu Vardhan
 
Chapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networkingChapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networkingVishnu Vardhan
 

More from Vishnu Vardhan (9)

Chapter 25. implementing i pv6 routing
Chapter 25. implementing i pv6 routingChapter 25. implementing i pv6 routing
Chapter 25. implementing i pv6 routing
 
5. configuring multiple switch with files
5. configuring multiple switch with files5. configuring multiple switch with files
5. configuring multiple switch with files
 
Ospf
OspfOspf
Ospf
 
Chapter 4. using the command line interface
Chapter 4. using the command line interfaceChapter 4. using the command line interface
Chapter 4. using the command line interface
 
Chapter 3.1 subnetting
Chapter 3.1 subnetting Chapter 3.1 subnetting
Chapter 3.1 subnetting
 
Chapter 3. fundamentals of wan and ip routing
Chapter 3. fundamentals of wan and ip routingChapter 3. fundamentals of wan and ip routing
Chapter 3. fundamentals of wan and ip routing
 
Chapter 2. fundamentals of ethernet la ns
Chapter 2. fundamentals of ethernet la nsChapter 2. fundamentals of ethernet la ns
Chapter 2. fundamentals of ethernet la ns
 
Chapter 1.2 osi layer
Chapter 1.2 osi layerChapter 1.2 osi layer
Chapter 1.2 osi layer
 
Chapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networkingChapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networking
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 

Network Automation with Python

  • 1. Here in this class we will deal with Network Automation with the help of Python www.networkrhinos.com | Vishnu (Founder) | +91-9790901210 Python 3 for Network Engineers
  • 2. Software to RUN network Automation • Pycharm – By. Jetbrains – Download Community version • GNS3VM • GNS3 • Virtual Box www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 3. Basics of Python • Understand a point, Coding is not all about how much you know, its all about what are the stuffs you can based on how much you know. • Lets get started quickly. We will have 2 sessions in this course. • 1st session will introduce the possible commands and explanation • 2nd session we will jump into Python for Network Engineers www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 4. What Python can do • We can create games, software’s etc • However we will focus on Python feature that’s helping the network engineer to make our job easy. www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 6. Printing “ Hello world “ • Print is a command which is used to print any strings or characters or values etc. Command : >>>print (“Hello World”) www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 8. Variables and Multiple assignments • Variables : • Variables are basically memory locations where we can store values. • Commands : >>>age = 20 >>>sentence = “my name is vishnu” >>>bob = 20 >>>john = 24 >>>steve = 30 >>> bob,john,steve = 20,24,30 >>>name,age = “vishnu”,28 ------ Am storing string and integer at the same place. www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 9. Variables and Multiple assignments Practice www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 11. Arithmetic Operations • Last slides we saw what are variables and stuffs. Lets do some maths with Python. • We have Addition, Subtraction, Multiplication, Division Commands : For adding and subtracting numbers >>>a=10 >>>b=20 >>>a+b Commands : For adding two or more strings >>>firstname = “Vishnu” >>>lastname = “Vardhan” >>>details = “age is 28” >>>firstname + lastname + details or >>>firstname + “ “ + lastname+ “ “ +details www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 12. Arithmetic Operations • Oh good that now you got how to add two different names by using “+”. But if you try to use “-” then it will not work for strings. • You can use “*” (Multiplication) with Strings • String supported operations are = + and * • String non supported operations are = % and -
  • 13. Arithmetic Operations Script www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 15. String Functions - Slicing • Functions are the additional power commands given to Strings we have lot, let us start with Slicing. Command: >>>sentence=“Welcome to network rhinos classes” >>>sentence[0] ‘W’ >>>sentence[4] ‘o’ ?? What if you want full length character. >>>sentence[0:6] ------ Make note Blank spaces also count ‘Welcome’ >>>sentence[:6] ‘Welcome’ >>>sentence[0:-2] ‘Welcome to network rhinos class’ www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 16. String Lab and intro to docs.python.org www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 17. Errors while slicing • What if you try to slice a value or character with a wrong index value. www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 18. Placeholders in String • As of not we have covered Integers, Arithmetic's, Strings and some functions. • Lets get our self familial with Placeholders • ?? What is Placeholders : • Taking a place of something. >>>name = “Bob” >>>details = “is 15 years old” ‘Bob is 15 years old’ I can simply use something called placeholder to say hey instead of placeholder use this value ( %s ) >>>detail=“%s is 15 years old” >>>detail%name ‘Bob is 15 years old’ ** Here you can see the %s is being replaced by name in the output. www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 19. Placeholders in string Lab www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 21. Introductions Lists • Pythons first Data structures. • What is Lists : It can be set of items which are ordered with index and each least value has items. You can think of Shopping lists. Like Item 1= banana , Item 2=apple etc etc., Lists are always enclosed in square braces and separated by commas Command : >>>shoplist=[“Apples”,”Oranges”,”Bananas”,”Choclates”] >>>shoplist [‘Apples’,’Oranges’,’Bananas’,’Choclates’] In list index value works for a list number unlike in strings it worked for a character. >>>shoplist[0] ‘Apples’ >>>shoplist[1] ‘Oranges’ >>>shoplist[0:2] # To see first 2 items Apples, Oranges www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 22. Adding a new value to the Lists • What if you missed something on the list and you want to add it later. Command : >>>shoplist.append[“Blueberrys”] >>>shoplist [‘Apples’,’Oranges’,’Bananas’,’Choclates’,Blueberrys] • What if you want to change something in the list. Command : >>>shoplist[0] = “Coconets” >>>shoplist [‘Coconets’,’Oranges’,’Bananas’,’Choclates’,Blueberrys] • To remove from a lists. Command : >>>del shoplist[1] [‘Coconets’,’Bananas’,’Choclates’,Blueberrys] www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 23. • You can also add two lists by just using a “+” Counting number of items Command : >>>len(shoplist) 4 • Finding maximum number on a lists : Command: >>>list1=[1,2,3,4,5,6,7] >>>max(list1) 7 www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 25. Dictionaries • Dictionaries are the are the list but with a meaning to each item. • For example I want to create student and age dictionary. • We will be using “:” between them key and meaning. Command : >>>students= {“Bob”:12 , “Steve”:15,”Mark”:20} >>>students[“Bob”] 12 • What if we want to update the students age. Simply use the above command with = <age> Command : >>>students[“Bob”]=25 >>>students[“Bob”] 25 Deleting : >>>del students[“Bob”] Counting : >>>len(students) www.networkrhinos.com | Vishnu (Founder) | +91-9790901210www.networkrhinos.com | Vishnu (Founder) | +91-9790901210
  • 26. Lab www.networkrhinos.com | Vishnu (Founder) | +91-9790901210