Python Midterm
In Python the __________ symbol is used as the not-equal-to operator.
!=
The remainder of an integer division is accomplished using the ____________ operator.
%
Which mathematical operator is used to raise 5 to the second power in Python?
**
Given str1 = Life, the universe and everything. what does str1.find( rev ) return?
-1
Integer division is accomplished using the ____________ operator.
//
What are the valid indexes for the string 'New York'?
0 through 7
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
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 is the decimal value of the following binary number? 10011101
157
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
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.0
What is the largest value that can be stored in one byte?
255
After the execution of the following statement, the variable price will reference the value __________. price = int(68.549)
68
A function header must end with a(n) _________.
:
Which of the following is not an augmented assignment operator?
<=
In Python the __________ symbol is used as the equal operator.
==
The __________ coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory.
ASCII
Why do programmers use top-down design and structured programming?
All of the above
What type of function can be used to determine whether a number is even or odd?
Boolean
Which of the following is the correct if clause to determine whether choice is anything other than 10?
Correct if choice != 10:
The following expression is valid: string[i] = 'i'
False
True or False: The third argument of the range function specifies the upper bound of the count.
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 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
Python has an object called _________ that is used to denote a lack of value.
None
What type of volatile memory is usually used only for temporary storage while running a program?
RAM
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
What is the output of the following print statement? print('The path is D:\\sample\\test.')
The path is D:\sample\test.
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
The index -1 identifies the last character of a string
True
The index -1 identifies the last character of a string.
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
What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? x < y or z > x
True
Python was originally implemented on ________________.
UNIX.
The line continuation character is a
\
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
What symbol is used to mark the beginning and end of a string?
a quote mark (")
A variable used to keep a running total is called a(n)
accumulator
The arguments in a function call are called _________ parameters.
actual
A comma in the print statement notifies Python to:
add a space after a string rather than begin a new line.
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
A compound Boolean expression created with the ___________ operator is TRUE only if both of its subexpressions are TRUE.
and
In the split method, if no separator is specified, the default is ____________.
any whitespace character
In a function call, the items inside parentheses are called _________.
arguments
A statement of the form variableName = numericExpression is called a(n) ____________.
assignment statement
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
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
The ____________ statement causes an exit from anywhere in the body of a loop.
break
An error is a program is called a(n) _______________.
bug
Writing Python statements is called _______________.
coding
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
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
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
What type of loop structure repeats the code a specific number of times?
count-controlled loop
Functions that do not return values _________.
do not have return statements
The decision structure that has two possible paths of execution is known as
dual alternative
In Python, string literals are surrounded by
either a or b
When an if-else statement needs to allow for more than two possible alternatives, you use a(n) ____________ clause.
elif
Which method would you use to determine whether a certain substring is the suffix of a string?
endswith(substring)
When a function is called by its name during the execution of a program, then it is
executed
The process known as the __________ cycle is used by the CPU to execute instructions in a program.
fetch-decode-execute
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
Which method would you use to determine whether a certain substring is present in a string?
find(substring)
A ____________ is a Boolean-valued variable used to report whether a certain circumstance has occurred.
flag
After the execution of the following statement, the variable sold will reference the numeric literal value as (n) __________ data type. sold = 256.752
float
A variable that can be recognized everywhere in the program is called a _________ variable.
global
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
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:
The __________ operator can be used to determine whether one string is contained in another string.
in
Each character in a string has a(n) __________ which specifies its position in the string.
index
A(n) ___________ loop usually occurs when the programmer does not include code inside the loop that makes the test condition false.
infinite
The __________ built-in function is used to read a number that has been typed on the keyboard.
input()
_________ 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
Function parameters have _________ scope.
local
and, or, and not are _________________ operators.
logical
The following is an example of an instruction written in which computer language? 1011 00010
machine language
When one loop is contained in the body of another loop, it is said to be ____________.
nested
Which logical operators perform short-circuit evaluation?
or, and
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
In a function definition, the parameters without default values must _________ the parameters with default values.
precede
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
A sequence of instructions is called a(n) _______________ .
program
The function call produces the same sequence as range( 10 ).
range( 0, 10, 1 ).
A(n) __________ structure is a structure that causes a statement or a set of statements to execute repeatedly.
repetition
A function is said to _________ its output.
return
Modules are __________________.
reusable pieces of software
The benefit of object-oriented programming is that it is
reusable. easy to understand. easy to update.
The _________ of a variable is the portion of the program that can refer to it.
scope
When Python stops evaluating a compound condition with the logical and operator because a condition evaluates to False, it is called ____________evaluation.
short-circuit
A sequence of consecutive characters from a string is called a(n) ____________.
slice
Computer programs are referred to as _______________ .
software
Programs are commonly referred to as
software
Instructions in a Python program are called _______________.
source code
An operator is a
special symbol that performs a specific operation.
Comments are useful for
specifying the intent of the program
Which method turns a single string into a list of substrings?
split
The interval between the numbers used in the range is known as which of the following?
step value
Which type of error prevents the program from running?
syntax
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
When referencing a substring such as str1[m:n] if m ? n then the value will be ____________.
the empty string
What is the return value of the string method lstrip()?
the string with all leading whitespaces removed
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
The encoding technique used to store negative numbers in the computer's memory is called _____.
two's complement
An object s identifies the kind of information contained in the object.
type
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
What Python loop repeatedly executes a block of statements as long as a certain condition is met?
while
What does the following expression mean? x <= y
x is less than or equal to y
Python programs can enclose strings in quotes.
All of the above.
What advantage is there to using functions in programming?
All of the above.
Which computer language uses short words known as mnemonics for writing programs?
Assembly
Which language is referred to as a low-level language?
Assembly language
Python is used with the ____________________ (CGI) for programming Web-based applications.
Common Gateway Interface
A combination of numbers, arithmetic operators, and parentheses that can be evaluated is called a numeric ____________.
expression
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
The parameters in a function definition are also called _________ parameters.
formal
When Python removes an orphaned object from memory, it is called ____________.
garbage collection
The first line in a function definition is known as the function
header
To gain access to the functions and variables of a library module, use a(n) _________ statement.
import
Where does a computer store a program and the data that the program is working with while the program is running?
in main memory
Using a while loop to ensure a proper response is received from a request is called ____________.
input validation
The Python library functions that are built into the Python __________ can be used by simply calling the required function.
interpreter
The following statement is an example of _________. [int(num) for num in listOfNums]
list comprehension
In programming terminology, numbers are called numeric ____________.
literals
A variable created inside a function is called a _________ variable.
local
Which standard library module contains trigonometric, exponential, and logarithmic functions?
math
When an if-else statement contains other if-else statements, it is said to be ____________.
nested
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
When an if-elif-else statement is evaluated, which block of statements is evaluated?
the first condition satisfied
If two variables with the same name are created in two different functions _________.
they have no relationship to each other.