Introduction to Python Programming

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

A ____ is a name that references a value in the computer's memory. 1. variable 2. register 3. RAM slot 4. byte

A

A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is . 1. code reuse 2. divide and conquer 3. debugging 4. facilitation of teamwork

A

A file that data is read from is known as a(n) . 1. input file 2. output file 3. sequential access file 4. binary file

A

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. 1. sentinel 2. flag 3. signal 4. accumulator

A

A(n) _____ is a piece of data that is sent into a function. 1. argument 2. parameter 3. header 4. packet

A

If you call the index method to locate an item in a list and the item is not found, this happens. 1. A ValueError exception is raised. 2. An InvalidIndex exception is raised. 3. The method returns −1. 4. Nothing happens. The program continues running at the next statement.

A

In the expression 12 + 7, the values on the right and left of the + symbol are called . 1. operands 2. operators 3. arguments 4. math expressions

A

Short notes placed in different parts of a program explaining how those parts of the program work are called . 1. comments 2. reference manuals 3. tutorials 4. external documentation

A

The contents of this type of file can be viewed in an editor such as Notepad. 1. text file 2. binary file 3. English file

A

The symbols >, <, and == are all operators. 1. relational 2. logical 3. conditional 4. ternary

A

The while loop is a ____ type of loop. 1. pretest 2. no-test 3. prequalified 4. post-iterative

A

This operator performs division, but instead of returning the quotient it returns the remainder. 1. % 2. * 3. ** 4. /

A

This operator performs integer division. 1. // 2. % 3. ** 4. /

A

This term refers to an individual item in a list. 1. element 2. bin 3. cubbyhole 4. slot

A

Which built-in function can be used to read input that has been typed on the keyboard? 1. input() 2. get_input() 3. read_input() 4. keyboard()

A

A ____ is a variable that is created inside a function. 1. global variable 2. local variable 3. hidden variable 4. none of the above; you cannot create a variable inside a function

B

A ____ structure provides one alternative path of execution. 1. sequence 2. single alternative decision 3. one path alternative 4. single execution decision

B

A compound Boolean expression created with the ____ operator is true if either of its subexpressions is true. 1. and 2. or 3. not 4. either

B

A file that data is written to is known as a(n) . 1. input file 2. output file 3. sequential access file 4. binary file

B

A is a name that represents a value that does not change during the program's execution. 1. named literal 2. named constant 3. variable signature 4. key term

B

A magic number is . 1. a number that is mathematically undefined 2. an unexplained value that appears in a program's code 3. a number that cannot be divided by 1 4. a number that causes computers to crash

B

A(n) ____ is a special variable that receives a piece of data when a function is called. 1. argument 2. parameter 3. header 4. packet

B

A(n) _____ makes a variable reference a value in the computer's memory. 1. variable declaration 2. assignment statement 3. math expression 4. string literal

B

In an inheritance relationship, the ___ is the general class. 1. subclass 2. superclass 3. slave class 4. child class

B

Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of which data type? 1. int 2. float 3. currency 4. str

B

The -= operator is an example of a(n) operator. 1. relational 2. augmented assignment 3. complex assignment 4. reverse assignment

B

This is a number that identifies an item in a list. 1. element 2. index 3. bookmark 4. identifier

B

This is a prewritten function that is built into a programming language. 1. standard function 2. library function 3. custom function 4. cafeteria function

B

This standard library function returns a random integer within a specified range of values. 1. random 2. randint 3. random_integer 4. uniform

B

This string method returns a copy of the string with all leading and trailing whitespace characters removed. 1. clean 2. strip 3. remove_whitespace 4. rstrip

B

This will happen if you try to use an index that is out of range for a list. 1. A ValueError exception will occur. 2. An IndexError exception will occur. 3. The list will be erased and the program will continue to run. 479 4. Nothing—the invalid index will be ignored.

B

When an exception is generated, it is said to have been . 1. built 2. raised 3. caught 4. killed

B

When possible, you should avoid using _____ variables in a program. 1. local 2. global 3. reference 4. parameter

B

Which built-in function can be used to convert an int value to a float? 1. int_to_float() 2. float() 3. convert() 4. int()

B

Which of the following statements will cause an error? 1. x = 17 2. 17 = x 3. x = 99999 4. x = '17'

B

You ____ a function to execute it. 1. define 2. call 3. import 4. export

B

You write this statement to respond to exceptions. 1. run/handle 2. try/except 3. try/handle 4. attempt/except

B

A ___ error does not prevent the program from running, but causes it to produce incorrect results. 1. syntax 2. hardware 3. logic 4. fatal

C

A ____ structure can execute a set of statements only under certain circumstances. 1. sequence 2. circumstantial 3. decision 4. Boolean

C

A(n) _____ is the part of a program in which a variable may be accessed. 1. declaration space 2. area of visibility 3. scope 4. mode

