🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Unit Testing and TDD: all 10 questions

Quiz: Unit Testing and TDD · Question 4 of 10

What does this print? (code)

What does this print?

from unittest.mock import Mock

mailer = Mock()
for marks in [35, 72, 28, 90]:
    if marks < 40:
        mailer.send('parent', marks)
print(mailer.send.call_count, mailer.send.call_args.args)
  1. A.4 ('parent', 90)
  2. B.2 ('parent', 28)
  3. C.2 ('parent', 35)
  4. D.0 ()
Answer & explanation

Correct answer: 2 ('parent', 28)

Only 35 and 28 are below 40; call_args holds the most recent call.

Can you get the rest right without peeking?

Take the timed Quiz: Unit Testing and TDD quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →