Week 4 Quiz
The reading log asks two questions. What does this program print, line by line?
goal = 300 pages_read = 45 print(pages_read >= goal) print(pages_read != 45)Select one.
- False False
- True False
- False True
- True True
== compares values. What does this line print?
print(3 == 3.0, "3" == 3)Select one.
- True True
- False False
- False True
- True False
A truth table lists its rows as a, b in the order True True, True False, False True, False False. On which row does a or b give False?
Select one.
- True True
- True False
- False True
- False False
Work it out in Python's order. What does this line print?
print(True or False and False)Select one.
- False
- True
- None
- SyntaxError
The expression not a or b is worked out down the four rows of a truth table (a, b = True True, True False, False True, False False). Which list gives its value on each row, in order?
Select one.
- True, False, True, True
- False, False, False, True
- False, True, True, True
- True, True, False, True
What does the reading log's Week 4 stage print?
goal = 300 pages_read = 45 if pages_read >= goal: print("Goal met") elif pages_read >= goal // 2: print("Halfway or better") else: print("Keep going")Select one.
- Goal met
- Halfway or better
- Keep going
- Halfway or better, then Keep going
Trace the chain from the top. What does this program print?
x = 7 if x > 10: print("big") elif x > 5: print("medium") else: print("small")Select one.
- big
- medium
- small
- medium, then small
What happens when you run this program?
x = 5 if x = 5: print("yes")Select one.
- It prints yes.
- Nothing runs, and the error names SyntaxError.
- It prints nothing and shows no error.
- It prints yes, then the error names TypeError.
Select every statement that is true about this program.
total = 95 if total >= 60: print("D or better") elif total >= 90: print("A") else: print("F")Select every option that applies.
- It prints D or better.
- It has a logic error.
- It has a syntax error.
- Moving the total >= 90 test first makes it print A.
- It prints D or better and then A.
True or false: this line prints False True.
print(bool(""), bool("0"))True or false.
- True
- False
Built with The Course Maker · samples.thecoursemaker.com