2:2

Ace your homework & exams now with Quizwiz!

What will be assigned to the string variable even after the execution of the following code? special = '0123456789' even = special[0:10:2]

'02468'

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

'02468'

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

'02468'

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

'02468'

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

'1357'

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

'1357'

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

'1357'

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

'1357'

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

'1357'

What is the value of the variable string after the execution of the following code? string = 'abcd' string.upper()

'ABCD'

What is the value of the variable string after the execution of the following code? string = 'abcd' string.upper()

'ABCD'

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

'ABCD'

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

'ABCD'

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

'ABCD'

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

'Hello world!'

What will be the value of the variable string after the following code executes? string = 'Hello' string += ' world!' ' world' 'Hello world!' 'Hello' Nothing; this code is invalid

'Hello world!'

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

'Hello world!'

What is the value of the variable string after the execution of the following code? string = 'Hello' string += ' world'

'Hello world'

What is the value of the variable string after the execution of the following code? string = 'Hello' string += ' world'

'Hello world'

What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.' s_string = special[-3: ]

'Ln.'

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

'Ln.'

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

'Ln.'

Which of these is not a valid file mode when opening a file in Python?

'f'

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

'r'

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

'r'

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

'r'

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

'r' r read read mode "r"

When you open a file for the purpose of retrieving a pickled object from it, what file access mode do you use?

'rb'

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

'w'

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

'w'

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

'w'

When you open a file for the purpose of saving a pickled object to it, what file access mode do you use?

'wb'

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

'zzzzzzzzzzzzz'

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

'zzzzzzzzzzzzzzz'

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

'zzzzzzzzzzzzzzz'

What will be assigned to the string variable pattern after the following code executes? i = 3 pattern = 'z' * (5 * i) 'zzzzzzzzzzzzzzz' 'z' * '15' 'zzzzz' Nothing; this code is invalid

'zzzzzzzzzzzzzzz'

What are the 5 major components of a computer system?

(1) CPU , (2) Main Memory , (3) Secondary Storage devices , (4) Input devices , (5) Output devices

Given the following function definition, what would the statement print magic(5) display? def magic(num): return num + 2 * 10

25

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 answer main()

25

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 answer main()

25

def main(): print("The answer is", magic(5)) def magic(num): answer = num + 2 * 10 return answer main()

25

What is the largest value that can be stored in one byte?

255

The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.

3

int

A Python data type that holds positive and negative whole numbers

float

A Python data type which stores floating-point numbers. Floating-point numbers are stored internally in two parts: a base and an exponent. When printed in the standard format, they look like decimal numbers

What is the relationship called in which one object is a specialized version of another object? a. parent-child b. node-to-node c. is a d. class-subclass

C

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__

C

What type of programming contains class definitions? a. procedural b. top-down c. object-oriented d. modular

C

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'

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'

C

What will be displayed after the following code executes? mystr = 'yes' yourstr = 'no' mystr += yourstr * 2 print(mystr) a. yes + no * 2 b. yes + no yes + no c. yesnono d. yesnoyesno

C

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.

D

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

' Country Ln.'

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

' Country Ln.'

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

' Country Ln.'

What will be assigned to the string variable even after the execution of the following code? special = '0123456789' even = special[0:10:2]

'02468'

chart is an effective tool used by programmers to design and document functions.

IPO

What is the output of the following code? list1 = [1, 2, 3, 4] list1[3] = 10 print(list1)

None of these

What is the output of the following code? list1=[1,2,3] list2=list1 list1[1]=7 print(list2)

None of these

When using the _____ operator, one or both subexpressions must be true for the compound expression to be true.

Or

When working with this type of file, you access its data from the beginning of the file to the end of the file.

Ordered Access

What part of the computer formats and presents data for people or other devices?

Output

When data is written to a file, it is described as a(n) ____ file.

Output

A dictionary can include the same value several times but cannot include the same key several times. (T/F)

True

A dictionary can include thee same value several times but cannot include the same key several times

True

A flowchart is a tool used by programmers to design programs.

True

A good way to repeatedly perform an operation is to write the statements for the task once and then place the statements in a loop that will repeat as many times as necessary.

True

A software developer is the person with the training to design, create, and test computer programs.

True

A tuple can be a dictionary key. T or F

True

A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it. T/F

True

An action in a single alternative decision structure is performed only when the condition is true.

True

An exception handler is a piece of code that is written using the try/except statement. True or False

True

Both of the following for clauses would generate the same number of loop iterations. for num in range(4): for num in range(1, 5):

True

Closing a file disconnects the communication between the file and the program. True or False

True

Comments in Python begin with the # character.

True

Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produced.

True

Dictionaries are not sequences. T or F

True

Different functions can have local variables with the same names. T/F

True

Digital Device is any device that works with binary

True

Digital data is stored in binary format

True

Expressions that are tested by the if statement are called Boolean expressions.

True

IDLE is an alternative method to using a text editor to write, execute, and test a Python program.

True

If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences in the paragraph. (T/F)

True

If the + operator is used on strings, it produces a string that is a combination of the two strings used as its operands. (T/F)

True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError exception is raised

True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError exception is raised. True or False

True

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError exception is raised. (T/F)

True

In Python you can have a list of variables on the left side of the argument operator. T/F

True

In a nested loop, the inner loop goes through all of its iterations for each iteration of the outer loop.

True

In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead

True

In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead. True or False

True

In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead. (T/F)

True

In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.

True

In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead. True or False

True

In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead. (T/F)

True

Invalid indexes do not cause slicing expressions to raise an exception (T/F)

True

Invalid indexes do not cause slicing expressions to raise an exception. True or False

True

Invalid indexes do not cause slicing expressions to raise an excption

True

List are dynamic data structures such that items may be added to them or removed from them (T/F)

True

Lists are dynamic data structures such that items may added to them or removed from them

True

Object reusability has been a factor in the increased use of object-oriented programming

True

Object-oriented programming allows us to hide the object's data attributes from code that is outside the object. True or False

True

Object-oriented programming allows us to hide the object's data attributes from code that is outside the object. (T/F)

True

Once a string is created, it cannot be changed

True

One reason not to use global variables is that it makes a program hard to debug.

True

One reason not to use global variables is that it makes a program hard to debug. T/F

True

One reason to store graphics functions in a module is so that you can import the module into any program that needs to use those functions. T/F

True

Python allows programmers to break a statement into multiple lines

True

Python allows programmers to break a statement into multiple lines.

True

Python allows you to pass multiple arguments to a function. T/F

True

Python function names follow the same rules as those for naming variables. T/F

True

RAM is a volatile memory used for temporary storage while a program is running.

True

RAM is volatile memory used for temporary storage while a program is running.

True

Reducing duplication of code is one of the advantages of using a loop structure.

True

Sets store their elements in an unordered fashion. T or F

True

Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written. True or False

True

The CPU is able to quickly access data stored at any random location in ROM.

True

The CPU understands instructions written in a binary machine language

True

The CPU understands instructions written in a binary machine language.

True

The \t escape character causes the output to skip over to the next horizontal tab.

True

The difference of set1 and set2 is a set that contains only the elements that appear in set1 but do not appear in set2. True or False

True

The following statement creates an empty dictionary: mydct = { } T or F

True

The function header marks the beginning of the function definition. T/F

True

The hidden data attributes of an object can be accessed by any public method using the reference of the object

True

The index -1 identifies the last character of a string

True

The index -1 identifies the last character of a string.

True

The index -1 identifies the last character of a string. True or False

True

The index -1 identifies the last element in a list

True

The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand

True

The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.

True

The integrity of a program's output is only as good as the integrity of its input. For this reason, the program should discard input that is invalid and prompt the user to enter valid data.

True

The isalpha() method returns _____ if the string contains only alphabetic characters and is at least one character in length.

True

The issubset() method can be used to determine whether set1 is a subset of set2. True or False

True

The main reason to use secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.

True

The math function ceil(x) returns the smallest integer that is greater than or equal to x. T/F

True

The randint function of a random module is used to generate a random number

True

The randrange function returns a randomly selected value from a specific sequence of numbers. T/F

True

The remove method raises an exception if the specified element is not found in the set. T or F

True

The repetition operator (*) works with strings as weak as with lists

True

The self parameter is required in every method of a class. True or False

True

The self parameter is required in every method of a class. (T/F)

True

The self parameter need not be named self but it is strongly recommended to do so, to conform with standard practice . True or False

True

The self parameter need not be named self but it is strongly recommended to do so, to conform with standard practice. (T/F)

True

To assign a value to a global variable in a function, the global variable must be first declared in the function. T/F

True

To calculate the average of the numeric values in a list, the first step is to get the total of values in the list

True

To calculate the average of the numeric values in a list, the first step is to get the total of values in the list (T/F)

True

To calculate the average of the numeric values in a list, the first step is to get the total values in the list. True or False

True

True or False: When two arguments are supplied to range, the count ranges from the first argument to the second argument minus 1.

True

True/False: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.

True

True/False: An action in a single alternative decision structure is performed only when the condition is true.

True

True/False: Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.

True

True/False: Expressions that are tested by the if statement are called Boolean expressions.

True

True/False: In Python, print statements written on separate lines do not necessarily output on separate lines.

True

True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.

True

True/False: Nested decision structures are one way to test more than one condition.

True

True/False: Python allows programmers to break a statement into multiple lines.

True

True/False: RAM is a volatile memory used for temporary storage while a program is running.

True

True/False: The CPU understands instructions written in a binary machine language.

True

True/False: The \t escape character causes the output to skip over to the next horizontal tab.

True

True/False: The first line in the while loop is referred to as the condition clause.

True

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x

True

When using the camelCase naming convention, the first word of the variable name is written in lowercase and the first characters of all subsequent words are written in uppercase.

True

You can use the for loop to iterate over the individual characters in a string

True

You would typically use a for loop to iterate over the elements in a set. True or False

True

The _________ is part of the computer with which the user interacts

User interface

With what part of the computer does the user interact?

User interface

What is the output of the following program? count = 5 while (count > 0): print("Woot!") count -= 1

Woot! is printed out 5 times

This is a feature of OOP that wraps data attributes and its relevant methods in a bundle

Encapsulation

What is the combining of data and code in a single object known as?

Encapsulation

In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.

End

One way to find the classes needed for an object-oriented program is to identify all of the verbs in a description of the problem domain

False

Python allows the programmer to work with text and number files. True or False

False

Python allows you to compare strings, but it is not case sensitive.

False

Python formats all floating-point numbers to two decimal places when outputting using the print statement

False

Python formats all floating-point numbers to two decimal places when outputting with the print statement.

False

Sets are created using curly braces {}. True or False

False

Since a named constant is just a variable, it can change any time during a program's execution.

False

The Python language is not sensitive to block structuring of code.

False

The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level language.

False

The Python language uses a compiler, which is a program that both translates and executes the instructions in a high level language.

False

The dictionary method popitem does not raise an exception if it is called on an empty dictionary. T or F

False

The elements in a dictionary are stored in ascending order, by the keys of the key-value pairs

False

The elements in a dictionary are stored in ascending order, by the keys of the key-value pairs. True or False

False

The first line in a while loop is referred to as the condition clause.

False

The following code will display 'yes + no': mystr = 'yes' yourstr = 'no' mystr += yourstr print(mystr) (T/F)

False

The following code will display 'yes + no': mystr = 'yes' yourstr = 'no' mystr += yourstr print(mystr) True or False

False

The following expression is valid: string[i] = 'i' (T/F)

False

The following expression is valid: string[i] = 'i'

False

The following statement creates an empty set: myset = ( ) T or F

False

The index of the first element in a list is 1, the index of the second element is 2, and so forth

False

The index of the first element in a list is 1, the index of the second element is 2, and so forth. True or False

False

The index of the first element in a list is 1, the index of the second element is 2, and so forth. (T/F)

False

The keys in a dictionary must be mutable objects. T or F

False

The math function atan(x) returns one tangent of x in radians. T/F

False

The not operator is a unary operator which must be used in a compound expression.

False

The practice of procedural programming is centered on the creation of objects

False

The remove method removes all occurrences of an item from a list

False

The remove method removes all occurrences of an item from a list (T/F)

False

The remove method removes all occurrences of an item from a list. True or False

False

The sort method rearranges the elements of a list so they are in ascending or descending order

False

The sort method rearranges the elements of a list so they are in ascending or descending order (T/F)

False

The strip() method returns a copy of the string with all the leading whitespace characters removed but does not remove trailing whitespace characters. (T/F)

False

