Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
50 Cards in this Set
- Front
- Back
Which of the following represents an example to calculate the sum of the numbers (accumulator)?
|
total += number
|
|
What is the format for the while clause in Python?
|
while condition :
|
|
What makes it easier to reuse the same code in more than one program?
|
Modules
|
|
Given the following function definition, what would the statement print magic(5) display?
def magic(num): return num + 2 * 10 |
25
|
|
Which of the following statements causes the interpreter to load the contents of the random module into memory?
|
import random
|
|
Which method could be used to strip specific characters from the end of a string?
|
rstrip
|
|
A(n) ___________ access file is also known as a direct access file.
|
random
|
|
When will the following loop terminate?
while keep_on_going != 999 : |
When keep_on_going refers to a value equal to 999.
|
|
The variable used to keep the running total is called a(n) _________.
|
Accumulator
|
|
A value-returning function is ________.
|
a function that will return a value back to the part of the program that called it
|
|
What type of value is returned by the functions random and uniform?
|
float
|
|
When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string.
|
read
|
|
What do you call the process of retrieving data from a file?
|
Reading data
|
|
Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?
|
'w'
|
|
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 structure that causes a statement or a set of statements to execute repeatedly?
|
Repetition
|
|
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
|
|
__________ 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
|
|
In a value-return 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
|
|
Which method could be used to convert a numeric value to a string?
|
str
|
|
Which mode specifier will open a file but will not let you change the file or write to it?
|
'r'
|
|
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
|
|
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)
|
|
What type of function can be used to determine whether a number is even or odd?
|
Boolean
|
|
What type of file access jumps directly to any piece of data in a file without reading the data that came before it?
|
Random
|
|
Python comes with _________ functions that have been already prewritten for the programmer.
|
standard
|
|
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 step creates a connection between a file and a program?
|
Open the file.
|
|
What type of loop structure repeats the code a specific number of times?
|
Count-controlled loop
|
|
What is not an example of an augmented assignment operator?
|
<=
|
|
The Python library functions that are built into the Python ______ can be used by simply calling the function.
|
interpreter
|
|
In a menu-driven program, what statement is used to determine and carry out the user's desired action?
|
if-elif-else
|
|
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 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
|
|
The Python standard library"s _______ module contains numerous functions that can be used in mathematical calculations.
|
math
|
|
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
|
|
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
|
|
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
|
|
The randrange function returns a randomly selected value from a specific sequence of numbers.
|
True
|
|
It is possible to create a while loop that determines when the end of a file has been reached.
|
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
|
|
Reducing duplication of code is one of the advantages of using a loop structure.
|
True
|
|
In Python, an infinite loop usually occurs when the computer accesses the wrong memory address.
|
False
|
|
Unlike other languages, in Python the number of values a function can return is limited to one.
|
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 nothing that can be done if the program tries to access a file to read that does not exist.
|
False
|
|
The first line in the while loop is referred to as the condition clause.
|
False
|
|
A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program.
|
True
|
|
Closing a file disconnects the communication between the file and the program.
|
True
|
|
An exception handler is a piece of code that is written using the try/except statement.
|
True
|