C

A(n) loop has no way of ending and repeats until the program is interrupted. 1. indeterminate 2. interminable 265 3. infinite 4. timeless

C

A(n) structure tests a condition and then takes one path if the condition is true, or another path if the condition is false. 1. if statement 2. single alternative decision 211 3. dual alternative decision 4. sequence

C

A____ is a sequence of characters. 1. char sequence 2. character collection 3. string 4. text block

C

This function returns the length of a list. 1. length 2. size 3. len 4. lengthof

C

This is a section of code that gracefully responds to exceptions. 1. exception generator 2. exception manipulator 3. exception handler 4. exception monitor

C

This is an operator that raises a number to a power. 1. % 2. * 3. ** 4. /

C

This is the first index in a list. 1. −1 2. 1 3. 0 4. The size of the list minus one

C

This is the first index in a string. 1. −1 2. 1 3. 0 4. The size of the string minus one

C

This type of function returns either True or False. 1. Binary 2. true_false 3. Boolean 4. logical

C

When a program is finished using a file, it should do this. 1. erase the file 2. open the file 3. close the file 4. encrypt the file

C

and, or, and not are operators. 1. relational 2. logical 3. conditional 4. ternary

C

A string literal in Python must be enclosed in . 1. parentheses. 2. single-quotes. 3. double-quotes. 4. either single-quotes or double-quotes.

D

A variable that is visible to every function in a program file is a . 1. local variable 2. universal variable 3. program-wide variable 4. global variable

D

A(n) ____ expression has a value of either True or False. 1. binary 2. decision 3. unconditional 4. Boolean

D

Before a file can be used by a program, it must be . 1. formatted 2. encrypted 3. closed 4. opened

D

The first line of a function definition is known as the . 1. body 2. introduction 3. initialization 4. header

D

This file object method returns a list containing the file's contents. 1. to_list 2. getlist 3. readline 4. readlines

D

This is the last index in a list. 1. 1 2. 99 3. 0 4. The size of the list minus one

D

This is the last index in a string. 1. 1 2. 99 3. 0 4. The size of the string minus one

D

This list method adds an item to the end of an existing list. 1. add 2. add_to 3. increase 4. append

D

This statement causes a function to end and sends a value back to the part of the program that called the function. 1. end 2. send 3. exit 4. return

D

This symbol marks the beginning of a comment in Python. 1. & 2. * 3. ** 4. #

D

Which of the following statements creates a tuple? 1. values = [1, 2, 3, 4] 2. values = {1, 2, 3, 4} 3. values = (1) 4. values = (1,)

D

A condition-controlled loop always repeats a specific number of times

F

A file object's writelines method automatically writes a newline ('\n') after writing each list item to the file.

F

A program can be made of only one type of control structure. You cannot combine structures

F

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

F

A statement in one function can access a local variable in another function.

F

Calling a function and defining a function mean the same thing.

F

If you do not handle an exception, it is ignored by the Python interpreter, and the program continues to execute.

F

If you print a variable that has not been assigned a value, the number 0 will be displayed.

F

In Python, you cannot write functions that accept multiple arguments.

F

It is not necessary to initialize accumulator variables.

F

Lists in Python are immutable.

F

The else suite in a try/except statement executes only if a statement in the try suite raises an exception.

F

The finally suite in a try/except statement executes only if no exceptions are raised by statements in the try suite.

F

The process of opening a file is only necessary with input files. Output files are automatically opened when data is written to them.

F

To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.

F

Variable names can have spaces in them.

F

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

F

You can remove an element from a tuple by calling the tuple's remove method.

F

You can write any program using only sequence structures

F

You do not need to have an import statement in a program to use the functions in the random module.

F

A compound Boolean expression created with the and operator is true only when both subexpressions are true.

T

A decision structure can be nested inside another decision structure.

T

A function in Python can return more than one value.

T

A list can be an element in another list.

T

In Python, the first character of a variable name cannot be a number.

T

In a math expression, multiplication and division take place before addition and subtraction.

T

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

T

Once a string is created, it cannot be changed.

T

Programmers must be careful not to make syntax errors when writing pseudocode programs

T

Some library functions are built into the Python interpreter.

T

The following statement subtracts 1 from x: x = x − 1

T

The while loop is a pretest loop.

T

Tuples in Python are immutable.

T

When you open a file that file already exists on the disk using the 'w' mode, the contents of the existing file will be erased.

T

You can have more than one except clause in a try/except statement.

T

You can use the + operator to concatenate two lists.

T

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

T


Conjuntos de estudio relacionados

BIOL 141 Respiratory System (Exam 3)

View Set

Chapter 14 - Firms In Competitive Markets

View Set

Personal Finance 12th Chapter 2 Study Guide

View Set

Chapter 91: Miscellaneous Antibacterial Drugs:

View Set