The strip(0 method returns a copy of the string with all the leading whitespace characters removed but does not remove trailing whitespace characters. True or False

False

The suppler method converts a string to all uppercase characters

False

The union of two is a set that contains only the elements that ppear in both sets.. True or False

False

The value assigned to a global constant can be changed in the mainline logic. T/F

False

To add a descriptive label to the X and Y axes of a graph when using the matplotlib package, you need to import the labels module. True or False

False

To get the total number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop.

False

True or False: The third argument of the range function specifies the upper bound of the count.

False

True/False: In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.

False

True/False: Python allows you to compare strings, but it is not case sensitive.

False

True/False: Python formats all floating-point numbers to two decimal places when outputting using the print statement.

False

True/False: The Python language is not sensitive to block structuring of code.

False

Unfortunately, there is no way to store and call on functions when using turtle graphics. T/F

False

Unlike other languages, in Python the number of values a function can return is limited to one. T/F

False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y and z > x

False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8? not (x < y or z > x) and y < z

False

What is the result of the following Boolean expression, given that x = 5, y = 3, and z= 8? not (x < y or z > x) and y < z

False

When a piece of data is read from a file, it is copied from the file into the program.

False

When accessing each character in a string, such as for copying purposes, you would typically use a while loop. True or False

False

When you call string's split method, the method divides the string into two substrings

False

You can store duplicate elements in a set. T or F

False

You cannot use a for loop to iterate over the characters in a string. True or False

False

You cannot use a for loop to iterate over the characters in a string. (T/F)

False

To get the total number of iterations in a nested loop, add the number of iterations in the inner loop to the number in the outer loop.

False To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops

How many graphical widgets does the tkinter module provide?

Fifteen

When a program needs to save data for later use, it writes the data in a(n)_____.

File

Which of these is associated with a specific file and provides a way for the program to work with that file?

File object

Which of these is associated with a specific file, and provides a way for the program to work with that file?

File object

If a file does NOT exist and a program attempts to open it in append mode, what happens?

File will be created

What attributes belong to a specific instance of the class?

Instance

the __________ object is used to assign a unique integer value to each RadioButton widget

IntVar()

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

Gaddis, Tony

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

Gaddis, Tony

The ___ dictionary method return the value associated with a specified key. If the key is not found, it returns a default value.

Get()

Accessor methods are also known as

Getters

What is another name for the accessor methods?

Getters

The acronym GUI stands for:

Graphical User Interface

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

Greater than

What is the first step that needs to be taken in order to apply a recursive approach?

Identify at least one case in which the problem can be solved without recursion.

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

Identify the classes needed

The _______________ statement is used to create a decision structure.

If

What is the disadvantage of coding in one long sequence structure?

If parts of the duplicated code have to be corrected, the correction has to be made many times.

What is the difference between the remove and discard methods?

If the specified element to delete is not in the set, the remove method raises a KeyError exception, but the discard method does not raise an exception.

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

In

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

update

You can add a group of elements to a set with this method.

update

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

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

A(n) ________ loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.

infinite

You can add a group of elements to a set with this method. a. append b. add c. update d. merge

update

A(n) ___________ loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.

infinite

A(n) ____________ loop has no way of ending and repeats until the program is interrupted.

infinite

what concept involves a superclass and a subclass

inheritance

A(n) ________ validation loop is sometimes called an error trap or an error handler.

input

The ___ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input

The _____ built-in function is used to read a number that has been typed on the keyboard.

input

The _____ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input

The integrity of a program's output is only as good as the integrity of the program's

input

Using a while loop to ensure a proper response is received from a request is called

input validation

Using a while loop to ensure a proper response is received from a request is called ____________.

input validation

The _____ built-in function is used to read a number that has been typed on the keyboard.

input()

The ________ built-in function is used to read a number that has been typed on the keyboard.

input()

The ________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input()

The __________ built-in function is used to read a number that has been typed on the keyboard.

input()

Which of the following statements creates a tuple?

values = (1,)

A(n) _________ is a name that represents a value stored in the computer's memory.

variable

The __________ function reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program.

input()

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

insert

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

insert

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

insert

Which attributes belong to a specific instance of a class?

instance

Which attributes belong to a specific instance of a class? object data instance self

instance

statement

instruction that the Python interpreter can execute

A(n) _______________ is a name that represents a value stored in the computer's memory.

variable

A program that both translates and executes the instructions in a high-level language program The Python ___________ is a program that can read Python programming statements and execute them.

interpreter

The Python _______________ is a program that can read Python programming statements and execute them.

interpreter

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

interpreter

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

interpreter

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

interpreter

what is the string Modification method rstrip()?

returns the string with all trailing whitespace characters removed. Trailing whitespace are the spaces and tabs that appear at the end of the string.

What type of error produces incorrect results but does not prevent the program from running?

logic

AND, OR and NOT are ______ operators.

logical

and, or, and not are _________________ operators.

logical

A part of a program that executes a block of code repeatedly is called a(n) ____________.

loop

what is the string Testing method isalnum()?

returns true if the string contains only alphabetic letters or digits. Returns False otherwise.

Modules are __________________.

reusable pieces of software

The benefit of object-oriented programming is that it is

reusable. easy to understand. easy to update.

This string method returns a copy of the string with all leading whitespace characters removed

lstrip

The following is an example of an instruction written in which computer language? 1011 00010

machine language

A disk drive stores data by _________ encoding it onto a circular disk.

magnetically

The disk drive is a secondary storage device that stores data by _____ encoding it onto a spinning circular disk.

magnetically

The main function contains a program's ________ logic which is the overall logic of the program

mainline

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

math

Which standard library module contains trigonometric, exponential, and logarithmic functions?

math

Which widget will display multiple lines of text?

message

A(n)__________ is a function that belongs to an object, and performs some operation using that object.

method

In the following line of code, what is the name of the subclass? class Rose(Flower):

rose

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

rstrip

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

rstrip

The procedures that an object performs are called

methods

_________ are small central processing unit chips.

microprocessors

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

rstrip()

A(n) _______ total is a sum of numbers that accumulates with each iteration of the loop

running

A variable is available only to statements in the variable's

scope

A variable's _____ is the part of a program in which the variable may be accessed.

scope

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

scope

The _________ of a variable is the portion of the program that can refer to it.

scope

In _________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.

script

In _______________ mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.

script

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

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

What is the value of the variable phones after the execution of the following code? phones = {'John': '5555555', 'Julie': '7777777'} phones['John'] = '1234567'

{'John': '1234567', 'Julie' : '7777777'}

What is the value of the variable phones after the execution of the following code? phones = {'John': '5555555', 'Julie' : '7777777'} phones['John'] = '1234567'

{'John': '1234567', 'Julie' : '7777777'}

What is the value of the variable phones after the execution of the following code? phones = {'John': '5555555', 'Julie' : '7777777'} phones['John'] = '1234567'

{'John': '1234567', 'Julie' : '7777777'}

What is the output of the following code? phones = {'John': '5555555', 'Julie' : '7777777'} phones['John'] = '1234567' print(phones)

{'John': '1234567', 'Julie': '7777777'}

What is the correct structure for creating a dictionary of month names to be accessed by month numbers?

{1:'January',2:'February',3:'March'}

You can use ______________ to create an empty dictionary.

{}

This operator can be used to find the union of two sets.

|

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

[1, 2, 3]

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]

[1, 2, 3]

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

[1, 2, 3]

What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = list1 (tab) list1 = [4, 5, 6] [1, 2, 3, 4, 5, 6] [1, 2, 3] [4, 5, 6] Error message

[1, 2, 3]

What does the following code display? values = [2] * 5 print (values)

[2, 2, 2, 2, 2]

What is the output of the following code? x=[2] y=[7] z=x+y print(z)

[2, 7]

What will the following code display? values = [ 2, 4, 6, 8, 10] print ( values [1:3] )

[4, 6]

What will the following code display? values = [2, 4, 6, 8, 10] print(values[1:3]) [4, 6, 8] [4, 6] [2, 4, 6] [2, 4, 6, 8]

[4, 6]

What will the following code print? list1 = [40, 50, 60 ] list2 = [ 10, 20, 30 ] list3 = list1 + list2 print (list3)

[40, 50, 60, 10, 20, 30].

What does the following code display? Treat -4 as a positive. numbers = [ 1, 2, 3, 4, 5, 6, 7, 8 ] print (numbers [-4 :] )

[5, 6, 7, 8]

What will the following code display? numbers = [1, 2, 3, 4, 5, 6, 7] print(numbers[4:8]) [4, 5, 6, 7, 8] [5, 6, 7, 8] [5, 6, 7] [1, 2, 3, 4, 5, 6, 7] Error message, because the list does not have an index 8

[5, 6, 7]

What does the following code display? numbers = [1, 2, 3, 4, 5, 6, 7 ] print (numbers [4 : 6] )

[5, 6]

What does the following code display? numbers = [ 1, 2, 3, 4, 5, 6, 7 ] print ( numbers [5 :] )

[6, 7]

What is the output of the following code? list1=[6,4,65,7,12] print(list1[-2:])

[7, 12]

What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = list1 list1[0] = 99

[99, 2, 3]

The line continuation character is a

\

The line continuation character is a _____.

\

How to add a new line?

\n

How to add a tab space?

\t

This operator can be used to find the symmetric difference of two sets.

^

This operator can be used to find the symmetric difference of two sets. a. I b. & c. - d. ^

^

The __________ method is automatically called when an object is created

__init__

Which method is automatically executed when an instance of a class is created in memory? __state__ __obj__ __str__ __init__

__init__

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

__init__

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

__str__

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

__str__

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

__str__

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

__str__

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

_str_

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

_str_

The approach known as __________ makes a program easier to understand, test and maintain

modularization

Functions that are in the standard library are stored in files that are known as

modules

The % symbol is the remainder operator, also known as the __________ operator.

modulus

Which of the following would you use if an element is to be removed from a specific index? an index method a slice method a remove method a del statement

a del statement

Given that the file is valid and contains numbers, what does x contain after the following statement?

a file object

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

a function

A value-returning function is

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

A value-returning function is _____.

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

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

a header

In Python, variable names may begin with ____________

a letter, an underscore

What symbol is used to mark the beginning and end of a string?

