← Quiz: Reviewing AI Code: all 10 questions
Quiz: Reviewing AI Code · Question 6 of 10
What does this print? (code)
What does this print?
def add_score(score, scores=None):
scores = [] if scores is None else scores
scores.append(score)
return scores
add_score(90)
print(add_score(75))
- A.[90, 75]
- B.[75]
- C.[90]
- D.None
Answer & explanation
Correct answer: [75]
With None as the default, every call gets a fresh list.
Can you get the rest right without peeking?
Take the timed Quiz: Reviewing AI Code quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →