SlideShare a Scribd company logo
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 1. basics of 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 Programming
Alex Moore
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
srinivasanr281952
 
Introduction to Python for Bioinformatics
Introduction to Python for BioinformaticsIntroduction to Python for Bioinformatics
Introduction to Python for Bioinformatics
José 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 scientists
Lambda Tree
 
Learning python
Learning pythonLearning python
Learning python
Tony Nguyen
 
Learning python
Learning pythonLearning python
Learning python
Fraboni Ec
 
Learning python
Learning pythonLearning python
Learning python
Hoang Nguyen
 
Learning python
Learning pythonLearning python
Learning python
Harry Potter
 
Learning python
Learning pythonLearning python
Learning python
James Wong
 
Learning python
Learning pythonLearning python
Learning python
Young Alista
 
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginnersLearn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
KingsleyAmankwa
 
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-learn
Arnaud Joly
 
Python_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. txPython_Haegl.powerpoint presentation. tx
Python_Haegl.powerpoint presentation. tx
vishwanathgoudapatil1
 
Module-1.pptx
Module-1.pptxModule-1.pptx
Module-1.pptx
Manohar Nelli
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
Dan Bowen
 
python-160403194316.pdf
python-160403194316.pdfpython-160403194316.pdf
python-160403194316.pdf
gmadhu8
 
Python: The Dynamic!
Python: The Dynamic!Python: The Dynamic!
Python: The Dynamic!
Omid Mogharian
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
Shivam Gupta
 

Similar to 1. basics of 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 Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 

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 routing
Vishnu Vardhan
 
5. configuring multiple switch with files
5. configuring multiple switch with files5. configuring multiple switch with files
5. configuring multiple switch with files
Vishnu Vardhan
 
Ospf
OspfOspf
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
Vishnu 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 routing
Vishnu 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 ns
Vishnu Vardhan
 
Chapter 1.2 osi layer
Chapter 1.2 osi layerChapter 1.2 osi layer
Chapter 1.2 osi layer
Vishnu Vardhan
 
Chapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networkingChapter 1. introduction to tcpip networking
Chapter 1. introduction to tcpip networking
Vishnu 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

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 

1. basics of 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