Midterm Test Flashcards
The math.sqrt() function can compute the square root of a negative number.
False
The central processing unit (CPU) is the “eyes” of a computer.
False -it is the brain
The bool data type embodies the mathematical concept of a real number.
False
An algorithm is a step by step set of directions that is independent of the programming language.
True
Information that is stored and manipulated by computers is called pipen.
False
Aliasing occurs when two variables refer to the same object.
True
Since floating point numbers are extremely accurate, they should generally be used instead of integers.
False
A single point on a graphics screen is called a bit.
False
Using eval can make your program insecure as a user could type malicious code and eval will execute it.
True
Python functions can never modify a parameter.
False
In the code
celsius = (fahrenheit * 9/5) + 32
celsius is an example of a(n)
Variable
In Python, the function heading begins with _______ and ends with a ________.
def ….. colon(:)
What is the set of values provided by this expression:
range(15, 3, -3)
{15,12,9,6}
What is the fundamental question of computer science?
What can be computed?
In Python, a “setFill” method that has the argument color_rgb(255,0,0) would set the object’s fill color to what color?
red
What graphics class would be best for drawing a square?
Rectangle
In order to use functions in the math library, a program must include:
An import statement
Given a = “What a great test”, a[4:-2] is
’ a great te’
In the code:
point1 = Point(5, 5)
p is a(n)
instance of the class Point
What value does the __name__ variable get assigned when a Python module is run directly?
‘__main__’
Given the following Python code, what value(s) are output?
thisString = “spam_and_eggs”
print(len(thisString))
13
Given the following Python code, what value(s) are output?
a = 42.4345
a = round(a*10)/10
print(“The number is “ + str(a))
The number is 42.4
Given the following Python code, what values are output?
thisString = “Hello World!”
for ch in thisString:
print(ch, end=” “)
H e l l o W o r l d !
Write an expression that will evaluate True if player A has won a table tennis game and False otherwise.
Assume there are two variables scoreA and scoreB which keep track of the score for two players, player A and player B respectively. The game is won when a player has at least 11 points and is leading by at least two points.
scoreA >= 11 and scoreA - scoreB >= 2
Write an expression that will evaluate True if a variable word ends in “ing”
word[-3:] == “ing”