Official Cert Guide - Chapter 4 - 5 Flashcards
Question
Answer
What is a python function?
A named block of code that can take wide variety parameters and return some form of output back.
Can you reuse a function?
Yes
Where stands OOPS for?
Object Oriented Programming
As what kind of modern language was Python Developed?
Object Oriented Programming
What is Object Oriented Programming?
A computer programming paradigm that makes it possible to describe real-world things and their relationships to each other.
What does OOP do?
You can create an object with several variables anywhere in your code and call this OOP function when you want.
What is Python in relation with OOP?
Object are central in Python. Python is jus a collection of objects interacting with each other.
What is the idea of OOP?
Break up a program into smaller
What is an important part of the OOP principles of reusability and object oriented structure?
Functions!
How do you describe objects in Python
With Classes!
What are classes?
A class is a tool you use to ceate your own data structure that contains information about something.
How do you use classes
You can use functions(methods) to perform operations on the data you describe
When you start with a class what is the first thing to do?
You need to pass some values to get started. The first values is always: self
What happens with the self value?
The self value passes the object name that you select to instantiate the class.
You can start the fucntion with init. How do we call this?
dunder or magic methods. This will setup the class.
The attributes you add to the class how are these called and what are they doing?
Called method. This become actions that you can perform on the object you are creating.
What is recommanded to do when you are creating a class
Provide other capitalizing signs from a variable. Example: use ‘'’test’’’ for a class and ‘‘test’’ for a variable
What do you replace when you use inheritance
You can replace methods and attributes that need to be different
What is important when you inherit in a class
You create the class before the colon
What is a central goal of OOP?
Allow you to build modular software that break code up into smaller
How can you separate code into smaller chunks that hold key structures and classes with movement between each other?
This can be done with import statement. You import modules.
Creating modular code provides the following benefits?
- Easier readability/maintainability
- Low coupling/high cohesion
- Code reusability
- Collaboration
Which module types are there?
- Third party modules imported in Python library
- Hand made appending with a .py extenion
What is the command for importing modules?
import
Which modules are interesting for you code?
The modules without the _ in the library
Can you shorten module names?
Yes
Which command do you use to import the netmiko module?
from netmiko import ConnectHandler