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

Quiz: The collections Module · Question 7 of 10

How do you get a changed copy of a namedtuple s with a new cgpa?

How do you get a changed copy of a namedtuple s with a new cgpa?

  1. A.s.cgpa = 9.1
  2. B.s._replace(cgpa=9.1)
  3. C.s.update(cgpa=9.1)
  4. D.namedtuple.set(s, "cgpa", 9.1)
Answer & explanation

Correct answer: s._replace(cgpa=9.1)

_replace returns a new tuple because the original is immutable.

Can you get the rest right without peeking?

Take the timed Quiz: The collections Module quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →