Midterm Test Flashcards

1
Q

The math.sqrt() function can compute the square root of a negative number.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The central processing unit (CPU) is the “eyes” of a computer.

A

False -it is the brain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The bool data type embodies the mathematical concept of a real number.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

An algorithm is a step by step set of directions that is independent of the programming language.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Information that is stored and manipulated by computers is called pipen.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Aliasing occurs when two variables refer to the same object.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Since floating point numbers are extremely accurate, they should generally be used instead of integers.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A single point on a graphics screen is called a bit.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Using eval can make your program insecure as a user could type malicious code and eval will execute it.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Python functions can never modify a parameter.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In the code

celsius = (fahrenheit * 9/5) + 32

celsius is an example of a(n)

A

Variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

In Python, the function heading begins with _______ and ends with a ________.

A

def ….. colon(:)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the set of values provided by this expression:

range(15, 3, -3)

A

{15,12,9,6}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the fundamental question of computer science?

A

What can be computed?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In Python, a “setFill” method that has the argument color_rgb(255,0,0) would set the object’s fill color to what color?

A

red

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What graphics class would be best for drawing a square?

A

Rectangle

17
Q

In order to use functions in the math library, a program must include:

A

An import statement

18
Q

Given a = “What a great test”, a[4:-2] is

A

’ a great te’

19
Q

In the code:

point1 = Point(5, 5)

p is a(n)

A

instance of the class Point

20
Q

What value does the __name__ variable get assigned when a Python module is run directly?

A

‘__main__’

21
Q

Given the following Python code, what value(s) are output?

thisString = “spam_and_eggs”
print(len(thisString))

A

13

22
Q

Given the following Python code, what value(s) are output?

a = 42.4345
a = round(a*10)/10
print(“The number is “ + str(a))

A

The number is 42.4

23
Q

Given the following Python code, what values are output?

thisString = “Hello World!”
for ch in thisString:
print(ch, end=” “)

A

H e l l o W o r l d !

24
Q

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.

A

scoreA >= 11 and scoreA - scoreB >= 2

25
Q

Write an expression that will evaluate True if a variable word ends in “ing”

A

word[-3:] == “ing”