CSE 1010 Midterm EXPECTED QUESTIONS WITH
VERIFIED ANSWERS
Question 1.
Which of the following statements has a syntax error? Assume age and years are variables that have
already been defined.
a. age = years - 2
b. age + 2 = years
c. age = 17 - 2
d. age = -15
ANSWER
age + 2 = years
Question 2.
A language is called _____ when upper case letters in identifiers are considered different from lower
case letters.
a. unambiguous
b. case sensitive
c. case strict
d. camel case
ANSWER
case sensitive
Question 3.
Which expression using parentheses is equivalent to the following expression:
x - y * -z / 3
a. (x - y) * ((-z) / 3))
b. x - ((y * (-z)) / 3)
c. x - (y * ((-z) / 3))
d. (x - (y * (-z))) / 3
ANSWER
x - ((y * (-z)) / 3)
, Question 4.
What is the value of 11 // 2?
a. 5
b. 6
c. 0
d. -5
ANSWER
5
Question 5.
Which statement makes the code in the math module available?
a. use math
b. allow math
c. import math
d. include math
ANSWER
import math
Question 6.
Assume a and b are variables that hold the base and height of a right triangle. The length of the long
side (hypotenuse) is calculated as the square root of a^2
+ b^2. Which expression calculates the length of the hypotenuse?
a. math.square_root(a * a + b * b)
b. math.sqrt(math.pow(a * a), math.pow(b * b))
c. math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))
d. math.pow(math.sqrt(a), 2) + math.pow(math.sqrt(b), 2)
ANSWER
math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))
VERIFIED ANSWERS
Question 1.
Which of the following statements has a syntax error? Assume age and years are variables that have
already been defined.
a. age = years - 2
b. age + 2 = years
c. age = 17 - 2
d. age = -15
ANSWER
age + 2 = years
Question 2.
A language is called _____ when upper case letters in identifiers are considered different from lower
case letters.
a. unambiguous
b. case sensitive
c. case strict
d. camel case
ANSWER
case sensitive
Question 3.
Which expression using parentheses is equivalent to the following expression:
x - y * -z / 3
a. (x - y) * ((-z) / 3))
b. x - ((y * (-z)) / 3)
c. x - (y * ((-z) / 3))
d. (x - (y * (-z))) / 3
ANSWER
x - ((y * (-z)) / 3)
, Question 4.
What is the value of 11 // 2?
a. 5
b. 6
c. 0
d. -5
ANSWER
5
Question 5.
Which statement makes the code in the math module available?
a. use math
b. allow math
c. import math
d. include math
ANSWER
import math
Question 6.
Assume a and b are variables that hold the base and height of a right triangle. The length of the long
side (hypotenuse) is calculated as the square root of a^2
+ b^2. Which expression calculates the length of the hypotenuse?
a. math.square_root(a * a + b * b)
b. math.sqrt(math.pow(a * a), math.pow(b * b))
c. math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))
d. math.pow(math.sqrt(a), 2) + math.pow(math.sqrt(b), 2)
ANSWER
math.sqrt(math.pow(a, 2)) + math.pow(b, 2)))