0% found this document useful (0 votes)
55 views28 pages

Finals Reviewer

finals

Uploaded by

Sneha arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views28 pages

Finals Reviewer

finals

Uploaded by

Sneha arora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Functions:

What is a group of statements that exists within a program for the purpose of performing a specific
task?

A) a function

B) a subtask

C) a process

D) a subprocess

ANSWER: A

The first line in a function definition is known as the function

A) header

B) block

C) return

D) parameter

ANSWER: A

The ________ design technique can be used to break down an algorithm into functions.

A) subtask

B) block

C) top-down

D) simplification

ANSWER: C

A set of statements that belong together as a group and contribute to the function definition is known
as a

A) header

B) block

C) return

D) parameter

ANSWER: B

A(n) ________ chart is also known as a structured chart.

A) flow
B) data

C) hierarchy

D) organizational

ANSWER: C

The ________ keyword is ignored by the Python interpreter and can be used as a placeholder for code
that will be written later.

A) placeholder

B) pass

C) pause

D) skip

ANSWER: B

A ________ variable is created inside a function.

A) global

B) constant

C) named constant

D) local

ANSWER: D

The ________ of a local variable is the function in which that variable is created.

A) global reach

B) definition

C) space

D) scope

ANSWER: D

A(n) ________ is any piece of data that is passed into a function when the function is called.

A) global variable

B) argument

C) local variable

D) parameter

ANSWER: B
A(n) ________ is a variable that receives an argument that is passed into a function.

A) global variable

B) argument

C) named constant

D) parameter

ANSWER: D

A ________ variable is accessible to all the functions in a program file.

A) keyword

B) local

C) global

D) string

ANSWER: C

A ________ constant is a name that references a value that cannot be changed while the program runs.

A) keyword

B) local

C) global

D) string

ANSWER: C

When a function is called by its name during the execution of a program, then it is

A) executed

B) located

C) defined

D) exported

ANSWER: A

It is recommended that programmers avoid using ________ variables in a program whenever possible.

A) local

B) global

C) string

D) keyword
ANSWER: B

The Python library functions that are built into the Python ________ can be used by simply calling the
required function.

A) code

B) compiler

C) linker

D) interpreter

ANSWER: D

Python comes with ________ functions that have already been prewritten for the programmer.

A) standard

B) library

C) custom

D) key

ANSWER: A

What type of function can be used to determine whether a number is even or odd?

A) even

B) odd

C) math

D) Boolean

ANSWER: D

A value-returning function is

A) a single statement that performs a specific task

B) called when you want the function to stop

C) a function that will return a value back to the part of the program that called it

D) a function that receives a value when called

ANSWER: C

Which of the following statements causes the interpreter to load the contents of the random module
into memory?

A) load random
B) import random

C) upload random

D) download random

ANSWER: B

Which of the following will assign a random integer in the range of 1 through 50 to the variable number?

A) random(1, 50) = number

B) number = random.randint(1, 50)

C) randint(1, 50) = number

D) number = random(range(1, 50))

ANSWER: B

What does the following statement mean?num1, num2 = get_num()

A) The function get_num() is expected to return a value for num1 and for num2.

B) The function get_num() is expected to return one value and assign it to num1 and num2.

C) This statement will cause a syntax error.

D) The function get_num() will receive the values stored in num1 and num2.

ANSWER: A

What will display after the following code is executed?[def main(): print("The answer is", magic(5))def
magic(num): answer = num + 2 * 10 return answerif __name__ == '__main__': main()]

A) 70

B) 25

C) 100

D) The statement will cause a syntax error.

ANSWER: B

In a value-returning function, the value of the expression that follows the keyword ________ will be sent
back to the part of the program that called the function.

A) def

B) result

C) sent

D) return
ANSWER: D

The Python standard library's ________ module contains numerous functions that can be used in
mathematical calculations.

A) math

B) string

C) random

D) number

ANSWER: A

Which of the following functions returns the largest integer that is less than or equal to its argument?

A) floor

B) ceil

C) lesser

D) greater

ANSWER: A

What will be the output after the following code is executed?[def pass_it(x, y): z = x + ", " + y
return(z)name2 = "Julian"name1 = "Smith"fullname = pass_it(name1, name2)print(fullname)]