a quote mark (")

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

a reference to the object

A(n) _________ method stores a value in a data attribute or changes its value in some other way

mutator

This method stores a value in a data attribute or changes the value of a data attribute

mutator

Which of the following will get a floating-point number from the user?

my_number = float(input("Enter a number:"))

Look at the following statement: mystring= ' cookies>milk>fudge>cake>ice cream ' Write a statement that splits this string, creating the following list: [ 'cookies' , 'milk' , 'fudge' , 'cake' , 'ice cream' ]

mylist = mystring.split('>')

Which of the following statements would you use to as the string 'Labrador' to the list at index 0?

mylist.append('Labrador')

variable

name that refers to a value

In a function definition, the parameters without default values must _________ the parameters with default values.

precede

The while loop is a _________________ type of loop.

pretest

The while loop is known as a(n) _______ loop because it tests the condition before performing an iteration.

pretest

The first input operation is called the _____, and its purpose is to get the first input value that will be tested by the validation loop.

priming read

The first operation is called the ________ and its purpose is to get the first input value that will be tested by the validation loop.

priming read

The first operation is called the __________ and its purpose is to get the first input value that will be tested by the validation loop.

priming read

Which of the following will display 20%?

print(format(0.2, '.0%')) <enter>

Given the following list, which statement will print out the character h? list1=[['ab','cd'],['ef','gh'],['ij','kl']]

print(list1[1][1][1])

Assume mystring references a string. Write a statement that uses a slicing expression and displays the first 3 characters in the string.

print(mystring[:3])

A(n) _____ is a set of real-world objects, parties, and major events related to the problem

problem domain

The 'P' in the acronym IPO refers to

processing

A sequence of instructions is called a(n) _______________ .

program

A(n) ________ is a set of instructions that a computer follows to perform a task. Also known as software.

program

A(n) _______________ is a set of instructions that a computer follows to perform a task.

program

A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

repetition

In one approach to identifying a class's data attributes and methods, the programmer identifies the class's ________

responsibilities

_________ is a type of memory that can hold data for long periods of time, even when there is no power to the computer.

secondary storage

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

secound

When a method is called, what does Python make to reference the specific object on which the method is supposed to operate?

self parameter

When a method is called, what does Python make to reference the specific object on which the method is supposed to operate? a. state variable b. self parameter c. object data d. init procedure

self parameter

A(n) ________ is a special value that marks the end of a sequence of items

sentinel

A(n) _______________ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.

sentinel

What is a Sentinel?

sentinel value is a special value that is used to terminate a loop.

A(n) _____ is an object that holds multiple items of data.

sequence

a______is an object that holds multiple unique items of data in an unordered manner

sequence

When working with this type of file, you access its data from the beginning of the file to the end of the file.

sequential access

A ______ contains a collection of unique values and works like a mathematical set.

set

Mutator methods are also known as

setters

Mutator methods are also known as setters attributes instances getters

setters

What is another name for the mutator methods?

setters

The process of calling a function requires _____.

several actions to be performed by the computer

When an object is passed as an argument, ________________ is passed into the parameter variable. a copy of that object Objects cannot be passed as arguments a reference to the object's state a reference to the object

a reference to the object

Select all that apply. To create a Python program you can use

a text editor, IDLE

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

a try/except statement

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

a try/except statement

argument

a value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.

Look at the following statement: numbers = [ 10, 20, 30, 40, 50] a. How man elements does the list have? b. What is the index of the first element in the list? c. What is the index of the last element in the list?

a. 5 b. 0 c. 4

Look at the following function definition: def my_function (a, b, c) : d = (a + c) / b print (a, b) a. Write a statement that calls this function and uses keyboard arguments to pass 2 into a, 4 into b, and 6 into c. b. What value will be displayed when the function call executes?

a. my_function(a=2, b=4, c=6) b. 2

Write a statement that creates an empty dictionary

aDict = {}

What does the following code display? mystr = 'abc' * 3 print (mystr)

abcabcabc

What is the value that will be printed to the screen after the execution of the following code? string = 'abcd' string.upper() print(string)

abcd

A(n) ________ method gets the value of a data attribute but does not change it

accessor

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?

accessor

What type of methods 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? mutator setter accessor class

accessor

A variable used to keep a running total is called a(n)

accumulator

The variable used to keep the running total is called a(n) ________.

accumulator

The arguments in a function call are called _________ parameters.

actual

You can add one element to a set with this method.

add

You can add one element to a set with this method. a. append b. add c. update d. merge

add

A comma in the print statement notifies Python to:

add a space after a string rather than begin a new line.

A set of well-defined logical steps that must be taken to perform a task

algorithm

A good reason to include documentation in your program is ____________.

all of the above

The sorted function can be used with _________.

all of the above

Write nested decision structures that perform the following: If amount1 is greater than 10 and amount2 is less than 100, display the greater of amount1 and amount2.

amount1 = input('Enter amount1:') amount2 = input('Enter amount2:') if amount1 > 10 and amount2 < 100: if amount1>amount2: print('amount1 is greater') elif amount2>amount1: print('amount2 is greater') else: print('Amounts not in valid range')

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?

an object

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 module an instance an object a class

an object

A compound Boolean expression created with the ___________ operator is TRUE only if both of its subexpressions are TRUE.

and

A compound Boolean expression created with the _______________ operator is true only if both of its subexpressions are true.

and

Compound Boolean expression created with the ______ operator is true only if both of its subexpressions are true.

and

When using the __ operator, both subexpressions must be true for the compound expression to be true.

and

When using the _____ operator, both subexpressions must be true for the compound expression to be true.

and

When using the __________ logical operator, both subexpressions must be true for the compound expression to be true.

and

An if-elif-else statement can contain ____________ clauses.

any number of

In the split method, if no separator is specified, the default is ____________.

any whitespace character

Who is your customer?

anyone who asks you to write a program as part of your job

When a file is opened in this mode, data will be written at the end of the file's existing contents.

append mode

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

argument

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

argument

In a function call, the items inside parentheses are called _________.

arguments

Which computer language uses short words known as mnemonics for writing programs?

assembly

A statement of the form variableName = numericExpression is called a(n) ____________.

assignment statement

What does a subclass inherit from a superclass?

attributes and methods

This is a small holding section in memory that many systems write data to before writing the data to a file.

buffer

An error is a program is called a(n) _______________.

bug

Which list will be referenced by the variable number after the execution of the following code? 0 , 9 , 2

by the variable number after the execution of the following code? [0, 2, 4, 6, 8]

If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____.

calls itself to solve the smaller problem

If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____. a. exits b. returns to the main function c. returns to the calling function d. calls itself to solve the smaller problem

calls itself to solve the smaller problem

What will the following code display? mystring = 'abcdefg' print (mystring [2:5] )

cde

The Python turtle is initially positioned in the __________ of a graphics window and it first appears, by default, to be heading __________.

center, east

Which is the first line needed when creating a class name Worker? def worker_pay(self): class Worker import random def __init__(self):

class Worker

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

class Worker:

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

class Worker:

Which of the following is the correct syntax for defining a class dining which inherits from class furniture?

class dining(furniture):

Writing Python statements is called _______________.

coding

________ are notes of explanation that document lines or sections of a program.

comments

_______________ are notes of explanation that document lines or sections of a program.

comments

A program that translates a high-level language program into a separate machine language program

compiler

A(n) _________ expression is made up of two or more Boolean expressions.

compound

A(n) _______________ expression is made up of two or more Boolean expressions.

compound

Multiple Boolean expressions can be combined by using a logical operator to create _____ expressions.

compound

Multiple Boolean expressions can be combined by using a logical operator to create __________ expressions.

compound

Combining two strings to form a new string is called ____________.

concatenation

When the + operator is used with two strings, it performs string

concatenation

A(n) ________-controlled loop causes a statement or set of statements to repeat as long as the condition is true.

condition

What type of loop structure repeats the code based on the value of Boolean expression?

condition-controlled loop

Which of the following requires that a condition be tested within the loop to determine whether the loop should continue?

conditional iteration

In a decision structure, the action is _________ executed because it is performed only when a specific condition is true.

conditionally

In a decision structure, the action is _______________ executed because it is performed only when a certain condition is true.

conditionally

A _________ is a name that represents a value the cannot be changed during a program's execution.

constant

string

contains a string of letters

The ____________ statement causes the current iteration of the body of a loop to terminate and execution returns to the loop s header.

continue

The ____________ statement causes the current iteration of the body of a loop to terminate and execution returns to the loop's header.

continue

A(n) _____ structure is a logical design that controls the order in which a set of statements execute.

control

A(n) __________ structure is a logical design that controls the order in which a set of statements execute.

control

str

converts to a string

What type of loop structure repeats the code a specific number of times?

count-controlled loop

Write a loop that counts the number of digits that appear in the string referenced by mystring.

counter = 0 for ch in mystring: if ch.isdigit(): counter +=1 print ('The number of digits is', counter)

What will be displayed after the following code is executed? count = 4 while count < 12: print("counting") count = count + 2

counting counting counting counting

What will be displayed after the following code is executed? count = 4 while count < 12: print("counting") count = count + 2

counting counting counting counting

The _______________ is the part of a computer that actually runs programs and is the most important component in a computer.

cpu

Given a class named Customer, which of the following creates a Customer object and assigns it to the variable named cust1:

cust1 = Customer()

Assume 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?

customer.write('Mary Smith')

Assume that there is a variable named customer that references a file object. How would you write the string 'Mary Smith' to the file?

customer.write('Mary Smith')

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?

customer.write('Mary Smith')

Given 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?

customer.write('Mary Smith')

You use ____ to delete an element from a dictionary. a. the remove method b. the erase method c. the delete method d. the del statement

d. the del statement

A(n) _______ is a component of a class that references data

data attribute

Python uses _______________ to categorize values in memory.

data types

The function header begins with the keyword _______ and is followed by the name of the function

def

Consider the following code: class Rectangle: def __init__(self, height, width): self.height = height self.width = width def getPerimeter(self): perimeter = self.height * 2 + self.width * 2 return perimeter def getArea(self): area = self.height * self.width return area def getStr(self): return str(self.height) + " by " + str(self.width) Which of the following adds an attribute named color to the class?

def __init__(self, height, width): self.height = height self.width = width self.color = "red"

Consider the following code: class Product: def __init__(self, name="", price=0.0): self.name = name self.price = price def getDescription(self): return self.name class Book(Product): def __init__(self, name="", price=0.0, author=""): Product.__init__(self, name, price) self.author = author def getDescription(self): return Product.getDescription(self) + " by " + self.author class Movie(Product): def __init__(self, name="", price=0.0, year=0): Product.__init__(self, name, price) self.year = year def getDescription(self): return Product.getDescription(self) + " (" + str(self.year) + ")" If a class named App inherits the Product class, you can add an attribute named version by coding the constructor for the App class like this:

def __init__(self, name="", price=0.0, version="1.0"): Product.__init__(self, name, price) self.version = version

Consider the following code: class Product: def __init__(self, name="", price=0.0): self.name = name self.price = price def getDescription(self): return self.name class Book(Product): def __init__(self, name="", price=0.0, author=""): Product.__init__(self, name, price) self.author = author def getDescription(self): return Product.getDescription(self) + " by " + self.author class Movie(Product): def __init__(self, name="", price=0.0, year=0): Product.__init__(self, name, price) self.year = year def getDescription(self): return Product.getDescription(self) + " (" + str(self.year) + ")" To allow the print function to automatically convert a Product object to a user-friendly string, you can add this method to the Product class:

def __str__(self): return self.name

Write a function that accepts a string as an argument and returns true if the argument ends with the substring ' .com ' . Otherwise, the function should return false.

def com_check(mystring): if mystring.endswith('.com'): return True return False

Fizz buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz". If the number is divisible by both three and five then they say "fizzbuzz".

def fizz_buzz(input): if(input % 3 == 0) and (input % 5 == 0) return "FizzBuzz" if input % 3 == 0: return "Fizz" if input % 5 == 0: return "Buzz" return input print (fizz_buzz(3))

The following statement calls a function named half, which returns a value that is half that of the argumenr. (Assume the number variable references a float value.) Write code for the function. result = half (number)

def half(value): return value / 2.0

The code for a function is known as a function

definition

Which statement could you use to remove an existing key-value pair from a dictionary?

del

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

del

Which would you use to delete an existing key-value pair from a dictionary

del

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

del

Given a list, what would you use if an item is to be removed from a specific index number?

del function

What would you use if an element is to be removed from a specific index?

del statement

This method is called to destroy the root widget's main window

destroy()

In a GUI environment, most interactions are done through small windows known as _____ that display information and allow the user to perform actions.

dialog boxes

In flowcharting, the _________ symbol is used to represent a Boolean expression.

diamond

In flowcharting, the _______________ symbol is used to represent a Boolean expression.

diamond

Write a statement that creates a dictionary containing the following key-value pairs: 'a' : 1 'b' : 2 'c' : 3

dict = {'a':1, 'b':2, 'c':3}

A ______ is an object that stores a collection of data. Each element in a dictionary has two parts: a key and a value. You use a key to locate a specific value.

dictionary

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

dictionary is not indexed by number

each elent in a____has two parts: a key and a value

dictonary

In Python, a __________ is an object that stores a collection of data. Each element of this object has two parts: a key and a value.

dictoniary

This set method removes an element but does not raise an exception if the element is not found. a. remove b. discard c. delete d. erase

discard

This set method removes an element but does not raise an exception if the element is not found.

discard

Label widgets can be used to

display texts and images in one line

Functions that do not return values _________.

do not have return statements

To refer to a function in a module, Python uses _______ notation

dot

The decision structure that has two possible paths of execution is known as

dual alternative

The decision structure that has two possible paths of execution is known as _____.

dual alternative

What is the output of the following code? list1=['h','e','l','l','o'] list1.sort() print(list1[0])

e

In Python, string literals are surrounded by

either a or b

What are the data items in a list called?

elements

What are the data items in a list called? values data items elements

elements

What are the data items in the list called?

elements

What are thee data items in a list calleed

elements

When an if-else statement needs to allow for more than two possible alternatives, you use a(n) ____________ clause.

elif

Combining data and code in a single object is known as modularity objectification instantiation encapsulation

encapsulation

In a print statement, you can set the _____ argument to a space or empty string to stop the output from advancing to a new line.

end

In a print statement, you can set the ________ argument to a space or empty string to stop the output from advancing to a new line.

end

In a print statement, you can set the __________ argument to a space or empty string to stop the output from advancing to a new line.

end

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

endswith(substring)

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

endswith(substring)

A(n) _________ character is a special character that is preceded with a backslash (\), appearing inside a string literal.

escape

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

executed

When a function is called by its name, then it is _____.

executed

A combination of numbers, arithmetic operators, and parentheses that can be evaluated is called a numeric ____________.

expression

A local variable can be accessed from anywhere in the program.

false

According to the behavior of integer division, when an integer is divided by an integer, the result will be a float.

false

All instances of a class share the same values of the data attributes in the class.

false

Comments in Python begin with the // character

false

In a UML diagram the first section holds the list of the class's methods.

false

In python, there is nothing that can be donee if the program tries to access a file to read that does not exist

false

In the program development cycle, the first step in writing instructions to carry out a task is to determine how to process the input to obtain the desired output.

false

Python allows the programmer to work with text and number files

false

Python uses the same symbols for the assignment operator as for the equality operator.

false

Sets are created using curly braces { }.

false

Short -circuit evaluation is only performed with the not operator.

false

The elements in a dictionary are stored in ascending order, by the keys of the key-value pairs.

false

The else part of an if statement cannot be omitted.

false

The index of the first element in a list is 1, the index of the second element is 2, and so forth.

false

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y and z > x

false

What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? x < y and z > x

false

What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8? not (x < y or z > x) and y < z

false

When a class inherits another class, it is required to use all the data attributes and methods of the superclass.

false

When a piece of data is read from a file, it is copied from the file into the program

false

The process known as the _____ cycle is used by the CPU to execute instructions in a program.

fetch-decode-execute

The process known as the __________ cycle is used by the CPU to execute instructions in a program.

fetch-decode-execute

A single piece of data within a record is called a

field

This is a single piece of data within a record.

field

The total number of data characters and additional spaces for a given datum in a formatted string is called which of the following?

field width

When a program needs to save data for later use, it writes the data in a(n)

file

The and operator has

higher precedence than the or operator, but lower precedence than the not operator

When Python stops evaluating a compound condition with the logical and operator because a condition evaluates to False, it is called ____________evaluation.

short-circuit

Examine the following function header, then write a statement that calls the function, passing 12 as an argument. def show_value (quantity) :

show_value(12)

If two variables with the same name are created in two different functions _________.

they have no relationship to each other.

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

third section

In Python, what module is used to create a GUI program?

tkinter

You can use this module in Python to create a GUI programs

tkinter

A program contains the following function definition: def cube (num) : return num * num * num Write a statement that passes the value 4 to this function and assigns its return value to the variable result.

result = cube(4)

A function is said to _________ its output.

return

A value-returning function has a(n) ________ statement that sends a value back to the part of the program that called it.

return

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

return

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.

return

what is the string Modification method upper()?

returns a copy of the string with all alphabetic letters converted to UPPERCASE .

what is the string Modification method strip(char)?

returns a copy of the string with all instances of char that appear at the beginning and the end of the string removed.

what is the string Modification method strip()?

returns a copy of the string with all leading and trailing whitespaces characters removed.

What is the ReadLines() library in a python program?

returns a list containing all the lines in the file.

Object-oriented programming allows us to hide the object's data attributes from code that is outside the object.

true

Python allows you to pass multiple arguments to a function.

true

Strings can be written directly to a file with the WRITE method, but the numbers must be converted to strings before they can be written.

true

The ZeroDivisionError exception is raised when the program attempts to perform the calculation x/y if y = 0

true

The if statement causes one or more statements to execute only when a Boolean expression is true.

true

The self parameter is required in every method of a class.

true

What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x

true

What is the result of the following Boolean expression, if x equals 5, y equals 3, and z equals 8?

true

closing a file disconnects the communication between the file and the program

true

if the last line in a file is not terminated with \n, the deadline method will return the line without the \n

true

A Boolean variable can reference one of two values which are

true or false

A Boolean variable can reference one of two values: _____

true or false

Boolean variable can reference one of two values: _____.

true or false

The ________________ is one or more statements grouped together with the anticipation that they could potentially raise an exception.

try block

To respond to errors, what kind of a statement must be used?

try/except

What statement can be used to handle some of the run-time errors in a program?

try/except statement

The items method of a dictionary returns what type of value?

tuple

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

tuple

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

tuple

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

tuple

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

tuple

How many types of files are there

two

The encoding technique used to store negative numbers in the computer's memory is called

two's complement

The encoding technique used to store negative numbers in the computer's memory is called _____.

two's complement

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

identify the classes needed

In object-oriented programming, one of the first tasks of the programmer is to list the nouns in the problem identify the objects needed list the methods that are needed identify the classes needed

identify the classes needed

The _______ statement is used to create a decision structure.

if

You use a(n) ____________ statement to write a single alternative decision structure.

if

You use an ____ statement to write a single alternative decision structure.

if

Assume the variable dct references a dictionary. Write an if statement that determines whether the key "James" exists in the dictionary. If so, display the value that is associated with that key. If the key is not in the dictionary, display a message indicating so.

if "James" in dct: print(dct["James"]) else: print("James Not found")

Which of the following is the correct if clause to determine whether choice is anything other than 10?

if choice != 10:

Which of the following is the correct if clause to use to determine whether choice is other than 10?

if choice != 10:

Which of the following is the correct if clause to use to determine whether is other than 10? a. if choice != 10 b. if choice != 10 c. if choice <> 10: d. if choice <> 10

if choice != 10:

Assume choice references a string. The following if statement determines whether choice is equal to 'Y' or 'y': if choice == 'Y' or choice == 'y' : Rewrite this statement so it only makes one comparison, and does not use the or operator. (Hint: use either the upper or lower methods. )

if choice.upper() == 'Y'

Python provides a special version of a decision structure known as the _______________ statement, which makes the logic of the nested decision structure simpler to write

if elif else

Which of the following will hide the turtle if it is visible?

if turtle.isvisible(): turtle.hideturtle()

Which of the following is the correct if clause to determine whether y is in the range 10 through 50?

if y >= 10 and y <= 50

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive?

if y >= 10 and y <= 50:

In a menu-driven program, what statement is used to determine and carry out the user's desired action?

if-elif-else

Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested decision structure simpler to write.

if-elif-else

A(n) _________ statement will execute one block of statements if its condition is true or another block if its condition is false.

if-else

You use an _____ statement to write a dual alternative decision structure.

if-else

A(n) _______________ statement will execute one block of statements if its condition is true, or another block if its condition is false.

if/else

tuples are ___ sequences which means that once a tuple is created it cannot be changed

immutable

The key word used to implement a predefined module in a class is called __________

import

To gain access to the functions and variables of a library module, use a(n) _________ statement.

import

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

import matplotlib.pyplot

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

import random

Write a statement that generates a random number in the range of 1 through 100 and assigns it to a variable named rand.

import random rand = random.randint(1, 100)

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

in

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

in

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

in

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

in

In order to avoid a KeyError exception, you can check whether a key is in the dictionary using the ______________ operator isin in included isnotin

in

The __________ operator can be used to determine whether one string is contained in another string.

in

This operator determines whether one string is contained inside another string.

in

You can use the ____ operator to determine whether a key exists in a dictionary. a. & b. in c. ^ d. ?

in

You can use the ____operator to determine whether a key exist in a dictionary

in

comment

in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program

Where does a computer store a program and the data that the program is working with while the program is running?

in main memory

Each character in a string has a(n) __________ which specifies its position in the string.

index

Function A calls function B, which calls function C, which calls function A. This is called _____ recursion.

indirect

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

infield = open('users.txt', 'r')

Write a code to read from a .txt File

infile = open("2313finalNumbers.txt") num = infile.readline() num = int(num) type(num)

What is the encoding technique called that is used to store negative numbers in the computer's memory?

two's complement

An object s identifies the kind of information contained in the object.

type

Write a program that opens the my_name.txt file(that you just created), reads your name from the file, displays the name on the screen, and then closes the file.

infile = open("my_name.txt", "r") name = infile.read() infile.close() print(name)

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

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

A variable created inside a function is called a _________ variable.

local

A(n) _____ variable is created inside a function.

local

Function parameters have _________ scope.

local

What is the output of the following command, given that value1 = 2.0 and value2 = 12? print(value1 * value2)

24.0

What is the output of the following command, given that value1 = 2.0 and value2 = 12? print(value1 * value2)

24.0

What is the output of the following command, given that value1 = 2.0 and value2 = 12? print(value1 * value2)

24.0

The remainder of an integer division is accomplished using the ____________ operator.

%

This operator can be used to find the intersection of two sets.

&

This operator can be used to find the intersection of two sets. a. I b. & c. - d. ^

&

In Python the __________ symbol is used as the not-equal-to operator.

!=

In Python, the _____ symbol is used as the not-equal-to operator.

!=

"Tkinter" is also known as

"Tk Interface"

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

"w" write write mode 'w' w

write a statement that displays your name

# This program displays a person's # name and Python's the best! print ('DiMarcus Clay') print ('Python's the best!') print ('The cat said "meow." ')

Which mathematical operator is used to raise 5 to the second power in Python?

**

Which mathematical operator is used to raise five to the second power in Python?

**

Which mathematical operator is used to raise five to the second power in python

**

Which mathematical operator is used to raise 5 to the second power in Python?

** =

What method or operator can be used to concatenate lists?

+

Which method or operator can be used to concatenate lists?

+

Which method or operator can be used to concatenate lists? concat + * %

+

Which method or operator can bee used to concatenate lists

+

This operator can be used to find the difference of two sets.

-

This operator can be used to find the difference of two sets. a. I b. & c. - d. ^

-

Select all that apply. Which of the following are steps in the program development cycle? Question 1 options: write the code and correct syntax errors correct logic errors test the program design the program

- correct logic errors - write the code and correct syntax errors - test the program - design the program

Given str1 = Life, the universe and everything. what does str1.find( rev ) return?

-1

What is the first negative index in a list

-1

What is the first negative index in a list?

-1

What is the first negative index in a string?

-1

Evaluate the python expression. 12.0 // (10 - 6) * -2

-6.0

5 - 8 * 2 - (-3)

-8

In Python, a module's file name should end in

.py

Integer division is accomplished using the ____________ operator.

//

The first index in a string

0

What is the first Index in a list?

0

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

0 through 7

What are the valid indexes for the string 'New York'? 0 through 8 0 through 7 -1 through -8 -1 through 6

0 through 7

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

0 through 7

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

0 through 7 and -1 through -8

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

0, 1, 2, 3

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4)

0, 1, 2, 3

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4):

0, 1, 2, 3

What are the values that the variable num contains through the iterations of the following for loop? for num in range(4):

0, 1, 2, 3

What will be assigned to the string variable even after the execution of the following code? special = '0123456789' even = special[0:10:2]

02468

What is the output of the following code? myList=['a','b','c','d','e'] z = 1 for x in range(5): word=myList[x] print(str(z),word,end="") z+=1

1 a2 b3 c4 d5 e

Evaluate the python expression. 4 / 5 * 2

1.6

Evaluate the python expression. 7 + 9 // 2

11

Evaluate the python expression. 5 % 8 * 2 - (-2)

12

Binary table to perform binary problems:

128 - 64 - 32 - 16 - 8 - 4 - 2 - 1

Given str1 = Life, the universe and everything. what does str1.find( ve ) return?

13

In the string literal Life, the universe and everything. the substring verse begins at position _____ and ends at position_____.

13, 17

What will the following program display? def main () : x = 1 y = 3.4 print ( x, y) change_us (x, y) print (x, y) def change_us (a, b) : a = 0 b = 0 print (a, b) main()

13.4 00 13.4

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

1357

Evaluate the python expression. 12 + 22 % 4

14

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 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer)

14

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 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer)

14

What is the decimal value of the following binary number? 10011101

157

What is the decimal value of the following binary number? 10011101

157

At the end of the following program, how many elements would the dictionary, names, contain? names={'Smith':'Bob','Jones':'Emily'} names['Smith']='George' print(names)

2

Evaluate the python expression. (16 + 7) % 4 - 1

2

Evaluate the python expression. 9 // 4

2

What is the output of the following code? count=0 list1=[0]*2 for item in list1: if item==0: count+=1 print(count)

2

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2)

2, 4, 6, 8

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2):

2, 4, 6, 8

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2,9,2)

2, 4, 6, 8

What are the values that the variable num contains through the iterations of the following for loop? for num in range(2, 9, 2):

2, 4, 6, 8

Evaluate the python expression. 9 / 4

2.25

Given str1 = Life, the universe and everything. what does str1.rfind( ve ) return?

24

What is the output of the following command, given that value1 = 2.0 and value2 = 12? print(value1 * value2)

24

If value1 is 2.0 and value2 is 12, what is the output of the following command? print(value1 * value2)

24.0

If value1 is 2.0 and value2 is 12. print(value1 * value2)

24.0

Look at the following function header: def my_function (a, b, c) : Now look at the following call to my_function: my_function (3, 2, 1) When this call executes, what value will be assigned to a? What value will be assigned to b? What value will be assigned to c?

3 will be assigned to a, 2 will be assigned to b, and 1 will be assigned to c.

Evaluate the python expression. 4 % 5 / 2.0 + 1.5

3.5

What will be displayed after the following code is executed? for num in range(0, 20, 5): num += num print(num)

30

What will be displayed after the following code is executed? for num in range(0, 20, 5): num += num print(num)

30

Evaluate the python expression. 4 * 11.5 / 2 + 16

39.0

Consider the following code: def get_volume(width, height, length=2): volume = width * height * length return volume def main(): l = 3 w = 4 h = 5 v = get_volume(l, w, h) print(v) main() What value is passed to the height argument by the call to the get_volume() function?

4

Evaluate the python expression. 9 // 2

4

What will be displayed after the following code is executed? total = 0 for count in range(4,6): total += count print(total)

4 9

What will be displayed after the following code is executed? total = 0 for count in range(4,6): total += count print(total)

4 9

Evaluate the python expression. 9 / 2

4.5

What is the output of the following code? person=["Jane",485,329] print(person[1])

485

Which would you use to delete an existing key-value pair from a dictionary? a. del b. remove c. delete d. unpair

A

Evaluate the python expression. 25 % 5 + 12.5 * 2 // 5

5.0

Evaluate the python expression. 4.2 / 2 * 3 - 1

5.3

What will this loop display? sum = 0 for i in range(0, 25, 5): sum += i print(sum)

50

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)

6

What will be displayed after the following code is executed? total = 0 for count in range(1,4): total += count print(total)

6

Consider the following code: def get_volume(width, height, length=2): volume = width * height * length return volume def main(): l = 3 w = 4 h = 5 v = get_volume(l, w, h) print(v) main() When this program runs, what does it print to the console?

60

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

64

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

64

After the execution of the following statement the variable PRICE will reference the value ______. price = int(68.549)

68

After the execution of the following statement, the variable price will reference the value _____. price = int(68.549)

68

After the execution of the following statement, the variable price will reference the value _____. price = int(68.549)

68

After the execution of the following statement, the variable price will reference the value ________.

68

After the execution of the following statement, the variable price will reference the value __________. price = int(68.549)

68

After the execution of the following statement, the variable price will reference the value __________. price = int(68.549)

68

After the execution of the following statement, the variable price will reference the value __________. price = int(68.549)

68

Evaluate the python expression. 4.2 + 7 // 2

7.2

When applying the .3f formatting specifier to the number 76.15854, the result is _______

76.159

When applying the .3f formatting specifier to the number 76.15854, the result is __________

76.159

What is the output of the following code? height=[72, 84, 67, 74] print(max(height))

84

A function header must end with a(n) _________.

:

What is NOT an example of an augmented assignment operator?

<=

What is not an example of an augmented assignment operator?

<=

Which of the following is not an augmented assignment operator?

<=

Which of the following is not an augmented assignment operator? /= += <= *=

<=

In Python the _____ symbol is used as the equality operator.

==

In Python the __________ symbol is used as the equal operator.

==

In python the __ symbol is used as the equality operator.

==

Base classes are also called a. superclasses b. derived classes c. subclasses d. class instances

A

In a UML diagram, what does the open arrowhead point to? a. the superclass b. the subclass c. the object d. a method

A

In the following line of code, what is the name of the subclass? class Rose(Flower): a. Rose b. Flower c. Rose(Flower) d. None of these

A

Mutator methods are also known as a. setters b. getters c. instances d. attributes

A

Of the two classes, Cherry and Flavor, which would most likely be the subclass? a. Cherry b. Flavor c. either one d. neither; these are inappropriate class or subclass names

A

The procedures that an object performs are called a. methods b. actions c. modules d. instances

A

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

A

What does the acronym UML stand for? a. Unified Modeling Language b. United Modeling Language c. Unified Model Language d. Union of Modeling Languages

A

What gives a program the ability to call the correct method depending on the type of object that is used to call it? a. Polymorphism b. Inheritance c. Encapsulation d. Methods

A

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

A

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

A

What will be assigned to the string variable pattern after the following code executes? i = 3 pattern = 'z' * (5 * i) a. 'zzzzzzzzzzzzzzz' b. 'zzzzz' c. 'z * 15' d. Nothing; this code is invalid

A

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'

A

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') 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.

A

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

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

A

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!

A

When there are several classes that have many common data attributes, it is better to write a(n) __________ to hold all the general data. a. superclass b. subclass c. object d. method

A

Which attributes belong to a specific instance of a class? a. instance b. self c. object d. data

A

Which method can you use to determine whether an object is an instance of a class? a. isinstance b. isclass c. isobject d. issubclass

A

Which method could be used to convert a numeric value to a string? a. str b. value c. num d. chr

A

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)

A

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'

A

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.

A

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

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

A

dictionary

A collection of key/value pairs that maps from keys to values.

sequence

A data type that is made up of elements organized linearly, with each element accessed by an integer index.

module

A file containing definitions and statements intended to be imported by other programs.

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)

B

boolean function

A function that returns a Boolean value. The only possible values of the bool type are False and True.

print

A function used in a program or script that causes the Python interpreter to display a value on its output device.

block

A group of consecutive statements with the same indentation.

What is a local variable? What statements are able to access a local variable?

A local variable is a variable that is declared inside a function. It belongs to the function in which it is declared, and only statements in the same function can access it.

file

A named entity, usually stored on a hard drive, floppy disk, or CD-ROM, that contains a stream of characters.

function

A named sequence of statements that performs some useful operation. Functions may or may not take parameters and may or may not produce a result

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

B

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'

B

high-level language

A programming language like Python that is designed to be easy for humans to read and write.

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

B

What is the result of the following statement? x = random.randint(5, 15) * 2

A random integer from 5 to 15, multiplied by 2, assigned to the variable x

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

A reference to the object

algorithm

A set of specific steps for solving a category of problems

local variable

A variable defined inside a function. A local variable can only be used inside its function. Parameters of a function are also a special kind of local variable.

What is referred to as the recursive case?

A way to solve the problem in all other circumstances using recursion

To add a single item to a set, you can use the set ________ method.

Add

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

B

The _____ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer memory.

ASCII

The __________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory.

ASCII

The_____ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer memory.

ASCII

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 they could be changed by the code outside the method?

Accessor

The variable used to keep the running total

Accumulator

The variable used to keep the running total is called a(n) _____.

Accumulator

This will happen if you try to use an index that is out of range for a string

An IndexError exception will occur

Why do programmers use top-down design and structured programming?

All of the above

Python programs can enclose strings in quotes.

All of the above.

What advantage is there to using functions in programming?

All of the above.

This will happen if you try to use an index that is out of range for a list.

An IndexError exception will occur.

semantic error

An error in a program that makes it do something other than what the programmer intended.

syntax error

An error in a program that makes it impossible to parse — and therefore impossible to interpret.

What is the output of the following code? nums={[2,4,6]:'evens',[1,3,5]:'odds'} print(nums[[2,4,6]]) None of these. 'odds' An error is generated in the second line of code. evens odds An error is generated in the first line of code. 'evens'

An error is generated in the first line of code.

runtime error

An error that does not occur until the program has started to execute but that prevents the program from continuing.

boolean expression

An expression that is either true or false.

Which method or operator can be used to concatenate lists? a. * b. + c. % d. concat

B

integer division

An operation that divides one integer by another and yields an integer. Integer division yields only the whole number of times that the numerator is divisible by the denominator and discards any remainder.

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

B

Why do global variables make a program difficult to debug?

Any statement in a program can change the value of a global variable. If you find that the wrong value is being stored in a global variable, you have to track down every statement that accesses it to determine where the bad value is coming from. In a program with thousands of lines of code, this can be difficult.

The ______ method is commonly used to add items to a list.

Append

The list method adds an item to the end of an existing list

Append

Which language from the following list is referred to as a low level language?

Assambly Language

Which computer language uses short words known as mnemonics for writing programs?

Assembly

Which language from the following list is referred to as a low-level language?

Assembly

Which language from the following list is referred to as a low-level language?

Assembly language

Which language is referred to as a low-level language?

Assembly language

What is referred to as the base case?

At least one case in which the problem can be solved without recursion

When a file is first opened successfully, where is the read position indicator?

At the beginning of the file

What does a subclass inherit from a superclass?

Attributes and methods

A(n) __________ access file is also known as a direct access file. a. sequential b. random c. numbered d. text

B

Accessor methods are also known as a. setters b. getters c. instances d. attributes

B

Given the following line of code, in a UML diagram, what would the open arrowhead point to? class Celery(Vegetable): a. Celery b. Vegetable c. class d. Celery(Vegetable)

B

How many types of files are there? a. one b. two c. three d. more than trhee

B

In an inheritance relationship, what is a specialized class called? a. a superclass b. a subclass c. an object d. an instance

B

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

B

In the following line of code, what is the name of the base class? class Python(Course): a. Python b. Course c. Python(Course) d. None of these

B

What are the data items in a list called? a. data b. elements c. items d. values

B

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' }

B

What is the first negative index in a list? a. 0 b. -1 c. -0 d. the size of the list minus 1

B

What is the first negative index in a string? a. 0 b. -1 c. -0 d. the size of the string minus one

B

What is the process of retrieving data from a file called? a. retrieving data b. reading data c. reading input d. getting data

B

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

B

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.

B

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']

B

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.'

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

B

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

B

Which method can be used to convert a list to a tuple? a. append b. tuple c. insert d. list

B

Which method could be used to strip specific characters from the end of a string? a. estrip b. rstrip c. strip d. remove

B

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

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

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 matplotlib import pyplot

C

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.

C

_____ Expression has a value of either true or false.

BOOLEAN

By doing this you can hide a class's attribute from code outside the class

Begin the attribute's name with two underscores

A(n) ___ file contains data that has not been converted to text.

Binary

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.

C

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

Boolean

This is a small "Holding Section" in memory that many systems write data before writing the data to a file.

Buffer

How do you delete an element from a dictionary?

By using the del statement

How do you determine the number of elements that are stored in a dictionary?

By using the len function

A single piece of data within a record is called a a. variable b. delimiter c. field d. data bit

C

Combining data and code in a single object is known as a. modularity b. instantiation c. encapsulation d. objectification

C

Given the following beginning of a class definition for a superclass named clock, how many accessor and mutator methods will be needed to complete the class definition? class clock: def __init__(self, shape, color, price): self._shape = shape self.color = color self.price = price a. 1 mutator, 1 accessor b. 3 mutator, 4 accessor c. 3 mutator, 3 accessor d. 4 mutator, 5 accessor

C

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'}

C

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]

C

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

C

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.

C

When working with multiple sets of data, one would typically use a(n) a. list b. tuple c. nested list d. sequence

C

Which method can be used to add a group of elements to a set? a. add b. addgroup c. update d. addset

C

Which method can be used to place an item at a specific index in a list? a. append b. index c. insert d. add

C

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__

C

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

C

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

C

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)

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

C

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

C

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

C

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

C

Which would you use to get the number of elements in a dictionary? a. size b. length c. len d. sizeof

C

__________ has the ability to define a method in a subclass and then define a method with the same name in a superclass. a. Inheritance b. Encapsulation c. Polymorphism d. the 'is a' relationship

C

One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure. T/F

False

The ________ is the part of the computer that actually runs programs and is the most important component in a computer.

CPU

Which widget will create a rectangular area that can be used to display graphics?

Canvas

Consider the following code: class Product: def __init__(self, name="", price=0.0): self.name = name self.price = price def getDescription(self): return self.name class Book(Product): def __init__(self, name="", price=0.0, author=""): Product.__init__(self, name, price) self.author = author def getDescription(self): return Product.getDescription(self) + " by " + self.author class Movie(Product): def __init__(self, name="", price=0.0, year=0): Product.__init__(self, name, price) self.year = year def getDescription(self): return Product.getDescription(self) + " (" + str(self.year) + ")" What does this code print to the console: def display(product): print(product.getDescription()) book = Book("Catcher in the Rye", 9.99, "J. D. Salinger") display(book)

Catcher in the Rye by J. D. Salinger

Before GUIs became popular, the _______ interface was the most commonly used

Command line

In which type of interface is a prompt displayed that allows the user to enter a command, which is then executed?

Command line

A(n) _____ code that specifies the data attributes and methods for a particular type of object.

Class

Why should a program close a file when it's finished using it?

Closing the file is necessary so subsequent accesses will NOT miss the updates (adds, changes, deletes) You've made to it.

Of the two classes Cola and Soda, which would most likely be the subclass?

Cola

Python is used with the ____________________ (CGI) for programming Web-based applications.

Common Gateway Interface

A(n) ??-controlled loop causes a statement or set of statements to repeat as long as a condition is true.

Condition

What type of loop structure repeats the code based on the value of the Boolean expression

Condition-controlled loop

What type of loop structure repeats the code based on the value of the Boolean expression?

Condition-controlled loop

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

D

Which of the following is the correct if clause to determine whether choice is anything other than 10?

Correct if choice != 10:

What type of loop structure is best at repeating the code a specific number of times?

Count-controlled loop

What type of loop structure repeats the code a specific number of times

Count-controlled loop

What type of loop structure repeats the code a specific number of times?

Count-controlled loop

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

Country Ln.'

In the following line of code, what is the name of the base class? class Python(Course):

Course

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

D

In a dictionary, you use a(n) __________ to locate a specific value. a. datum b. element c. item d. key

D

What does a subclass inherit from a superclass? a. instances and attributes b. objects and methods c. methods and instances d. attributes and methods

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 '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'}

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'}

D

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') main() a. ERROR: cannot have 0 items b. ERROR: cannot have 0 items ERROR: 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.

D

What will be the output after the following code is executed? import matplotlib.pyplot as plt def main(): x_crd = [0, 1 , 2, 3, 4, 5] y_crd = [2, 4, 5, 2] plt.plot(x_crd, y_crd) 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.

D

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

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

D

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]

D

Which method can be used to convert a tuple to a list? a. append b. tuple c. insert d. list

D

Which method is automatically executed when an instance of a class is created in memory? a. __state__ b. __obj__ c. __str__ d. __init__

D

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

D

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.

D

Which of the following is the correct syntax for defining a class, table, which inherits from the furniture class? a. class furniture[table]: b. class table.furniture: c. class furniture(table): d. class table(furniture):

D

__________ allows a new class to inherit members of the class it extends. a. Encapsulation b. Attributes c. Methods d. Inheritance

D

Given that there is a large list and a large dictionary containing the same amount of data, when the programmer attempts to retrieve a particular piece of data from each structure, which of these statements is true?

Data in the dictionary can be retrieved faster than in the list.

What happens when a piece of data is written to a file?

Data is copied from a variable in RAM to a file.

A class _____ is a set of statements that defines a class's methods and data attributes.

Definition

Which of the following is not a microprocessor manufacturing company?

Dell

What is the second step that needs to be taken in order to apply a recursive approach?

Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.

What is the number of the first index in a dictionary

Dictionaries are not indexed by number

What is the number of the first index in a dictionary? 1 0 the size of the dictionary minus one Dictionaries are not indexed by number

Dictionaries are not indexed by number

Each element in a(n) _____ has two parts: a key and a value.

Dictionary

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

Dictionary is not indexed by number.

A _____ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

Dual Alternative Decision

Which of the following is considered to be the world's first General Purpose Programmable Electronic computer?

ENIAC

Which of the following is considered to be the world's first programmable electronic computer

ENIAC

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

ERROR: cannot have 0 items

What is the output of the following code? colors={'red':'angry','blue':'warm'} a,b=colors.popitem() print(a)

Either red or blue could be output.

What are the data items in a list called?

Elements

One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure.

False

What will be thee output after the following code is executed and the user enters 75 and 0 as the first two prompts

Error: cannot have 0 times

A bit that is turned off is represented by the value -1

FALSE

All programs are normally stored in ROM and loaded into RAM as needed for processing.

FALSE

Kim runs a catering business. Write a program that asks Kim her expected sales for each of month (in a quarter) and then calculates her expected sales total for the first quarter.

FOR LOOP: total = 0 for month in range (3): sales = float(input("Enter the sales for the month: ")) total += sales print("The total sales for the quarter are: ", total) WHILE LOOP: total = 0 month = 0 while month < 3: sales = float(input("Enter the sales for the month: ")) total += sales month += 1 print("The total sales for the quarter are: ", total)

(T/F) In Python, there is no way to prevent a program from crashing if it attempts to read a file that does not exist.

False

(T/F) When opening a file in write mode, if a file with the specified name already exists, a warning message is generated.

False

A bit that is turned off is represented by the value -1.

False

A class method does not have to have a self parameter

False

A computer is a single device that performs different types of tasks for its users.

False

A function definition specifies what a function does and causes the function to execute. T/F

False

A hierarchy chart shows all the steps that are taken inside a function. T/F

False

A list can be a dictionary key. T or F

False

A list cannot be passed as an argument to a function

False

A list cannot be passed as an argument to a function (T/F)

False

A local variable can be accessed from anywhere in the program. T/F

False

A mutator method has no control over the way that a class's data attributes are modified. True or False

False

A mutator method has no control over the way that a class's data attributes are modified. (T/F)

False

A program can be made of only one type of control structure. You cannot combine structures.

False

A while loop is called a pretest loop because the condition is tested after the loop has had one iteration.

False

According to the behavior of integer division, when an integer is divided by an integer the result will be a float.

False

All class definitions are stored in the library so that they can be imported into any program (T/F)

False

All instances of a class share the same values of data attributes in the class. True or False

False

All instances of a class share the same values of the data attributes in the class. (T/F)

False

All programs are normally stored in ROM and are loaded into RAM as needed for processing.

False

An object is a stand-alone program but is used by programs that need its service. True or False

False

An object is a stand-alone program but is used by programs that need its service. (T/F)

False

An object is an entity that can be used effectively in many programs

False

Arays, which are allowed by most other programming languages, have more capabilities than Python list structures

False

Arrays, which are allowed by most other programming languages, have more capabilities than Python list structures (T/F)

