PYTHON QUIZ DESCRIPTION

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
     

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

What will be the output of the following Python code?
print('*', "abcde".center(6), '*', sep='')

 

  •  * abcde *
     

  •  *abcde *
     

  •  * abcde*
     

  •  * abcde *

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

 

  • 4

  • 2

  • 1

  • 8

Which of the following statements is used to create an empty set in Python?
 

  •  ( )
     

  •  [ ]
     

  •  { }
     

  •  set()

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

  •  .python
     

  • .pl
     

  • .py
     

  •  .p

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

Which of the following functions can help us to find the version of python that we are currently working on?
 

  • sys.version(1)
     

  •  sys.version(0)
     

  •  sys.version()
     

  • sys.version

 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

What arithmetic operators cannot be used with strings in Python?

  • +

  • _

  • *

  • All the mentioned

What will be the output of the following Python code?
list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)

 

  •  [1, 4]
     

  •  [1, 3, 4]
     

  •  [4, 3]
     

  •  [1, 3]

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

  • |
     

  •  //
     

  • /
     

  •  %

The following python program can work with ____ parameters.
def f(x):
    def f1(*args, **kwargs):
           print("Sanfoundry")
           return x(*args, **kwargs)
    return f1

 

  • any number of

  • 1

  • 2

  • 0

Who developed Python Programming Language?

  • Wick van Rossum
     

  • Rasmus Lerdorf
     

  •  Guido van Rossum
     

  • Niene Stom

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

  • //

  • #

  • !

  • /*

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]
     

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

  • a B C D
     

  •  a b c d
     

  •  error
     

  • A B C D

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

Which function is called when the following Python program is executed?
f = foo()
format(f)

 

  • str()
     

  •  format()
     

  •  __str__()
     

  •  __format__()

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 code?
print("abc. DEF".capitalize())

  • Abc. def
     

  • abc. def
     

  •  Abc. Def
     

  •  ABC. DEF

Is Python case sensitive when dealing with identifiers?

  • no
     

  • yes
     

  • machine dependent
     

  •  none of the mentioned
     

What is the order of precedence in python?

  • Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
     

  •  Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
     

  •  Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
     

  •  Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

Which keyword is used for function in Python language?

  • Function
     

  • Def
     

  • Fun
     

  •  Define

What does pip stand for python?

  • unlimited length
     

  • all private members must have leading and trailing underscores
     

  •  Preferred Installer Program
     

  •  none of the mentioned

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?
x = 'abcd'
for i in range(len(x)):
    print(i)

 

  • error
     

  •  1 2 3 4
     

  •  a b c d
     

  •  0 1 2 3

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)

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

  • getarg
     

  •  getopt
     

  •  main
     

  •  os
     

What will be the output of the following Python function?
len(["hello",2, 4, 6])

 

  • error

  • 6

  • 4

  • 3