Q1. Naming convention of a module of a python file is ?
· All names should be lower case.
· Underscore can be used.
· Should be short
· All of the above.
Ans- All of the above
Q2. The following code is saved in a file hello.py (using python 3.X version):
def print_hello():
print ("Hello")
Now consider the following interaction on Python console, assuming hello.py
is in the current directory where the console is invoked:
>>> import hello
>>> hello.print_hello()
What will be the output of the code ?
Ans- "Hello" will be printed (without quotes)
Q3. What is the output of the following python code?
class hello:
def __init__(self,a="Visit Prutor.ai website"):
self.a=a
def display(self):
return 0
obj=hello()
print( obj.display() )
Ans- 0
Q4. What is the output of the following python code?
class test:
def __init__(self,x=''):
self.x=x
def display(self):
print(self.x)
obj=test()
obj.display()
Ans- Executes normally and doesn’t display anything
Q5. What does Instantiation mean in terms of Object Oriented Programming?
· Deleting an instance of class
· Creating an instance of class
· Copying an instance of class
· Modifying an instance of class
Ans- Creating an instance of class
0 Comments