A check that changes the log

The function below records one sensor reading. Python's list.append adds an entry and returns None. Consider two separate calls, each starting with an empty list: one with assertions enabled and one running under -O, which removes assertions. Select every correct statement.


Python
def record_reading(log, value):
    assert log.append(value) is None, "append failed"
    return len(log)
Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Exceptions and Assertions Questions: