Subject / 421 questions

Programming MCQs

Page 10 of Programming multiple-choice questions with answers. Tap an option to check yourself.

Page 10 of 22

Question 181 Python

What is the role of the __init__ method in a Python class?

Correct answer C. It initialises a newly created instance, typically setting its attributes

Open question
Question 182 Python

How does a @staticmethod differ from a @classmethod in Python?

Correct answer B. A static method receives no implicit first argument, while a class method receives the class as cls

Open question
Advertisement
Question 186 Python

What is the effect of decorating a method with @property?

Correct answer B. The method can be accessed like an attribute, without parentheses

Open question
Question 189 Python

Which values can random.randint(1, 6) return?

Correct answer D. Any integer from 1 to 6, including both 1 and 6

Open question
Advertisement
Advertisement