False

Arrays, which are allowed by most other programming languages, have more capabilities than Python list structures. True or False

False

Assume list1 references a list. After the following statement is executed, list1 and list2 will reference two identical, but separate list in memory: list2 = list1 (T/F)

False

Functions can be called from statements in the body of a loop and loops can be called from within the body of a function.

False

If a file with the specific name already exists when the file is opened and the file is opened in 'w' mode, then an alert will appear on the screen. True of False

False

If a file with the specified name already exists when the file is opened and the file is opened in 'w' mode, then an alert will appear on the screen.

False

In Python there is no restriction on the name of a module file. T/F

False

In Python, an infinite loop usually occurs when the computer accesses an incorrect memory address.

False

In Python, math expressions are always evaluated from left to right, no matter what the operators are.

False

In Python, math expressions are evaluated from left to right, no matter what the operators are.

False

Indexing of a string starts at 1 so the index of the first character is 1, the index of the second characters is 2, and so forth. (T/F)

False

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

Float

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

Float

A ________ is a diagram that graphically depicts the steps that take place in a program.

Flowchart

In Python, you would use the ?? statement to write a count-controlled loop.

For

Before a file can be used by a program, it must be:

Formatted

The Toplevel widget is a container, like a(n) _____, but displays in its own window.

Frame

This widget is a container that can hold other widgets

Frame

The acronym ______ refers to the fact that the computer cannot tell the difference between good data and bad data.

GIGO

In which environment can a user determine the order in which things happen?

GUI

These types of programs are event driven

GUI

What types of programs are event-driven?

GUI programs

What is the value of the variable string after the execution of the following code? string = 'Hello' string += ' world'

Hello world

In the following line of code, what is the name of the base class? class Male(Human):

Human

In the following line of code, what is the name of the base class? class Male(Human):

Human

This operator can be used to find the union of two sets. a. I b. & c. - d. ^

I

The output of the following print statement is: print('I\'m ready to begin')

I'm ready to begin

What is the output of the following print statement? print('I\'m ready to begin')

I'm ready to begin

What is the output of the following print statement? print 'I\'m ready to begin'

I'm ready to begin

What is the output of the following print statement? print 'I\'m ready to begin'

I'm ready to begin

________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.

Input validation

__________ is the process of inspecting data that has been input into a program in order to ensure that the data is valid before it is used in a computation.

Input validation

Each character in a string has a(n) ___ which specifies its position in he string.

Index

What concept involves a superclass and a subclass?

Inheritance

_____ allows a new class to inherit the members of the class it extends.

Inheritance

A(n) ?? validation loop is sometimes called an error trap or an error handler.

Input

What part of the computer collects data from people and from other devices?

Input

A file that data is written to, is known as a(n):

Input File

This marks the location of the next item that will be read from a file.

Input Position

_____ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

Input validation

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!')

Invalid, must contain one number

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

Invalid, must contain one number

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!')

Invalid, must contain one number

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!')

Invalid, must contain one number.

What is the relationship called in which one object is a specialized version of another object?

Is a

what is the string Testing method islower()?

Is true if all of the alphabetic letters in the string are lower case, otherwise is false.

what is the string Testing method isupper()?

Is true if all of the alphabetic letters in the string are uppercase, is false otherwise.

what is the string Testing method isspace()?

Is true if the string contains only whitespace characters, false otherwise. (Whitespace characters are spaces, newlines(\n), and tabs(\t).

What does the following program do? student = 1 while student <= 3: total = 0 for score in range(1, 4): score = int(input("Enter test score: ")) total += score average = total/3 print("Student ", student, "average: ", average) student += 1

It accepts 3 test scores for each of 3 students and outputs the average for each student.

What does the following program do? import turtle def 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() main()

It draws 2 blue lines.

What does the get method do if thee specified key is not found in the dictionary

It returns a default value

What does the items method return?

It returns all a dictionary's keys and their associated values as a sequence of tuples.

What does the keys method return?

It returns all the 'keys' in a dictionary as a sequence of tuples.

What does the values method return?

It returns all the 'values' in the dictionary as a sequence of tuples.

Select all that apply. Assume you are writing a program that calculates a user's total order cost that includes sales tax of 6.5%. Which of the following are advantages of using a named constant to represent the sales tax instead of simply entering 0.065 each time the tax is required in the code?

It will be easier for another programmer who may need to use this code to understand the purpose of the number wherever it is used in the code. If the tax amount changes to 7.0%, the value will only have to be changed in one place. It avoids the risk that any change to the value of sales tax will be made incorrectly or that an instance of the tax value might be missed as might occur if the number had to be changed in multiple locations.

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

Key

An element in a dictionary has two parts. What are they called?

Key and value

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

KeyError

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

KeyError

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

KeyError

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

KeyError

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

KeyError

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

KeyError

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

KeyError

Which widget will create an area that displays one line of text or an image?

Label

The built-in function ____ returns the length of a sequence.

Len

This function return the Length of a list:

Len

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

List

What will be assigned to s_string after the execution of the following code? special = '1357 Country Ln.' s_string = special[-3: ]

Ln

What type of error produces incorrect results but does not prevent the program from running?

Logic

The following is an example of an instruction written on which computer language? 10110000

Machine Language

The following is an example of an instruction written in which computer language? 10110000

Machine language

Where does a computer store a program and the data that the program is working with while the program is running?

Main memory

Which widget will display multiple lines of text?

Message

The procedure that an object performs are called.

Methods

What are the procedures that an object performs called?

Methods

What makes it easier to reuse the same code in more than one program?

Modules

What are the advantages of breaking a large program into modules?

Modules also make it easier to reuse the same code in more than one program. If you have written a set of functions that are needed in several different programs, you can place those functions in a module. Then, you can import the module in each program that needs to call one of the functions.

Does a set allow you to store duplicate elements?

No

Python has an object called _________ that is used to denote a lack of value.

None

Given a valid file that contains multiple lines of data, what is the output of the following code: f=open("names.txt","w") print(f)

None of these

What is the output of the following code? val1={'small':[1,2,3],'large':[64,87,92]} x=val1.get('medium','gigantic') print(x) An error is generated in the first line of code. None of these. [1,2,3] x [64,87,92] An error is generated in the second line of code.

None of these

Which of the following is used to add a new item to a dictionary? add append concat Correct! None of these +

None of these

Which statement would produce the value of the number of items in the list, list1? None of these list1.size() sizeof(list1) list1+1 list1.index() items in list1

None of these

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

None of these.

What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts?

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

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') main()

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

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

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

What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts?

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

Show the output of the following code: Def main(): Max = 0 getMax(1, 2, max) print(max) Def getMax(value1, value2, max): If value1 > value2: Max = value1 Else: Max = value2 main()

OUTPUT: 0

What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?

Object

What type of programming contains class definitions?

Object-oriented

element

One of the values in a list (or other sequence). The bracket operator selects elements of a list.

conditional statement

One program structure within another, such as a conditional statement inside a branch of another conditional statement

Which of these causes an IOError?

Opening a file that doesn't exist.

Word processing programs, spreadsheet program, email programs, web browsers, and game programs belong to which software?

Operating Systems (software)

Which of these is not a major component of a typical computer system?

Operating system

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

Pickling

What gives a program the ability to call the correct method depending on the type of object that is used to call it?

Polymorphism

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

Pop

The ______________ programming practice is centered on creating functions that are separate from the data that they work on.

Proceedural

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

Processing a tuple is faster than processing a list

What is an advantage of using a tuple rather than a list? Processing a tuple is faster than processing a list There is never an advantage to using a tuple Tuples can include any data as an element Tuples are not limited in size

Processing a tuple is faster than processing a list

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

Processing a tuple is faster than processing a list.

What is the advantage of using tuples over lists?

Processing a tuple is faster than processing a list.

What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?

Pseudocode

What symbol is used to mark the beginning and end of a string?

Quotation

Main memory is commonly known as _______

RAM

Main memory is commonly known as _______________.

RAM

What type of volatile memory is usually used only for temporary storage while running a program

RAM

What type of volatile memory is usually used only for temporary storage while running a program?

RAM

A(n) ?? structure causes a statement or set of statements to execute repeatedly.

Repetition

What is the structure that causes a statement or a set of statements to execute repeatedly?

Repetition

When the * operator's left operand is a list and its right operand is an integer, the operator becomes a

Repetition operator

If there are a group of these in a container, only one of them can be selected at any given time

RadioButton

exception

Raised by the runtime system if something goes wrong while the program is running.

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?

Random

The ?? function is a built-in function that generates a list of integer values.

Range

What is the read() library

Read the entire file into a single string

What do you call the process of retrieving data from a file?

Reading

What do you call the process of retrieving data from a file?

Reading data

What is the ReadLine() library?

Reads a single line from a file with newline at the end.

The symbols >, <, == , are all _____ operators.

Relational

What is the output of the following code? count=0 days=['Monday','Tuesday','Wednesday','Thursday','Friday'] for a in days: if count==2: print("Results:",end="") for b in range(2): print(a,end="") count+=1

Results:WednesdayWednesday

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

Return a default value

what is the string Modification method lower()?

Returns a copy of the string with all alphabetic letters converted to LOWERCASE.

what is the string Modification method lstrip()?

Returns a copy of the string with all leading whitespace characters removed. Leading whitespace are spaces and tabs that appear at the beginning of the string.

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

Returns a default value

what is the string Testing method isalpha()?

Returns true if the string contains only alphabetic letters. Returns false otherwise.

what is the string Testing method isdigit()?

Returns true if the string contains only numeric digits. Returns false otherwise.

In the following line of code, what is the name of the subclass? class Rose(Flower):

Rose

In the following line of code, what is the name of the subclass? class Rose(Flower):

Rose

Which widget allows the user to select a value by moving a slider along a track?

Scale

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

Second

an object that holds multiple items of data, stored one after the other. You can perform operations on a sequence to examine and manipulate the items stored in it.

Sequence

______ a object is the process of converting the object to a stream of bytes that can be saved to a file for later retrieval.

Serializing

A(n) _______ is an object that holds multiple unique items of data in an unordered manner.

Set

Mutator methods are also known as

Setters

What is another name for the mutator methods?

Setters

A function is called from the main function for the first time. It then calls itself seven times. What is the depth of recursion?

Seven

A(n) _______ is a span of items that are taken from a sequence.

Slice

A fundamental set of instructions that control the internal operation's of the computer's hardware

Software

Programs are commonly referred to as

Software

Dictionary is not indexed by number.

String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.

You created the following dictionary relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception? relationships['jimmy']

String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.

You used the following statement to create a dictionary: relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception? print(relationships['jimmy'])

String comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'.

An object of this type can be associated with a Label widget, and any data stored in the object will be displayed in the Label

StringVar

In an inheritance relationship, what is a specialized class called?

Subclass

In a UML diagram, what does the open arrowhead point to?

Superclass

A flowchart is a tool that programmers use to design programs

TRUE

Computer programs typically perform three steps: Input is received, some process is performed on the input, and output is produced.

TRUE

In Python, print statements written on separate lines do not necessarily output on separate lines

TRUE

The main reason for using secondary storage is to hold data for long periods of time, even when the power supply to the computer is turned off.

TRUE

In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.

Target Variable

What are string Testing Methods?

Test a string for specific characteristics, for example: the isdigit() method returns true if the string contains only numeric digits.

A(n) ______ file contains data that has been encoded as text, using a scheme such as ASCII.

Text

The contents of this type of file can be viewed in an editor such as Notepad:

Text File

This widget is an area in which the user may type a single line of input from the keyboard

Textline

format operator

The % operator takes a format string and a tuple of values and generates a string by inserting the data values into the format string at the appropriate locations.

A set of standard diagrams for graphically depicting object-oriented systems is provided by ________

The Unifies Modeling Language

(T/F) Closing a file disconnects the communication between the file and the program.

True

what is the string Modification method lstrip(char)?

The char argument is a string containing a character. Returns a copy of the string with all instances of char that appear at the BEGINNING of the string removed.

what is the string Modification method rstrip(char)?

The char argument is a string containing a character. Returns a copy of the string with all instances of char that appear at the END of the string removed

(T/F) Dictionaries are mutable types.

True

What is needed to delete a single line from a file?

The creation of a new file

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

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

This removes an item at a specific index in a list.

The del statement

Which of the following does not apply to sets?

The elements are in pairs

Which of the following does not apply to sets?

The elements are in pairs.

Which of the following does not apply to sets?

The elements are pairs.

Which of the following is associated with a specific file and provides a way for the program to work with that file?

The file object

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

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

(T/F) The following code could potentially raise an IOError. f=open("names.txt", 'r') for x in f: print(5/int(x.rstrip()))

True

What happens when a justification method is used to display string output but the string is longer than the allocated width?

The justification method is ignored

Which part of a dictionary element must be immutable?

The key

What does the index value -1 refer to in a list?

The last item in the list

What defines the depth of recursion?

The number of times the function calls itself

flow of execution

The order in which statements are executed during a program run.

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test.

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test.

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test.

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test.

What is the output of the following print statement? print('the path is D:\\sample\\test.')

The path is D:\sample\test.

What module do you import if you want to pickle objects?

The pickle module

What is the difference between the dictionary methods pop and popitem?

The pop method accepts a key as an argument, returns the value that is associated with that key, and removes that key-value pair from the dictionary. The popitem method returns a randomly selected key-value pair, as a tuple, and removes that key-value pair from the dictionary.

What is object serialization?

The process of converting the object to a stream of bytes that can be saved to a file for later retrieval.

Suppose you want to select a random number from the following sequence: 0, 5, 10, 15, 20, 25, 30 What library function would you use?

The randrange function, which is in the random module.

You can call this method to close a GUI program

The root widget's destroy method

Given a valid file containing multiple lines of data, what does the print() statement print out the first time that it is called: f=open("data.txt","r") for line in f: line=f.readline() print(line) f.close()

The second line of the file

What is the last Index in a list?

The size of the list minus one. Example:

This is the last index in a string

The size of the string minus one

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

The string with all leading whitespaces removed

syntax

The structure of a program

A class can be thought of as a blueprint that can be used to create an object. (T/F)

True

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

Third

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

Third section

What is the output of the following code? list1=['a','b','c'] list1.remove(1) print(list1)

This code causes an error

What is the output of the following code? d={0:'a',1:'b',2:'c'} print(d[-1])

This code causes an error.

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

This code generates an error

What is the output of the following code? list1=['a','b','c'] print(list1[3])

This code produces an error

What is the output of the following code? list1=[] list1+=4 print(list1)

This code produces an error

What is the output of the following code? list1=[] list1[1]='hello' print(list1[1][0])

This code produces an error

A dictionary can include the same value several times but cannot include the same key several times. True or False

True

Consider the following code: class Product: def __init__(self, name="", price=0.0): self.name = name self.price = price def getDescription(self): return self.name class Book(Product): def __init__(self, name="", price=0.0, author=""): Product.__init__(self, name, price) self.author = author def getDescription(self): return Product.getDescription(self) + " by " + self.author class Movie(Product): def __init__(self, name="", price=0.0, year=0): Product.__init__(self, name, price) self.year = year def getDescription(self): return Product.getDescription(self) + " (" + str(self.year) + ")" Now, what does this code print to the console: product = Book("Catcher in the Rye", 9.99, "J. D. Salinger") if isinstance(product, Product): print("This is a product.") if isinstance(product, Movie): print("This is a movie.") if isinstance(product, Book): print("This is a book.")

This is a product. This is a book.

(T/F) Strings can be written directly to a file with the write method, but integer data types must always be converted to strings before they can be written to a file.

True

(T/F) The following code could potentially raise a ZeroDivisionError. f=open("names.txt", 'r') for x in f: print(5/int(x.rstrip()))

True

The ____________ statement causes an exit from anywhere in the body of a loop.

break

The showinfo function is in this module

Tkinter.messagebox

evaluate

To simplify an expression by performing the operations in order to yield a single value.

(T/F) A dictionary can include the same value several times.

True

(T/F) A file can safely be opened and closed multiple times within the same program.

True

(T/F) A for loop that reads in lines from a file automatically stops when it reaches the end of the file, whereas the readline() method requires you to check for an empty string to signal the end of the file.

True

A(n) _________ gives information about the line number(s) that caused an exception.

Traceback

(T/F) All members of a set must be unique.

True

How many types of files are there?

Two

How many types of files are there?

Two In general, there are two types of files: text and binary.

What is the encoding technique called that is used to store negative numbers in the computers memory?

Two's complement

A language used to define the relationship between an object and the methods of the class is known as ________

UML

Python was originally implemented on ________________.

UNIX.

UML is an acronym for

Unified Modeling Language

What does the acronym UML stand for?

Unified Modeling Language

What does the acronym UML stand for?

Unified modeling language

Are the elements of a set ordered or unordered?

Unordered

A program that performs a specialized task, such as a virus scanner, a file compression program, or a data backup program

Utility Programs (software)

Examine the following piece of code: class Potato (Vegetable): In a UML diagram, what would the open arrowhead point to?

Vegetable

Given the following line of code, in a UML diagram, what would the open arrowhead point to? class Celery(Vegetable):

Vegetable

Write a program that outputs all of the positive integers less than 50 as well as the sum of those positive integers at the end.

WHILE LOOP: count = 0 while(count < 50): print(count) count = count + 1 FOR LOOP: for x in range (50): print(x)

When will the following loop terminate? while keep_on_going != 999 :

When keep_on_going refers to a value equal to 999

When will the following loop terminate? while keep_on_going != 999 :

When keep_on_going refers to a value equal to 999

When will the following loop terminate? while keep_on_going != 999 :

When keep_on_going refers to a value not equal to 999

The ____________ statement causes an exit from anywhere in the body of a loop.

break statement

What are the items that appear on the graphical interface window called?

Widgets

This is a small "holding section" in memory that many systems write data to before writing the data to a file.

buffer

Which of the following is considered to be the first computer to use a Graphics User Interface?

Xerox PARC Alto

What is the output of the following code? nums=[2,5,3,7] if 5 in nums: print('Yes') else: print('No')

Yes

Are strings immutable?

Yes, they cannot be modified.

How do you create an empty set?

You call the built-in set function.

How can you determine whether a key-value pair exists in a dictionary?

You can use the in operator to test for a specific key.

How can you determine whether a specific element exists in a set?

You can use the in operator to test for the element.

How do you determine the number of elements in a set?

You pass the set as an argument to the len function.

Which list will be referenced by the variable list_string after the execution of the following code? list_string = '03/07/2008' list_string = list_string.split('/')

['03', '07', '2008']

Which list will be referenced by the variable list_strip after the execution of the following code? list_string = '03/07/2008' list_strip = list_string.split('/')

['03', '07', '2008']

Which list will be referenced by the variable list_strip after the execution of the following code? list_string = '03/07/2008' list_strip = list_string.split('/')

['03', '07', '2008']

What is the output of the following code? a = '03/07/2014' b = a.split('/') print(b)

['03', '07', '2014']

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('/')

['03', '07', '2018']

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('/')

['03', '07', '2018']

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('/') ['3', '7', '2018'] ['3', '/', '7', '/', '2018'] ['03', '/', '07', '/', '2018'] ['03', '07', '2018']

['03', '07', '2018']

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('/')

['03', '07', '2018']

What is the output of the following code? school = ['primary','secondary',['college','university']] print(school[2])

['college', 'university']

What is the output of the following code? number = [0,1,2,3,4] print(number[:])

[0, 1, 2, 3, 4]

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

[0, 2, 4, 6, 8]

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

[0, 2, 4, 6, 8]

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

[0, 2, 4, 6, 8]

Which list will be referenced by the variable number after the following code is executed? number = range(0, 9, 2) [1, 3, 5, 7, 9] [2, 4, 6, 8] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] [0, 2, 4, 6, 8]

[0, 2, 4, 6, 8]

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

[0, 2, 4, 6, 8]

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

[0,2,4,6,8]

What will be the value of the variable 'list' after the following code executed? list = [1, 2] list = list * 3

[1, 2, 1, 2, 1, 2]

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

[1, 2, 1, 2, 1, 2]

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

[1, 2, 1, 2, 1, 2]

What would be the value of the variable list after the execution of the following code? list = [1, 2] list = list * 3

[1, 2, 1, 2, 1, 2]

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

[1, 2, 3, 10]

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

[1, 2, 3, 10]

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

[1, 2, 3, 10]

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

[1, 2, 3, 10]

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]

[1, 2, 3]

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]

[1, 2, 3]

Look at the following statement: numbers = [ 1, 2, 3] a. What value is stored in numbers [2]? b. What value is stored in numbers [0]? c. What value is stored in numbers [-1]?

a .3 b. 1 c. 3

Given the Python statement number = int(input( Enter a whole number: )) what will be the output if the user enters 17.9?

a Traceback error message

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

a del statement

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

a del statement

The smallest storage element in a computer's memory is known as a _____.

bit

The smallest storage location in a computer's memory is known as a

bit

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

block

A set of statements that belong together as a group and contribute to the function definition is known as a(n) _____.

block

In Python, ____________________ literals can be written in several ways, but most programmers prefer the use of the standard values True and False.

boolean

In Python, variable names may begin with ____________.

both a & b

This string method returns the lowest index in the string where a specified substring is found

find

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

find(substring)

Which method would you use to determine whether a certain substring is present in a string? find(substring) replace(string, substring) endswith(substring) startswith(substring)

find(substring)

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

find(substring)

The program development cycle is made up of _____ steps that are repeated until no errors can be found in the program.

five

A ____________ is a Boolean-valued variable used to report whether a certain circumstance has occurred.

flag

A ________________ is a Boolean variable that signals when some condition exists in the program.

flag

Boolean variables are commonly used as __________ to indicate whether a specific condition exists.

flags

USB drives store data using _________ memory.

flash

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) ________ data type.

float

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) __________ data type. sold = 256.752

float

After the execution of the following statement, the variable sold will reference the numeric literal value as (n) __________ data type. sold = 256.752

float

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

float

After the execution of the following statement, the variable sold will reference the numeric literal value as a(n) _____ data type: sold = 256.752

float

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

floor

A(n) _____ is a diagram that graphically depicts the steps that take place in a program.

flowchart

A(n) ________ is a diagram that graphically depicts the steps that take place in a program?

flowchart

A(n) __________ is a diagram that graphically depicts the steps that take place in a program?

flowchart

Which programming tool graphically depicts the logical steps to carry out a task and show how the steps relate to each other?

flowchart

In Python, you would use the _______ statement to write a count-controlled loop.

for

The ____________ loop is used to iterate through a sequence of values.

for

Assume names references a list. Write a for loop that displays each element of the list.

for element in names: print(element)

Assume the list of numbers1 has 100 elements, and numbers2 is an empty list. Write code that copies the values in numbers1 to numbers2.

for item in numbers1: numbers2.append(item)

The parameters in a function definition are also called _________ parameters.

formal

The ________ specifier is a special set of characters that specify how a value should be formatted.

formatting

The _______________ specifier is a special set of characters that specify how a value should be formatted.

formatting

When Python removes an orphaned object from memory, it is called ____________.

garbage collection

The ____ dictionary method returns the value associated with a specified key. If the key is not found, it returns a default value. a. pop( ) b. key( ) c. value( ) d. get( )

get( )

Accessor methods are also known as getters attributes setters instances

getters

assignment statement

gives value to a variable

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

global

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

global

A variable that can be recognized everywhere in the program is called a _________ variable.

global

A(n) _____ constant is a global name that references a value that cannot be changed.

global

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

global

It is recommended that programmers should avoid using _____ variables in a program when possible.

global

If the start index ____________ the end index, the slicing expression will return an empty string. greater than equal to less than or equal to less than

greater than

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

greater than

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

greater than

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

greater than

The mechanical and electrical devices of a computer are referred to as _______________.

hardware

The term _________ refers to all the physical devices that make up a computer.

hardware

The term _______________ refers to all of the physical devices that a computer is made of.

hardware

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

header

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

header

The first line in the function definition is known as the function _____.

header

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

hierarchy

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

hierchy

chart is a visual representation of the relationships between functions.

hierchy

A ________ variable is created inside a function.

local

What is the relationshop called in which one object is a specialized version of another object?

is-a

Which method can you use to determine whether an object is an instance of a class?

isinstance

Which function provides a way to check an object's type?

isinstance()

Which of the following string methods can be used to determine if a string contains only '\n' characters?

isspace()

What does the get method do if the specified key is not found in the dictionary? it returns a default value it throws an exception it does nothing you cannot use the get method to specify a key

it returns a default value

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

items

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

items

Which method would you use to return all the keys in a dictionary and their associated values as a list of tuples?

items

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

items

The ____ method returns all of a dictionary's keys and their associated values as a sequence of tuples. a. keys_values( ) b. values( ) c. items ( ) d. get( )

items ( )

The ___ method return all of a dictionary's keys and their associated values as a sequence of Tuples.

items()

Each repetition of a loop is known as a(n) ___________________

iteration

What does a subclass inherit from its superclass?

its data members and its methods

What does the following code display? name = 'joe' print (name . lower ( ) ) print (name. upper ( ) ) print (name)

joe JOE joe joe

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

key

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

key

In a dictionary, you use a(n) _____ to locate a specific value. a. datum b. element c. item d. key

key

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

key

In a dictionary, you use a(n) ______________ to locate a specific value key datam element item

key

The _____ argument specifies which parameter the argument should be passed into.

keyword

Which widget will create an area that displays one line of text or an image?

label

This function returns the length of a strung

len

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

len

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

len

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

len

Which would you use to get the number of elements in a dictionary? sizeof length size len

len

The ____ function returns the number of elements in a dictionary: a. size( ) b. len( ) c. elements( ) d. count( )

len( )

The following function returns the number of elements in a set: a. size( ) b. len( ) c. elements( ) d. count( )

len( )

The following function returns the number of elements in a set:

len( ).

Recursive functions are _____ iterative algorithms.

less efficient than

In Python, variable names may consist of

letters,digits, and underscores

_________ are file that facilitate the reuse of functions.

library modules

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called

list

In Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a _____.

list

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

list

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

list

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

list

The following statement is an example of _________. [int(num) for num in listOfNums]

list comprehension

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

list( )

Which of the following statements will convert the values in a tuple named tuple1 to the values in a list named list1.

list1=list(tuple1)

Which of the following statements is true? lists are mutable; strings are immutable both lists and strings are immutable lists are immutable; strings are mutable None of these both lists and strings are mutable

lists are mutable; strings are immutable

In programming terminology, numbers are called numeric ____________.

literals

Write a statement that creates a list with the following strings: 'Einstein', 'Newton', 'Copernicus', and 'Kepler' .

names = ['Einstein', 'Newton', 'Copernicus', 'Kepler']

When an if-else statement contains other if-else statements, it is said to be ____________.

nested

When one loop is contained in the body of another loop, it is said to be ____________.

nested

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

nested list

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

nested list

Recursion is _____.

never required to solve a problem

The _____ operator take a Boolean expression as its operand and reverses its logical value.

not

The logical _________ operator reverses the truth of a Boolean expression.

not

