20 Questions

Python Quiz

1 :-

A keyword

 

2 :-

What is true about Object-Oriented Programming in Python?

 

3 :-

What is the expected output of the following snippet?

i = 5

while i>0

i = i //2

if i % 2 = 0

     break

else :

   i + = 1

    print (i)

4 :-

What is the expected behavior of the following code?

the _ list = “alpha ; beta; gamma”.split (":")

the  string ='' .join(the _list)

print (the_string.isaplpha())

5 :-

What arithmetic operators cannot be used with strings in Python?

6 :-

Which of the following statements are true?

 

7 :-

Assuming that the V variable holds an integer value to 2, which of the following operators should be used instead of OPER to make the expression equal to 1?

V OPER 1

8 :-

The following expression

1 +-2

is:

9 :-

Python’s built in function named open () tries to open a file and returns:

 

10 :-

What is the expected behavior of the following code?

my _ list = [ i for i in range ( 5)]

m= [ my  list [i] for i in range ( 4, 0,-1)] if my _ list [i] & 2 !==0]

print (m)

 

11 :-

What will be the value of the i variable when the while e loop finishes its execution?

           i = 0

While i ! = 0 :

          i = i-i

else :

       i = i + 1

12 :-

8. The default value of "position" attribute is _________.

13 :-


14. Which of the following HTML attribute is used to define inline styles?

14 :-

Which of the following lines of code will work flawlessly when put independently inside the add_new() method in order to make the snippet’s output equal to [0, 1, 2]?

class my class:

def ___ init___(self, size):

self.queue = [ i for i in range( size )]

def get ( self ):

    return self . queue

def get ___ last( self):

   return self . queue[-1]

def add new ( self):

    # insert the line of code here

object = my class 2

object . add_ new()

print ( object. get())

15 :-

What is the expected behavior of the following code?

m = 0

def foo (n):

       global m

       assert m ==0

       try :

             return 1/n

       except arithmeticerror:

              m +=1

              raise

try :

     foo (0)

  except arithmetic error

       m +=2

except :

      m+=1

print (m)

16 :-

Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True?

class A:

     vara = 1

     def ____init ____( self) :

      self . Prop___ a = 1

class B  ( A):

        vara = 2

def ____init____( self):

super ().___int____()

self. Prop___ b= 2

 

obj __a =A()

obj__aa =A ()

obj__b = B ()

obj__bb =obj__b

 

17 :-

What can you deduce from the line below?

x= a.b.c.f ()

18 :-

What is the output of the following piece of code?

 a = ‘ ant ’

 b ="bat"

 c='camel'

 print (a,b,c,sep='"')

19 :-

Python strings can be “glued" together using the operator:

20 :-

A class constructor

Mock Test Completion Certificate
You scored 0 out of 20 questions.

🏅

For your extraordinary service and contributions to your profession.
We are delighted in providing this certificate to you.

Tips for improving your score:

  • Make sure to read the questions and answer choices carefully.
  • Don't try to answer any choices that you don't know. It's better to skip a question.