_________________________________________________________
Q.1. Naming convention of a module of a python file is ?
1.
2.
3.
4.
Q.2. 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 ?
1.
2.
3.
4.
ANSWER :- (4) Here it uses import fuction which imports the file from another location and thus by using it we can use functions of that imported file thus here it will print hello without quotes from imported file.
_________________________________________________________
Q.3.
class hello:
def __init__(self,a='Visit Prutor.ai website'):
self.a=a
def display(self):
return 0
obj=hello()
print( obj.display() )
class hello:
def __init__(self,a='Visit Prutor.ai website'):
self.a=a
def display(self):
return 0
obj=hello()
print( obj.display() )
1.
2.
3.
4.
ANSWER :- (2) Here constructor will set the value of variable given and then execute print(obj.display()) fuction and then return 0 will be executed which gives 0 as output on the screen.
_________________________________________________________
Q.4.
class test:
def __init__(self,x=''):
self.x=x
def display(self):
print(self.x)
obj=test()
obj.display()
1.
2.
3.
4.
ANSWER :- (1) Here full program will be executed normally with no errors but display blank screen as output as here nothing is given in input.
_________________________________________________________
👀👀👀 NEXT QUIZ COMMING SOON STAY UPDATED.......👀👀👀
only at : - hi-tutorial.blogspot.com
_________________________________________________________
Comments
Post a Comment