Questions and Answers14
How can polymorphism be achieved in Python? - ANSWERS-By using default parameter values
in methods and through inheritance and method overriding
What is encapsulation? - ANSWERS-A process of wrapping variables and methods into a single
entity
Which of the following is true about private variables in Python? - ANSWERS-They start with
two underscores __
What does operator overloading allow in Python? - ANSWERS-Redefining existing operators to
work with user-defined objects
What is a correct way to implement operator overloading for +? - ANSWERS-Defining a __add__
method in your class
Which access modifier indicates a protected member in Python? - ANSWERS-_ (single
underscore)
Which statement is true about encapsulation in Python? - ANSWERS-It relies on the
programmer's discipline rather than language enforcement
How can you achieve method overloading in Python? - ANSWERS-Using default parameter
values and *args, **kwargs for dynamic argument passing
, What is the purpose of the __eq__ method in Python? - ANSWERS-To check the equality of two
objects based on their content
T/F: The readlines() method returns the entire content of the file as a single string. - ANSWERS-
False. It returns a list of lines.
T/F: Python was created by Guido van Rossum in the late 1980s - ANSWERS-True
T/F: Python is a low-level programming language focusing primarily on system operations and
memory management. - ANSWERS-False. Python is a high-level programming language
T/F: Pythons syntax allows programmers to write programs with fewer lines than some other
programming languages - ANSWERS-True
T/F: Python is only suitable for web development and cannot be used in data science -
ANSWERS-False. Python is widely used in web development, data science, machine learning,
and more.
Python is a proprietary software, and obtaining it requires a purchase. - ANSWERS-False. Python
is open-source
T/F: In python, variables must be declared before they are assigned a value. - ANSWERS-False.
Python does not require explicit variable declarations before assignment
T/F: The assignment operator in Python is == - ANSWERS-False. The assignment operator in
Python is =
T/F: Python variables are case-sensitive. - ANSWERS-True