PYTHON QUIZ DESCRIPTION

Which of the following is the use of id() function in python?

  • Every object doesn’t have a unique id
     

  •  Id returns the identity of the object
     

  •  All of the mentioned
     

  • None of the mentioned

What will be the output of the following Python code?
i = 1
while True:
    if i%3 == 0:
        break
    print(i)
 
    i + = 1

  • 1 2 3

  • error

  • none of the mentioned

  • 1 2

Which of the following is not a core data type in Python programming?
 

  • Tuples
     

  •  Lists
     

  • Class
     

  • Dictionary

Which module in the python standard library parses options received from the command line?

  • getarg
     

  •  getopt
     

  •  main
     

  •  os
     

Is Python code compiled or interpreted?

  • Python code is both compiled and interpreted
     

  •  Python code is neither compiled nor interpreted
     

  •  Python code is only compiled
     

  •  Python code is only interpreted

Which one of the following is not a keyword in Python language?
 

  • pass
     

  •  eval
     

  • assert
     

  •  nonlocal

What will be the output of the following Python program?
z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
z

  • {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}
     

  • {‘abc’, ‘p’, ‘q’, ‘san’}
     

  •  {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
     

  •  {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
     

Which one of the following is the use of function in python?
 

  • Functions don’t provide better modularity for your application
     

  • you can’t also create your own functions
     

  •  Functions are reusable pieces of programs
     

  • All of the mentioned
     

Which of the following functions is a built-in function in python?

  • factorial()
     

  •  print()
     

  •  seed()
     

  •  sqrt()
     

 Which of the following is used to define a block of code in Python language?

  •  Indentation
     

  •  Key
     

  •  Brackets
     

  • All of the mentioned

What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
    print(i)

 

  • error
     

  •  1 2 3 4
     

  •  a b c d
     

  •  0 1 2 3

Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]

 

  • A[2][1]
     

  •  A[1][2]
     

  • A[3][2]
     

  •  A[2][3]
     

Is Python case sensitive when dealing with identifiers?

  • no
     

  • yes
     

  • machine dependent
     

  •  none of the mentioned
     

What are the values of the following Python expressions?
 2**(3**2)
 (2**3)**2
 2**3**2

  • 512, 64, 512
     

  •  512, 512, 512
     

  • 64, 512, 64
     

  •  64, 64, 64

What will be the output of the following Python code snippet if x=1?
x<<2

 

  • 4

  • 2

  • 1

  • 8

 What will be the output of the following Python expression if x=56.236?
print("%.2f"%x)

  • 56.236
     

  • 56.23
     

  •  56.0000
     

  • 56.24

Which of these is the definition for packages in Python?
 

  • A set of main modules
     

  •  A folder of python modules
     

  •  A number of files containing Python definitions and statements
     

  •  A set of programs making use of Python modules

What will be the output of the following Python code?
class tester:
def __init__(self, id):
self.id = str(id)
id="224"
temp = tester(12)
print(temp.id)

  • 12

  • 224

  • None

  • Error

What arithmetic operators cannot be used with strings in Python?

  • +

  • _

  • *

  • All the mentioned

Who developed Python Programming Language?

  • Wick van Rossum
     

  • Rasmus Lerdorf
     

  •  Guido van Rossum
     

  • Niene Stom

Python supports the creation of anonymous functions at runtime, using a construct called __________

  • pi
     

  •  anonymous
     

  •  lambda
     

  • none of the mentioned

What will be the output of the following Python code?
print("abc. DEF".capitalize())

  • Abc. def
     

  • abc. def
     

  •  Abc. Def
     

  •  ABC. DEF

What will be the output of the following Python program?
i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)

  • error

  • 0 1 2 0

  • 0 1 2

  • none of the mentioned
     

What will be the output of the following Python program?
def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

 

  • Error

  • None

  • false

  • True

What will be the output of the following Python statement?
"a"+"bc"

 

  • bc

  • abc

  • a

  • bca

Which of the following character is used to give single-line comments in Python?

  • //

  • #

  • !

  • /*

Which of the following is the truncation division operator in Python?

  • |
     

  •  //
     

  • /
     

  •  %

Which of the following is the correct extension of the Python file?

  •  .python
     

  • .pl
     

  • .py
     

  •  .p

To add a new element to a list we use which Python command?
 

  • list1.addEnd(5)
     

  •  list1.addLast(5)
     

  •  list1.append(5)
     

  •  list1.add(5)

What will be the output of the following Python code snippet?
for i in [1, 2, 3, 4][::-1]:
    print (i)

  • 4 3 2 1
     

  •  error
     

  • 1 2 3 4
     

  •  none of the mentioned