A) Julian Smith

B) Smith Julian

C) Julian, Smith

D) Smith, Julian

ANSWER: D

What will be the output after the following code is executed?[def pass_it(x, y): z = x , ", " , ynum1 =
4num2 = 8answer = pass_it(num1, num2)print(answer)]

A) 4, 8

B) 8, 4

C) 48

D) None

ANSWER: D

What will be the output after the following code is executed?[def pass_it(x, y): z = y**x return(z)num1 =
3num2 = 4answer = pass_it(num1, num2)print(answer)]
A) 81

B) 64

C) 12

D) None

ANSWER: B

What will be displayed after the following code is executed?[def pass_it(x, y): z = x*y result =
get_result(z) return(result)def get_result(number): z = number + 2 return(z)num1 = 3num2 = 4answer =
pass_it(num1, num2)print(answer)]

A) 12

B) 9

C) 14

D) Nothing; this code contains a syntax error.

ANSWER: C

What does the following program do?[import turtledef main(): turtle.hideturtle()


square(100,0,50,'blue')def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color)
turtle.pendown() turtle.begin_fill() for count in range(4): turtle.forward(width) turtle.left(90)
turtle.end_fill()if __name__ == '__main__': main()]

A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right corner.

B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right corner.

C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner.

D) Nothing; since you cannot call a function with turtle graphics.

ANSWER: C

What does the following program do?[import turtledef main(): turtle.hideturtle()


square(100,0,50,'blue')def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color)
turtle.pendown() turtle.begin_fill() for count in range(2): turtle.forward(width) turtle.left(90)
turtle.end_fill()if __name__ == '__main__': main()]

A) It draws a blue square.

B) It draws a blue triangle.

C) It draws 2 blue lines.

D) Nothing; since you cannot call a function with turtle graphics.

ANSWER: B
Files and Exceptions:
Which of the following is associated with a specific file and provides a way for the program to work with
that file?

A) the filename

B) the file extension

C) the file object

D) the file variable

ANSWER: C

What is the process of retrieving data from a file called?

A) retrieving data

B) reading data

C) reading input

D) getting data

ANSWER: B

Which of the following describes what happens when a piece of data is written to a file?

A) The data is copied from a variable in RAM to a file.

B) The data is copied from a variable in the program to a file.

C) The data is copied from the program to a file.

D) The data is copied from a file object to a file.

ANSWER: A

Which step creates a connection between a file and a program?

A) open the file

B) read the file

C) process the file

D) close the file

ANSWER: A

How many types of files are there?


A) one

B) two

C) three

D) more than three

ANSWER: B

A(n) ________ access file is also known as a direct access file.

A) sequential

B) random

C) numbered

D) text

ANSWER: B

Which type of file access jumps directly to a piece of data in the file without having to read all the data
that comes before it?

A) sequential

B) random

C) numbered

D) text

ANSWER: B

A single piece of data within a record is called a

A) variable

B) delimiter

C) field

D) data bit

ANSWER: C

Which mode specifier will erase the contents of a file if it already exists and create the file if it does NOT
already exist?

A) 'w'

B) 'r'

C) 'a'
D) 'e'

ANSWER: A

Which mode specifier will open a file but not let you change the file or write to it?

A) 'w'

B) 'r'

C) 'a'

D) 'e'

ANSWER: B

Which method could be used to strip specific characters from the end of a string?

A) estrip

B) rstrip

C) strip

D) remove

ANSWER: B

Which method could be used to convert a numeric value to a string?

A) str

B) value

C) num

D) chr

ANSWER: A

Which method will return an empty string when it has attempted to read beyond the end of a file?

A) read

B) getline

C) input

D) readline

ANSWER: D

Which statement can be used to handle some of the runtime errors in a program?

A) an exception statement

B) a try statement
C) a try/except statement

D) an exception handler statement

ANSWER: C

Given that the customer file references a file object, and the file was opened using the 'w' mode
specifier, how would you write the string 'Mary Smith' to the file?

A) customer file.write('Mary Smith')

B) customer.write('w', 'Mary Smith')

C) customer.input('Mary Smith')

D) customer.write('Mary Smith')

ANSWER: D

