4 Python Fuction and Classes Flashcards
Which of the following is the correct syntax for a Python function?
a. define function (arg):
b. function function(arg);
c. def function(arg):
d. func function(arg):
C
Which of the following is a valid Python function name?
a. 1function
b. __init__
c. True
d. Funct1on
D
When three single quotation marks are used on the next line directly after defining a
function, what does this indicate?
a. Multi-line text
b. A docstring
c. A string value including double or single quotation marks
d. None of the above
B
What are key components of object-oriented programming in Python? (Choose two.)
a. Functions that can be performed on a data structure
b. Attributes that are stored in an object
c. Configuration templates
d. YAML files
A,B
Which of the following are benefits of OOP? (Choose all that apply.)
a. Reusable code
b. Easy to follow
c. Low coupling/high cohesion
d. Complex integration
A,B,C
Which of the following are used to define a class in Python? (Choose two.)
a. class classname(parent):
b. class classname:
c. def class classname(arg):
d. None of the above
A,B
What is a method?
a. A variable applied to a class
b. Syntax notation
c. A function within a class or an object
d. Something that is not used in a class
C
Which of the following describes inheritance?
a. A hierarchy for functions in Python
b. Class attributes and methods used as the starting point for another class
c. A function only applied to methods being used in another class
d. None of the above
B
Which module provides access to the file system and directory structure?
a. filesystem
b. open
c. system
d. os
D
Which module is a testing framework for Cisco infrastructure?
a. pyATS
b. pyang
c. devnetats
d. ncclient
A
Allows a child class to take on attributes and methods of
another class. In the previous section
Inheritance
Allow you to interact with an object
Methods
Creates a new local namespace where all its attributes are defined (describe objects)
Class
Object Oriented Programation
OOP