Question - 1
The process of pickling in Python includes ____________.
- conversion of a Python object hierarchy into byte stream
- conversion of a byte stream into Python object hierarchy
- conversion of a list into a datatable
- conversion of a datatable into a list
Solutions
Answer- A
Question - 2
To open a file c:\scores.txt for reading, we use _____________.
- infile = open(“c:scores.txt”, “r”)
- infile = open(“c:\scores.txt”, “r”)
- infile = open(file = “c:scores.txt”, “r”)
- infile = open(file = “c:\scores.txt”, “r”)
Solutions
Answer- B
Question - 3
Which function overloads the + operator?
- __add__()
- __plus__()
- __sum__()
- None of these
Solutions
Answer- A
Question - 4
Which operator is overloaded by __invert__()?
Answer- B
Question - 5
_____ represents an entity in the real world with its identity and behavior.
- A method
- An object
- A class
- An operator
Solutions
Answer- B
Question - 6
_____ is used to create an object.
- class
- constructor
- User-defined functions
- In-built functions
Solutions
Answer- B
Question - 7
What is setattr() used for?
- To access the attribute of the object
- To check if an attribute exists or not
- To delete an attribute
- To set an attribute
Solutions
Answer- B
Question - 8
class test:
def __init__(self,a):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
What will be the output of the following Python code?
- Runs normally, doesn’t display anything
- Displays 0, which is the automatic default value
- Error as one argument is required while creating the object
- Error as display function requires additional argument
Solutions
Answer- C
Question - 9
What is Instantiation in terms of OOP terminology?
- Deleting an instance of class
- Creating an instance of class
- Modifying an instance of class
- Copying an instance of class
Solutions
Answer- B
Question - 10
The assignment of more than one function to a particular operator is _______.
- Operator over-assignment
- Operator overriding
- Operator instance
- Operator overloading
Solutions
Answer- D
Question - 11
What error will occur when you execute the following code?
MANGO = APPLE
- NameError
- SyntaxError
- TypeError
- ValueError
Solutions
Answer- A
Question - 12
What will be the output of this program?
print(6 + 5 - 4 * 3 / 2 % 1)
Answer- D
Question - 13
Which of the following arithmetic operators cannot be used with strings in python?
Answer- C
Question - 14
Which of the following statements is valid for the "if statement"?
- if f >= 12:
- if (f >= 122)
- if (f => 1222)
- if f >= 12222
Solutions
Answer- A
Question - 15
Which of the following blocks allows you to test the code blocks for errors?
- try block
- except block
- finally block
- None of the above
Solutions
Answer- A
Question - 16
Which of the following functions returns a list containing all matches?
- find
- findall
- search
- None of the above
Solutions
Answer- B
Question - 17
In the Python Programming Language, syntax error is detected by ______ at _________.
- Interpreter / Compile time
- Run time / Interpreter
- Interpreter / Run time
- Compile time / Run time
Solutions
Answer- C
Question - 18
Which of the following blocks allows you to handle the errors?
- except block
- try block
- finally block
- None of these
Solutions
Answer- A
Question - 19
word="javatpoint"
print(*word)
What will be the output of this program?
- javatpoint
- j a v a t p o i n t
- *word
- SyntaxError: invalid syntax
Solutions
Answer- B
Question - 20
What is hasattr(obj,name) used for?
- To access the attribute of the object
- To delete an attribute
- To set an attribute
- To check if an attribute exists or not
Solutions
Answer- D
Practice more set questions