When a file has been opened using the 'r' mode specifier, which method will return the file's contents as
a string?

A) write

B) input

C) get

D) read

ANSWER: D

Which of the following is the correct way to open a file named users.txt in 'r' mode?

A) infile = open('r', users.txt)

B) infile = read('users.txt', 'r')

C) infile = open('users.txt', 'r')

D) infile = readlines('users.txt', r)

ANSWER: C

Which of the following is the correct way to open a file named users.txt to write to it?

A) outfile = open('w', users.txt)

B) outfile = write('users.txt', 'w')

C) outfile = open('users.txt', 'w')

D) outfile = open('users.txt')

ANSWER: C
What will be the output after the following code is executed and the user enters 75 and 0 at the first
two prompts?[def main(): try: total = int(input("Enter total cost of items? ")) num_items =
int(input("Number of items ")) average = total / num_items except ZeroDivisionError: print('ERROR:
cannot have 0 items') except ValueError: print('ERROR: number of items cannot be negative')if
__name__ == '__main__': main()]

A) ERROR: cannot have 0 items

B) ERROR: number of items can't be negative

C) 0

D) Nothing; there is no print statement to display average.

ANSWER: A

What will be the output after the following code is executed and the user enters 75 and -5 at the first
two prompts?[def main(): try: total = int(input("Enter total cost of items? ")) num_items =
int(input("Number of items ")) average = total / num_items except ZeroDivisionError: print('ERROR:
cannot have 0 items') except ValueError: print('ERROR: number of items cannot be negative')if
__name__ == '__main__': main()]

A) ERROR: cannot have 0 items

B) ERROR: cannot have 0 itemsERROR: number of items can't be negative

C) ERROR: number of items can't be negative

D) Nothing; there is no print statement to display average. The ValueError will not catch the error.

ANSWER: D

Lists and Tuples


What are the data items in a list called?

A) data

B) elements

C) items

D) values

ANSWER: B

When working with multiple sets of data, one would typically use a(n)

A) list

B) tuple
C) nested list

D) sequence

ANSWER: C

The primary difference between a tuple and a list is that

A) you don't use commas to separate elements in a tuple

B) a tuple can only include string elements

C) a tuple cannot include lists as elements

D) once a tuple is created, it cannot be changed

ANSWER: D

What is an advantage of using a tuple rather than a list?

A) Tuples are not limited in size.

B) Tuples can include any data as an element.

C) Processing a tuple is faster than processing a list.

D) There is never an advantage to using a tuple.

ANSWER: C

Which list will be referenced by the variable number after the following code is executed?number =
range(0, 9, 2)

A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

B) [1, 3, 5, 7, 9]

C) [2, 4, 6, 8]

D) [0, 2, 4, 6, 8]

ANSWER: D

Which of the following would you use if an element is to be removed from a specific index?

A) a del statement

B) a remove method

C) an index method

D) a slice method

ANSWER: A

What is the first negative index in a list?


A) 0

B) -1

C) -0

D) the size of the list minus 1

ANSWER: B

Which method can be used to place an item at a specific index in a list?

A) append

B) index

C) insert

D) add

ANSWER: C

Which method or operator can be used to concatenate lists?

A) *

B) +

C) %

D) concat

ANSWER: B

Which method can be used to convert a list to a tuple?

A) append

B) tuple

C) insert

D) list

ANSWER: B

Which method can be used to convert a tuple to a list?

A) append

B) tuple

C) insert

D) list

ANSWER: D
What will be the value of the variable list after the following code executes?list = [1, 2]list = list * 3

A) [1, 2] * 3

B) [3, 6]

C) [1, 2, 1, 2, 1, 2]

D) [1, 2], [1, 2], [1, 2]

ANSWER: C

What will be the value of the variable list after the following code executes?list = [1, 2, 3, 4]list[3] = 10

A) [1, 2, 3, 10]

B) [1, 2, 10, 4]

C) [1, 10, 10, 10]

D) Nothing; this code is invalid.

ANSWER: A

What will be the value of the variable list2 after the following code executes?[list1 = [1, 2, 3]list2 = []for
element in list1: list2.append(element)list1 = [4, 5, 6]]

A) [1, 2, 3]

B) [4, 5, 6]

C) [1, 2, 3, 4, 5, 6]

