Python Quiz 7


 Q:1. Naming convention of a module of a python file is ?

Answer :      4.    All of the above


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()

Answer :    3.    Nothing will be printed


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())

Answer :     2.       0


Q:4. class test:

                def__init__(self,x="):

                        self.x=x

                def display(self):

                        print(self.x)

       obj=test()

       obj.display()

Answer :   1.      Execute normally and does not display anything


Q:5. What does Instantiation mean in terms of object oriented programming?

Answer :    2.     Creating an instance of  class








No comments:

Post a Comment