What will be displayed after the following code executes? guess = 19 if guess < 19: print("Too low") elif guess > 19: print("Too high")

nothing will display

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

number = random.randint(1, 50)

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

number = random.randint(1, 50)

Assuming the random module has been imported, which of the following could possibly result in a value of 0.94?

number = random.random()

What type of programming contains class definitions?

object-oriented

What type of programming contains class definitions? procedural modular object-oriented top-down

object-oriented

The primary difference between a tuple and a list is that

once a tuple is created, it cannot be changed

The primary difference between a tuple and a list is that once a tuple is created, it cannot be changed you don't use commas to separate elements in a tuple a tuple cannot include lists as elements a tuple can only include string elements

once a tuple is created, it cannot be changed

The primary difference between a tuple and a list is that...

once a tuple is created, it cannot be changed

The primary difference between a tuple and list is that _____.

once a tuple is created, it cannot be changed

The primary difference between a tuple and list is that ________.

once a tuple is created, it cannot be changed

A for loop that uses a range() function is executed

once for each integer in the collection returned by the range() function

The parentheses of the range function can contain ____________ values.

one,two, and three

Which steep creates a connection between a file and a program

open the file

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

open the file

Before a file can be used by a program, it must be

opened

Before a file can be used by a program, it must be _________.

opened

In the expression 12.45 + 3.6, the values to the right and left of the + symbol are the

operands

The _____ accepts the user's commands.

operating system

A compound Boolean expression created with the _____ operator is true if either of its subexpressions is true.

or

When using the __________ logical operator, one or both of the subexpressions must be true for the compound expression to be true.

or

Which logical operators perform short-circuit evaluation?

or, and

Which logical operators perform short-circuit evaluation?

or, not

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

outfield = open('users.txt.', 'w')

write a program that opens a file with the file name my_name.txt, writes your name to the file, and closes the file.

outfile = open("my_name.txt", "w") outfile.write("Ana Lucia") outfile.close()

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

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

A file that data is written to is known as a(n)

output file

This shape appears at the top and bottom and is called a terminal symbol. The Start terminal symbol marks the starting point and the End terminal symbol marks the end point

ovals

A recursive function includes _____ which are not necessary in a loop structure.

overhead actions

Given a variable named p that refers to a Product object, which of the following statements accesses the price attribute of the Product object?

p.price

This method arranges a widget in its proper position, and it makes the widget visible when the main window is displayed

pack

This method is used to make a widget visible and to determine its position in the main window

pack()

Arguments are passed by _____ to the corresponding parameter variables in the function.

position

input symbols and output symbols and represents steps in which data is input and output

parallelograms

A(n) _____ is a variable that receives an argument that is passed into a function.

parameter

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

parameter

Which of the following is in the correct order of operator precedence (highest to lowest)?

parentheses, multiplication, addition.

The ____________ statement is a do-nothing statement.

pass

What function do you call to pickle an object?

pickle.dump

What function do you call to retrieve and unpickle an object?

pickle.load

In Python, object serialization is called ______

pickling

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

pickling

The feature of inheritance that allows an object of a subclass to be treated as if it were an object of the superclass is known as

polymorphism

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

pop

Which method would you use to get the value associated with a specific key and remove that key-value par from the dictionary? items pop popitem list

pop

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

pop

The ____ method returns the value associated with a specified key and removes that key-value pair from the dictionary . a. pop( ) b. random( ) c. popitem( ) d. rand_pop( )

pop( )

The ___ method return the value associated with a specified key and removes that key-value pair from the dictionary.

pop()

The ____ method returns a randomly selected key-value pair from a dictionary. a. pop( ) b. random( ) c. popitem( ) d. rand pop( )

popitem( )

The method returns an arbitrarily selected key-value pair from a dictionary.

popitem( )

What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to be compiled or executed?

pseudocode

What is the informal language, used by programmers use to create models of programs, that has no syntax rules and is not meant to be compiled or executed?

pseudocode

Which programming tool uses English-like phrases with some Python terms to outline the task?

pseudocode

The return values of the trigonometric functions in Python are in

radians

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

random

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

random

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

random

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?

random

a ____access file retrevies data from the begging of the file to the end of the file

random

The _____ function is a built-in function that generates a list of integer values.

range

The function call produces the same sequence as range( 10 ).

range( 0, 10, 1 ).

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

read

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

read

This marks the location of the next item that will be read from a file.

read position

If a file has been opened properly, which method will return the file's entire contents as a string?

read()

What is the process of retrieving data from a file called

reading data

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

reading data

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

readline

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

readline

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

readline

This file object methods return a list containing the File's contents

readlines

A(n) ______ is a complete set of data about an item, usually a line of data in an input file.

record

In a flowchart, a function call is depicted by a(n)

rectangle

processing symbols that represent steps in which the program performs some process on data, such as a mathematical calculation.

rectangle

The base case is a case in which the problem can be solved without _____.

recursion

A(n) _________ operator determines whether a specific relationship exists between two values.

relation

The symbols > < and == are all _____________ operators.

relational

This set method removes an element and raises an exception if the element is not found. a. remove b. discard c. delete d. erase

remove

This set method removes an element and raises an exception if the element is not found.

remove

A(n) ________ structure causes a set of statements to execute repeatedly.

repetition

A(n) ________ structure is a structure that causes a statement or a set of statements to execute repeatedly.

repetition

A(n) __________ decision structure provides only one alternative path of execution.

single alternative

A sequence of consecutive characters from a string is called a(n) ____________.

slice

a_____is a span of items that are taken from a sequence

slice

A problem can be solved with recursion if it can be broken down into _____ problems.

smaller

Computer programs are referred to as _______________ .

software

Programs are commonly referred to as

software

Programs are commonly referred to as _____.

software

A(n) __________ is a single task that the program must perform in order to satisfy the customer.

software requirement

A _____ has no moving parts, and operates faster than a traditional disk drive.

solid state drive

If the problem can be solved immediately without recursion, then the recursive function _____.

solves it and returns

Instructions in a Python program are called _______________.

source code

An operator is a

special symbol that performs a specific operation.

operators

special tokens that represent computations like addition, multiplication and division

Comments are useful for

specifying the intent of the program

Which method turns a single string into a list of substrings?

split

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

standard

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

standard

The interval between the numbers used in the range is known as which of the following?

step value

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

str

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

str

the____method returns true if the string contains only numeric digits.

string

You created the following dictionary relationships = {'Jimmy':'brother'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception? relationships['jimmy']

string comparisons are case sensitive so 'jimmy' does not equal 'Jimmy'

This string method returns a copy of the string with all leading and trailing whitespace characters removed

strip

The top-down design breaks down the overall task of a program into a series of

subtasks

When there are several classes that have many common data attributes, it is better to write a(n) _____ to hold all the general data.

superclass

When there are several classes that have many common data attributes, it is better to write a(n) ________ to hold all the general data.

superclass

When there are several classes that have many common data attributes, it is better to write a(n) __________ to hold all the general data.

superclass

Base classes are also called _____.

superclasses

Which type of error prevents the program from running?

syntax

Closing a file disconnects the communication between the file and the program.

t

In Python, the variable in the for clause is referred to as the _____ because it is the target of an assignment at the beginning of each loop iteration.

target variable

In Python, the variable in the for clause is referred to as the __________ because it is the target of an assignment at the beginning of each loop iteration.

target variable

In Python, the variable in the for clause is referred to as the ________ because it is the target of an assignment at the beginning of each loop iteration.

target variable Because it is the target of an assignment at the beginning of each loop iteration

What are Modification Methods?

these are strings that have a number of methods that return modified versions of themselves.

The contents of this type of file can be viewed in an editor such as Notepad.

text file

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

the data is copied from a variable in RAM to a file

You use ____ to delete an element from a dictionary. a. the remove method b. the erase method c. the delete method d. the del statement

the del statement

When referencing a substring such as str1[m:n] if m ? n then the value will be ____________.

the empty string

Which of the following is associated with a specific file and provides a way for the program to work with that file

the file object

Which of the following is associated with a specific file and provides a way for the program to work with that file?

the file object

When an if-elif-else statement is evaluated, which block of statements is evaluated?

the first condition satisfied

This string method returns true if a string contains only alphabetic characters and is at least one character in length

the is alpha method

This string method returns true if a string contains only numeric digits and is at least one character in length

the isdigit method

semantic

the meaning of a program

When you code the dot operator after an object, what can you access?

the public attributes and methods of the object

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

the string with all leading white spaces removed

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

the string with all leading whitespaces removed

What is the return value of the string method lstrip()? the string with all leading whitespaces removed the string with all leading tabs removed the string with all whitespaces removed the string with all leading spaces removed

the string with all leading whitespaces removed

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

top-down

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

top-down

Which of the following represents an example to calculate the sum of numbers (that is, an accumulator), given that the number is stored in the variable number and the total is stored in the variable total?

total += number

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

total += number

A dictionary can include the same value several times but cannot include the same key several times.

true

An exception handler is a piece of code that is written using the try/except statement

true

Both of the following for clauses would generate the same number of loop iterations.

true

Decision structures are also known as selection structures.

true

Each subclass has a method named __init__ that overrides the superclass's __init__ method.

true

If you try to retrieve a value from a dictionary using a nonexistent key, a KeyError exception is raised.

true

In Python, print statements written on separate lines do not necessarily output on separate lines.

true

In script mode, the interpreter reads the contents of a file that contains Python statements and executes each statement.

true

It is possible to create a WHILE loop that determines when the end of a file has been reached

true

Nested decision statements are one way to test more than one condition.

true

The variable data refers to the string No way! . The expression data[3:6] evaluates to:

way

When will the following loop terminate? while keep_on_going != 999:

when keep_on_going refers to a value equal to 999

When will the following loop terminate? while keep_on_going != 999:

when keep_on_going refers to a value equal to 999

When will the following loop terminate? while keep_on_going != 999:

when keep_on_going refers to a value equal to 999

What Python loop repeatedly executes a block of statements as long as a certain condition is met?

while

What is the format for the while clause in Python

while condition : statement

Which of the following will create an object, worker_joey of the Worker class? worker_joey.Worker class worker_joey: worker_joey = Worker() def __init__(worker_joey)

worker_joey = Worker()

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

worker_joey = Worker()

What does the following expression mean? x <= y

x is less than or equal to y

What does the following expression mean? x <= y

x is less than or equal to y

What does the following expression mean? x <= y

x is less than or equal to y

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

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

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

yesnono

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

yesnono

What does the following of the code display? mystr = 'yes' mystr += 'no' mystr += 'yes' print (mystr)

yesnoyes

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

zzzzzzzzzzzzzzz

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

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

What is the correct structure for creating a dictionary of month names to be accessed by month numbers?

{ 1 : 'January', 2 : 'February', 3 : 'March' }

What is the correct structure for creating a dictionary of month names to be accessed by month numbers? a. { 1 ; 'January', 2 ; 'February', 3 ; 'March' } b. { 1 : 'January', 2 : 'February', 3 : 'March' } c. [ 1 : 'January', 2 : 'February', 3 : 'March' ] d. { 1, 2, 3 : 'January', 'February', 'March' }

{ 1 : 'January', 2 : 'February', 3 : 'March' }

What is the correct syntax for creating a dictionary of month names to be accessed by month numbers (only the first three months are given)? { 1, 2, 3 : 'January', 'February', 'March' } [ 1 : 'January', 2 : 'February', 3 : 'March' ] { 1 : 'January', 2 : 'February', 3 : 'March' } { 1 ; 'January', 2 ; 'February', 3 ; 'March' } {' ','January','February','March'}

{ 1 : 'January', 2 : 'February', 3 : 'March' }

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)? [ '1': 'January, '2': 'February', ..... '12': 'December' ] { 1; 'January', 2; 'February', ..... 12: 'December' } { 1, 2, .... 12 : 'January', 'February', .... 'December' } { 1: 'January', 2: 'February', .... 12: 'December' }

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

You can use ___ to create an empty dictionary

{ }

You can use ____ to create an empty dictionary. a. { } b. ( ) c. [ ] d. empty( )

{ }

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: (tab) del cities['CA'] (tab) cities['CA'] = 'Sacramento' print(cities) {'CA' : 'Sacramento'} ['CA' : 'Sacramento'] {'CA' : 'Sacramento', 'NY' : 'Albany', 'GA' : 'Atlanta'} {'NY' : 'Albany', 'GA' : 'Atlanta'}

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

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: (tab) del cities['FL'] cities['FL'] = 'Tallahassee' print(cities) {'CA' : 'San Diego', 'FL' : 'Tallahassee', 'NY' : 'Albany', 'GA' : 'Atlanta'} KeyError {'FL' : 'Tallahassee'} {'CA' : 'San Diego', 'NY' : 'Albany', 'GA' : 'Atlanta'}

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

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: (tab) del cities['FL'] (tab) cities['FL'] = 'Tallahassee' print(cities) {'CA' : 'San Diego', 'NY' : 'Albany', 'GA' : 'Atlanta'} {'CA' : 'San Diego', 'NY' : 'Albany', 'GA' : 'Atlanta', 'FL' : 'Tallahassee'} {'FL' : 'Tallahassee'} KeyError

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

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)

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

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)

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

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)

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

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

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

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

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


Related study sets

Sociology 2301 - Chauvin Connect Ch.1-3

View Set

Module 8: Sleep and Dreams Quiz Objectives 1-3

View Set

Intermediate Fiance -- Chapter 6

View Set

Comp TIA A+ part 2 final assessment

View Set

History-GCSE Renaissance medicine

View Set

Surface and sectional anatomy week 2 test

View Set

Chapter 39, Oxygenation and Perfusion

View Set