D) Nothing; this code is invalid.

ANSWER: A

This function in the random module returns a random element from a list.

A) choice

B) choices

C) sample

D) random_element

ANSWER: A

This function in the random module returns multiple, nonduplicated random elements from a list.

A) choice

B) choices

C) sample
D) random_element

ANSWER: B

What values will list2 contain after the following code executes?list1 = [1, 2, 3]list2 = [item + 1 for item in
list1]

A) [1, 2, 3]

B) [2, 3, 4]

C) [6, 7, 8]

D) [[1, 2, 3],[2, 3, 4],[3, 4, 5]]

ANSWER: B

What values will list2 contain after the following code executes?list1 = [1, 10, 3, 6]list2 = [item * 2 for
item in list1 if item > 5]

A) [2, 20, 6, 12]

B) [10, 6]

C) [20, 12]

D) [[1, 10, 3, 6],[1, 10, 3, 6]]

ANSWER: C

In order to create a graph in Python, you need to include

A) import matplotlib

B) import pyplot

C) import matplotlib.pyplot

D) import matplotlibimport pyplot

ANSWER: C

What will be the output after the following code is executed?[import matplotlib.pyplot as pltdef main():
x_crd = [0, 1, 2, 3, 4, 5] y_crd = [2, 4, 5, 2] plt.plot(x_crd, y_crd)if __name__ == '__main__': main()]

A) It will display a simple line graph.

B) It will display a simple bar graph.

C) Nothing; plt is not a Python method.

D) Nothing; the number of x-coordinates do not match the number of y-coordinates.

ANSWER: D
More about Strings:

What are the valid indexes for the string 'New York'?

A) 0 through 7

B) 0 through 8

C) -1 through -8

D) -1 through 6

ANSWER: A

What will be displayed after the following code executes?mystr = 'yes'yourstr = 'no'mystr += yourstr *
2print(mystr)

A) yes + no * 2

B) yes + no yes + no

C) yesnono

D) yesnoyesno

ANSWER: C

What will be assigned to the variable s_string after the following code executes?special = '1357 Country
Ln.'s_string = special[ :4]

A) '7'

B) '1357'

C) 5

D) '7 Country Ln.'

ANSWER: B

What will be assigned to the variable s_string after the following code executes?special = '1357 Country
Ln.'s_string = special[4:]

A) ' Country Ln.'

B) '1357'

C) 'Coun'

D) '57 C'

ANSWER: A
What will be assigned to the variable s_string after the following code executes?special = '1357 Country
Ln.'s_string = special[-3:]

A) '135'

B) '753'

C) 'Ln.'

D) 'y Ln'

ANSWER: C

What will be assigned to the variable some_nums after the following code executes?special =
'0123456789'some_nums = special[0:10:2]

A) '0123456789'

B) '24682468'

C) '02468'

D) '02020202020202020202'

ANSWER: C

If the start index is ________ the end index, the slicing expression will return an empty string.

A) equal to

B) less than

C) greater than

D) less than or equal to

ANSWER: C

What is the return value of the string method lstrip()?

A) the string with all whitespaces removed

B) the string with all leading whitespaces removed

C) the string with all leading tabs removed

D) the string with all leading spaces removed

ANSWER: B

What is the first negative index in a string?

A) 0

B) -1
C) -0

D) the size of the string minus one

ANSWER: B

What will be assigned to the string variable pattern after the following code executes?i = 3pattern = 'z' *
(5 * i)

A) 'zzzzzzzzzzzzzzz'

B) 'zzzzz'

C) 'z * 15'

D) Nothing; this code is invalid.

ANSWER: A

Which method would you use to determine whether a certain substring is present in a string?

A) endswith(substring)

B) find(substring)

C) replace(string, substring)

D) startswith(substring)

ANSWER: B

Which method would you use to determine whether a certain substring is the suffix of a string?

A) endswith(substring)

B) find(substring)

C) replace(string, substring)

D) startswith(substring)

ANSWER: A

What list will be referenced by the variable list_strip after the following code executes?my_string =
'03/07/2018'list_strip = my_string.split('/')

A) ['3', '7', '2018']

B) ['03', '07', '2018']

C) ['3', '/', '7', '/', '2018']

D) ['03', '/', '07', '/', '2018']

ANSWER: B
What will be the value of the variable string after the following code executes?string =
'abcd'string.upper()

A) 'abcd'

B) 'ABCD'

C) 'Abcd'

D) Nothing; this code is invalid.

ANSWER: B

What will be the value of the variable string after the following code executes?string = 'Hello'string += '
world!'

A) 'Hello'

B) ' world!'

C) 'Hello world!'

D) Nothing; this code is invalid.

ANSWER: C

What will display after the following code executes?[password = 'ILOVEPYTHON'if password.isalpha():
print('Invalid, must contain one number.')elif password.isdigit(): print('Invalid, must have one non-
numeric character.')elif password.isupper(): print('Invalid, cannot be all uppercase characters.')else:
print('Your password is secure!')]

A) Invalid, must contain one number.

B) Invalid, must have one non-numeric character.

C) Invalid, must contain one number.Invalid, cannot be all uppercase characters.

D) Your password is secure!

ANSWER: A

Dictionaries and Sets:

In a dictionary, you use a(n) ________ to locate a specific value.

A) datum

B) element

C) item
D) key

ANSWER: D

What is the correct structure to create a dictionary of months where each month will be accessed by its
month number (for example, January is month 1, April is month 4)?

A) { 1 ; 'January', 2 ; 'February', ... 12 ; 'December'}

B) { 1 : 'January', 2 : 'February', ... 12 : 'December' }

C) [ '1' : 'January', '2' : 'February', ... '12' : 'December' ]

D) { 1, 2,... 12 : 'January', 'February',... 'December' }

ANSWER: B

What will be the result of the following code?ages = {'Aaron' : 6, 'Kelly' : 3, 'Abigail' : 1 }value =
ages['Brianna']

A) False

B) -1

C) 0

D) KeyError

ANSWER: D

What is the number of the first index in a dictionary?

A) 0

B) 1

C) the size of the dictionary minus one

D) Dictionaries are not indexed by number.

ANSWER: D

What is the value of the variable phones after the following code executes?phones = {'John' : '5555555',
'Julie' : '5557777'}phones['John'] = 5556666'

A) {'John' : '5555555', 'Julie' : '5557777'}

B) {'John' : '5556666', 'Julie' : '5557777'}

C) {'John' : '5556666'}

D) This code is invalid.

ANSWER: B

Which would you use to delete an existing key-value pair from a dictionary?
A) del

B) remove

C) delete

D) unpair

ANSWER: A

Which would you use to get the number of elements in a dictionary?

A) size

B) length

C) len

D) sizeof

ANSWER: C

Which method would you use to get all the elements in a dictionary returned as a list of tuples?

A) list

B) items

C) pop

D) keys

ANSWER: B

Which method would you use to get the value associated with a specific key and remove that key-value
pair from the dictionary?

A) list

B) items

C) pop

D) popitem

ANSWER: C

What values will d2 contain after the following code executes?d = {1: 10, 2: 20, 3: 30}d2 = {k:v for k,v in
d.items()}

A) {10: 1, 20: 2, 30: 3}

B) {1: 1, 2: 2, 3: 3}

C) {10: 10, 20: 20, 30: 30}


D) {1: 10, 2: 20, 3: 30}

ANSWER: D

Which method can be used to add a group of elements to a set?

A) add

B) addgroup

C) update

D) addset

ANSWER: C

In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the
________ operator.

A) included

B) in

C) isnotin

D) isin

ANSWER: B

What does the get method do if the specified key is NOT found in the dictionary?

A) It throws an exception.

B) It does nothing.

C) It returns a default value.

D) You cannot use the get method to specify a key.

ANSWER: C

Which of the following does NOT apply to sets?

A) The stored elements can be of different data types.

B) All the elements must be unique; you cannot have two elements with the same value.

C) The elements are unordered.

D) The elements are in pairs.

ANSWER: D

What is the process used to convert an object to a stream of bytes that can be saved in a file?

A) pickling
B) streaming

C) writing

D) dumping

ANSWER: A

What will be displayed after the following code executes? (Note: the order of the display of entries in a
dictionary are not in a specific order.)[cities = {'GA' : 'Atlanta', 'NY' : 'Albany', 'CA' : 'San Diego'}if 'CA' in
cities: del cities['CA'] cities['CA'] = 'Sacramento'print(cities)]

A) {'CA': 'Sacramento'}

B) ['CA': 'Sacramento']

C) {'NY': 'Albany', 'GA': 'Atlanta'}

D) {'CA': 'Sacramento', 'NY': 'Albany', 'GA': 'Atlanta'}

ANSWER: D

What will be displayed after the following code executes? (Note: the order of the display of entries in a
dictionary are not in a specific order.)[cities = {'GA' : 'Atlanta', 'NY' : 'Albany', 'CA' : 'San Diego'}if 'FL' in
cities: del cities['FL'] cities['FL'] = 'Tallahassee'print(cities)]

A) {'FL': 'Tallahassee'}

B) KeyError

C) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta', 'FL' 'Tallahassee'}

D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}

ANSWER: D

What will be displayed after the following code executes? (Note: the order of the display of entries in a
dictionary are not in a specific order.)[cities = {'GA' : 'Atlanta', 'NY' : 'Albany', 'CA' : 'San Diego'}if 'FL' in
cities: del cities['FL']cities['FL'] = 'Tallahassee'print(cities)]

A) {'FL': 'Tallahassee'}

B) KeyError

C) {'GA': 'Atlanta', 'FL': 'Tallahassee', 'NY': 'Albany', 'CA': 'San Diego'}

D) {'CA': 'San Diego', 'NY': 'Albany', 'GA': 'Atlanta'}

ANSWER: C
Classes and Object Oriented Programming:
What does the acronym UML stand for?

A) Unified Modeling Language

B) United Modeling Language

C) Unified Model Language

D) Union of Modeling Languages

ANSWER: A

Which section in the UML holds the list of the class's data attributes?

A) first section

B) second section

C) third section

D) fourth section

ANSWER: B

Which section in the UML holds the list of the class's methods?

A) first section

B) second section

C) third section

D) fourth section

ANSWER: C

What type of method provides a safe way for code outside a class to retrieve the values of attributes,
without exposing the attributes in a way that could allow them to be changed by code outside the
method?

A) accessor

B) mutator

C) setter

D) class

ANSWER: A

The procedures that an object performs are called

A) methods
B) actions

C) modules

D) instances

ANSWER: A

Which attributes belong to a specific instance of a class?

A) instance

B) self

C) object

D) data

ANSWER: A

What is the special name given to the method that returns a string containing an object's state?

A) __state__

B) __obj__

C) __str__

D) __init__

ANSWER: C

Which method is automatically executed when an instance of a class is created in memory?

A) __state__

B) __obj__

C) __str__

D) __init__

ANSWER: D

Which method is automatically called when you pass an object as an argument to the print function?

A) __state__

B) __obj__

C) __str__

D) __init__

ANSWER: C

What type of programming contains class definitions?


A) procedural

B) top-down

C) object-oriented

D) modular

ANSWER: C

Which of the following can be thought of as a self-contained unit that consists of data attributes and the
methods that operate on the data attributes?

A) a class

B) an object

C) an instance

D) a module

ANSWER: B

Combining data and code in a single object is known as

A) modularity

B) instantiation

C) encapsulation

D) objectification

ANSWER: C

Mutator methods are also known as

A) setters

B) getters

C) instances

D) attributes

ANSWER: A

Accessor methods are also known as

A) setters

B) getters

C) instances

D) attributes
ANSWER: B

When an object is passed as an argument, ________ is passed into the parameter variable.

A) a copy of the object

B) a reference to the object's state

C) a reference to the object

D) Objects cannot be passed as arguments.

ANSWER: C

In object-oriented programming, one of first tasks of the programmer is to

A) list the nouns in the problem

B) list the methods that are needed

C) identify the classes needed

D) identify the objects needed

ANSWER: C

Which is the first line needed when creating a class named Worker?

A) def__init__(self):

B) class Worker:

C) import random

D) def worker_pay(self):

ANSWER: B

Which of the following will create an object, worker_joey, of the Worker class?

A) def__init__(worker_joey):

B) class worker_joey:

C) worker_joey = Worker()

D) worker_joey.Worker

ANSWER: C

You might also like