4 Python Fuction and Classes Flashcards

1
Q

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):

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is a valid Python function name?
a. 1function
b. __init__
c. True
d. Funct1on

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A,B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A,B,C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A,B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which module provides access to the file system and directory structure?

a. filesystem
b. open
c. system
d. os

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which module is a testing framework for Cisco infrastructure?

a. pyATS
b. pyang
c. devnetats
d. ncclient

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Allows a child class to take on attributes and methods of
another class. In the previous section

A

Inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Allow you to interact with an object

A

Methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Creates a new local namespace where all its attributes are defined (describe objects)

A

Class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Object Oriented Programation

A

OOP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly