🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: How AI Coding Assistants Work: all 10 questions

Quiz: How AI Coding Assistants Work · Question 9 of 10

What does this print? (code)

What does this print?

def average_marks(marks):
    if not marks:
        return 0.0
    return sum(marks) / len(marks)

print(average_marks([]), average_marks([80, 90]))
  1. A.Error: division by zero
  2. B.0.0 85.0
  3. C.0 85
  4. D.None 85.0
Answer & explanation

Correct answer: 0.0 85.0

The guard for an empty list is the decision you, not the AI, must make.

Can you get the rest right without peeking?

Take the timed Quiz: How AI Coding Assistants Work quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →