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

Quiz: Refactoring with AI · Question 5 of 10

What does this print? (code)

What does this print?

def old(late_days):
    return min(late_days * 500, 5000) if late_days > 0 else 0

def new(late_days):
    return min(late_days * 500, 5000)

print(old(-2), new(-2))
  1. A.0 0
  2. B.0 -1000
  3. C.-1000 -1000
  4. D.0 5000
Answer & explanation

Correct answer: 0 -1000

The new version forgot the guard for negative input.

Can you get the rest right without peeking?

Take the timed Quiz: Refactoring with AI quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →