# 2.11. Multiple-Choice¶

The multiple-choice feature allows the student to answer a multiple-choice question and get immediate feedback. The questions can have one correct answer or multiple correct answers.

The following Python example from the Student Computer Science Principles ebook has only one correct answer. You can see it when you click the following link Multiple-Choice-One-Answer.

2-8-1: What does the following code print?

```output = ""
x = -5
while x < 0:
x = x + 1
output = output + str(x) + " "
print(output)
```
• 5 4 3 2 1
• If x starts at -5 how can the first value printed be 5?
• -5 -4 -3 -2 -1
• This would be true if the print statement was before we incremented x.
• -4 -3 -2 -1
• The value of x is incremented before it is printed so the first value printed is -4.

The following Java example from the Java Review ebook has only one correct answer. You can see it when you click on the following link Java-Ex-One-Answer.

2-8-2: What does the following code print?

```System.out.println(2 % 3);
```
• 2
• Whenever the first number is smaller than the second, the remainder is the first number. Remember that % is the remainder and 3 goes into 2 0 times with a remainder of 2.
• 0
• This is the number of times that 3 goes into 2 but the % operator gives you the remainder.
• 3
• Try it. Remember that % gives you the remainder after you divide the first number by the second one.
• 1
• This would be correct if it was 3 % 2 since 2 would go into 3 one time with a remainder of 1.

The following Python example from the How to Think Like a Computer Scientist ebook requires more than one answer to be correct. You can see it at the bottom of the page when you click the following link Multiple-Choice-Multiple-Answer.

2-8-3: Which of the following is a Boolean expression? Select all that apply.

• True
• True and False are both Boolean literals.
• 3 == 4
• The comparison between two numbers via == results in either True or False (in this case False), both Boolean values.
• 3 + 4
• 3 + 4 evaluates to 7, which is a number, not a Boolean value.
• 3 + 4 == 7
• 3 + 4 evaluates to 7. 7 == 7 then evaluates to True, which is a Boolean value.
• "False"
• With the double quotes surrounding it, False is interpreted as a string, not a Boolean value. If the quotes had not been included, False alone is in fact a Boolean value.
Next Section - 2.12. Poll