Exam Questions for Chapters 12 and 13¶
The following questions test what you have learned in chapters 12 to 13. Click the “Start” button when you are ready to begin the exam. Click the “Pause” button to pause the exam (you will not be able to see the questions when the exam is paused). It will show how much time you have used, but you have unlimited time. Click on the “Finish Exam” button at the end when you are done. The number correct, number wrong, and number skipped will be displayed at the bottom of the page. Feedback for each answer will also be shown as well as your answer.
You will not be able to change your answers after you hit the “Finish Exam” button.
- 5 to 20
- This would be true if it was if x >= 5 and x <= 20:
- 6 to 20
- This would be true if it was if x > 5 and x <= 20:
- 5 to 19
- It will print "condition true" when x is greater than or equal to 5 and less than 20.
- 6 to 19
- This would be true if it was if x > 5 and x < 20:
- A
- This would be true if the score was greater than or equal to 90
- B
- Since the score is less than 90 and greater than or equal to 80 "B" will print.
- C
- This would be true if the score was less than 80 and greater than or equal to 70.
- D
- This would be true if the score was less than 70 and greater than or equal to 60.
- E
- This would be true if the score was less than 60.
- 3
- This will print several things.
- 25
- This will only print "You will ace a test"
- 45
- This will only print "You will meet a new friend"
- 10
- This will only print "You will catch a cold"
- I
- This would always set x to 0 but if x was 1 in the original code it would not change.
- II
- If x is greater than 4 it is reset to 0 in the original code.
- III
- Anytime x is greater than 2 it will be set to 0 in the original code.
- IV
- What if x is negative in the original code?
- A
- This would be true if the 2nd - 4th if were elif instead.
- B
- This would be true if the score was 83 and the 2nd - 4th if were elif instead.
- C
- This would be true if the score was 73 and the 2nd - 4th if were elif instead.
- D
- Since it is true that 93 is greater than 60 this will set grade to "D"
- E
- This would be true if score was less than 60.
csp-13-8-1: Given the code below, what describes the values of x that will cause the code to print “condition true”?
if x >= 5 and x < 20:
print ("condition true")
print ("All done")
csp-13-8-2: What is printed when the following code executes?
score = 88
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "E"
print(grade)
csp-13-8-3: For what value of num will the following print only “You will meet a new friend.”?
if num < 5 or num > 50:
print("You will get a treat.")
if num == 5 or num < 0:
print("You will lose something.")
if num < 10 or num > 40:
print("You will meet a new friend.")
if num < 20 or num > 60:
print("You will catch a cold.")
if num >= 20 and num <= 30:
print("You will ace a test.")
csp-13-8-4: Which of the following is equivalent to the code segment below?
if x > 2:
x = x * 2
if x > 4:
x = 0
I. x = 0
II. if x > 2:
x = x * 2
III. if x > 2:
x = 0
IV. if x > 2:
x = 0
else:
x = x * 2
csp-13-8-5: What is the value of grade when the following code executes and score is 93?
if score >= 90:
grade = "A"
if score >= 80:
grade = "B"
if score >= 70:
grade = "C"
if score >= 60:
grade = "D"
else
grade = "E"