PYTHON

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

function

The first line in the function definition is known as the function ________.

header

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

human

What concept involves a superclass and a subclass?

inheritance

What attributes belong to a specific instance of the class?

instance

With what part of the computer does the user interact?

user interface

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

!=

What types of programs are event-driven?

GUI programs

The acronym GUI stands for

Graphical User Interface

Which widget allows the user to select a value by moving a slider along a track?

scale

Base classes are also called ________

superclasses

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

tkinter

True/False: A class might be thought of as a 'blueprint' that an object may be created from.

true

True/False: A problem can be solved with recursion if it can be broken into smaller problems that are identical in structure to the overall problem.

true

True/False: A recursive function must have some way to control the number of times it repeats

true

True/False: A root widget's destroy method can be used as a callback function for a quit button.

true

True/False: Lists are dynamic data structures such that items may be added to them or removed from them

true

True/False: The pack method determines where a widget should be positioned.

true

True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.

true

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

tuple

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 value of the variable phones after the execution of the following code? phones = {'John': '555555', 'Julie': '7777777'} phones['John'] = '1234567'

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

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

Dictionary is not indexed by number

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

The Toplevel widget is a container, like a ________, but displays in its own window.

Frame

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

True

True/False: When using the camelCase naming convention, the first word of the variable name is written in lowercase letters and the first character of the second and subsequent words are written in uppercase letters.

True

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 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 the object's state?

__str__

A value-returning function is ________.

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

True/False: The hierarchy chart shows all the steps that are taken inside a function

false

True/False: The instances of a class share the data attributes in the class

false

True/False: The remove method removes all occurrences of the item from a list.

false

A(n) ________ is a diagram that graphically depicts the steps that take place in a program.

flowchart

What is another name for the accessor methods?

getters

A ________ constant is a global name that references a value that cannot be changed.

global

When working with multiple sets of data, one would typically use a ________.

nested list

What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?

object

True/False: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.

False

True/False: In Python, math expressions are evaluated from left to right, no matter what the operators are. Selected Answer

False

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

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

In which environment can a user determine the order in which things happen?

GUI

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.

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

Jimmy and jimmy are different

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

KeyError

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

True

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

True

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

True/False: A list cannot be passed as an argument to a function.

false

True/False: A mutator method has no control over the way that a class's data attributes are modified.

false

True/False: A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.

false

True/False: An object is a stand-alone program but is used by programs that need its service.

false

True/False: Check buttons are displayed in groups and used to make mutually exclusive selections.

false

True/False: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.

false

True/False: Using the radio buttons, the user can make multiple selections at one time.

false

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

find(substring)

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

insert

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

interpreter

What is the relationship called in which one object is a specialized version of another object?

is a

Which widget will display multiple lines of text?

message

What are the procedures that an object performs called?

methods

What type of programming contains class definitions?

object-oriented

The primary difference between a tuple and list is that ________.

once a tuple is created, it cannot be changed

A(n) ________ is a variable that receives an argument that is passed into a function

parameter

What gives a program the ability to call the correct method depending on the type of object that is used to call it?

polymorphism

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

self parameter

What is another name for the mutator methods?

setters

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

What defines the depth of recursion?

the number of times the function calls itself

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

third

True/False: An info dialog box is a simple window that displays a message to the user and has an OK button that closes the dialog box.

true

True/False: Each subclass has a method named __init__ that overrides the superclass's __init__.

true

True/False: In Python, one can have a list of variables on the left side of the assignment operator

true

True/False: New attributes and methods may be added to a subclass.

true

True/False: One of the reasons not to use global variables is that it makes a program hard to debug.

true

True/False: Programs that use tkinter do not always run reliably under IDLE.

true

True/False: Python does not have GUI programming features built into the language itself.

true

True/False: Python function names follow the same rules for naming variables.

true

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

true

A Boolean variable can reference one of two values: ________.

true or false

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

try/except statement

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

update

What are the items that appear on the graphical interface window called?

widgets

What does the following expression mean? x <= y

x is less than or equal to y

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

'Country Ln.'

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 the string variable pattern after the execution of the following code? i = 3 pattern = 'z' * (5 * i)

'zzzzzzzzzzzzzzz'

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

0 through 7

________ allow(s) a new class to inherit the members of the class it extends.

Inheritance

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 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 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 is called a(n) ________.

accumulator

What does a subclass inherit from a superclass?

attributes and methods

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

canvas

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

class dining(furniture):

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

condition-controlled loop

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

in

Which method can you use to determine whether an object is an instance of a class?

isinstance

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

key

Which widget will create an area that displays one line of text or an image?

label

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

len

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

list

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

local

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

second

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

'ABCD'

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

'w'

What method or operator can be used to concatenate lists?

+

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

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

24.0

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

25

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

68

What is not an example of an augmented assignment operator?

<=

In Python the ________ symbol is used as the equality operator

==

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

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

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

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

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

What is the output of the following print statement? print('The path is D:\\sample\\test.')

The path is D:\sample\test

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: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.

True

True/False: 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

True/False: Comments in Python begin with the # character.

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: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.

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 for passing multiple arguments to a function.

True

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

True

True/False: The function header marks the beginning of the function definition.

True

True/False: 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 correct data.

True

True/False: When function A calls function B, which in turn calls function A, it is known as indirect recursion.

True

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

True

When will the following loop terminate? while keep_on_going != 999:

When keep_on_going refers to a value equal to 999

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 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 would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = list1 list1 = [4, 5, 6]

[1,2,3]

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

argument

A set of statements that belong together as a group and contribute to the function definition is known as a(n) ________.

block

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

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

count-controlled loop

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

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

del

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

del statement

What are the data items in the list called?

elements

True/False: A function definition specifies what a function does and causes the function to execute.

false

True/False: A local variable can be accessed from anywhere in the program.

false

True/False: The sort method rearranges the elements of a list so they appear in ascending or descending order.

false

True/False: Unlike other languages, in Python, the number of values a function can return is limited to one

false

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

global

It is recommended that programmers should avoid using ________ variables in a program when possible

global

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

math

What makes it easier to reuse the same code in more than one program?

modules

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

pickling

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

pop

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?

psuedocode

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

read

What is the structure that causes a statement or a set of statements to execute repeatedly?

repitition

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

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

scope

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

standard

True/False: Different functions can have local variables with the same names

true


Conjuntos de estudio relacionados

Abdominal Sonography Review: Quiz: #9: ABDOMINAL VASCULATURE

View Set

Chapter 11 - The Role of Government in Our Economy

View Set