Check your understanding of the previous reading: the parts of an if statement, valid conditionals, and event handling.

Question 1

What are the two main components of an if statement?

Select one answer, then check.

  • Correct. The reading names these as the two essential parts: the conditional (the expression after the if keyword) and the body.
  • Not quite. The reading never calls the second part a "consequence"; it is the body.
  • Not quite. The reading describes the conditional as being "like" a question, but its name is the conditional.
  • Not quite. Neither "question" nor "consequence" is the term the reading uses for these two parts.

Question 2

Which of the following is NOT a valid conditional?

Select one answer, then check.

  • Correct. An assignment is a statement, not an expression, so it can never appear after the if keyword; if x = 5: is a syntax error.
  • Not quite. A boolean value is exactly what a conditional is supposed to be.
  • Not quite. The reading gives this as its example of a valid conditional.
  • Not quite. These are valid conditionals too; thanks to Truthiness they are simply the values that evaluate to False.