PYTHON-3 QUIZ DESCRIPTION

Study the following program:
i = 1:  
while True:  
    if i%3 == 0:  
        break  
    print(i)  
Which of the following is the corre

  • 1 2 3
     

  • 3 2 1
     

  •  1 2
     

  •  Invalid syntax

What will be the output of the following Python expression?
round(4.576)

 

  • 4

  • 4.6

  • 5

  • 4.5

Study the following statements:
str1 = "javat"  
str2 = ":"  
str3 = "point"  
str1[-1:]  
What will be the output of this statement?

  • t

  • j

  • point

  • java

What will be the output of the following Python code?
def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
prin

  • error, there is more than one return statement in a single try-finally block

  • 3

  • 2

  • 1

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

  • Every object in Python doesn’t have a unique id
     

  •  In Python Id function returns the identity of the object
     

  • None of the mentioned
     

  • All of the mentioned
     

Study the following program:
class Std_Name:   
    def __init__(self, Std_firstName, Std_Phn, Std_lastName):  
        self.Std_firstName = Std_firstName  
  &n

  • Ann Bob
     

  • Ann Nick
     

  • Wick Bob
     

  •  Wick Nick

Study the following program:
x = 1  
while True:  
    if x % 5 = = 0:  
        break  
    print(x)   
    x + = 1  

  • error
     

  •  b2 1
     

  •  0 3 1
     

  • None of these

What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x))),))

  • 01
     

  •  [0] [1]
     

  •  (’01’)
     

  •  (‘[0] [1]’,)
     

Study the following program:
i = 0  
while i < 3:  
    print(i)  
    i += 1  
else:  
    print(0)  
What will be the output of th

  • 0 1
     

  • 0 1 2
     

  •  0 1 2 0
     

  •  0 1 2 3
     

What is output of print(math.pow(3, 2))?
 

  • 9.0
     

  • None
     

  •  9
     

  •  None of the mentioned
     

Study the following code:
"javatpoint"[5:]  
What will be the output of this code?

  •  javatpoint
     

  • java

     

  • point
     

  •  None of these
     

Which of the following is correctly evaluated for this function?
pow(x,y,z)  
(x**y) / z

  •  (x / y) * z
     

  •  (x**y) % z
     

  • (x / y) / z

     

  •  (x / y) * y
     

Which of the following is a Python tuple?
 

  • {1, 2, 3}
     

  •  {}
     

  • [1, 2, 3]
     

  •  (1, 2, 3)

What is output of print(math.pow(3, 2))?
 

  • 9.0
     

  •  None
     

  •  9

     

  • None of the mentioned
     

Study the following program:
a = 1  
while True:  
    if a % 7 = = 0:  
        break  
    print(a)  
    a += 1  

  • 1 2 3 4 5
     

  • 1 2 3 4 5 6
     

  •  1 2 3 4 5 6 7
     

  • Invalid syntax

What is output of print(math.pow(3, 2))?

  • 9.0
     

  • None
     

  • 9
     

  • None of the mentioned

Which of the following is a Python tuple?

  •  {1, 2, 3}
     

  •  {}

     

  •  [1, 2, 3]

     

  •  (1, 2, 3)
     

What will be the output of the following Python code?
x = [[0], [1]]
print((' '.join(list(map(str, x))),))

  • 01
     

  • [0] [1]
     

  •  (’01’)
     

  •  (‘[0] [1]’,)

What will be the output of the following Python code snippet?
z=set('abc$de')
'a' in z

  • Error
     

  • True
     

  •  False
     

  •  No output

Study the following statements:
print(0xA + 0xB + 0xC)  
What will be the output of this statement?

  • 33

  • 63

  • 0xA + 0xB + 0xC
     

  • None of these

Study the following code:
x = ['XX', 'YY']  
for i in a:  
i.lower()  
print(a)  
What will be the output of this program?

 

  •  ['XX', 'YY']
     

  •  ['xx', 'yy']
     

  •  [XX, yy]
     

  •  None of these
     

Which of the following is a feature of Python DocString?

  • In Python all functions should have a docstring

     

  • Docstrings can be accessed by the __doc__ attribute on objects

     

  • It provides a convenient way of associating documentation with Python modules, functions, classes, and methods

     

  •  All of the mentioned
     

Study the following program:
class book:  
    def __init__(a, b):  
        a.o1 = b  
   
class child(book):  
    def __init__(a,

  • 32
     

  • 32 32
     

  • 32 None
     

  • Error is generated

Study the following function:

round(4.576)  
What will be the output of this function?

 

  • 4
     

  •  5
     

  •  546
     

  • 5.0

Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?
 

  • Infile = open(''d:\java.txt'', ''r'')
     

  •  Infile = open(file=''d:\java.txt'', ''r'')
     

  •  Infile = open(''d:java.txt'',''r'')
     

  • Infile = open.file(''d:\java.txt'',''r'')
     

Which of the following is correct output of this program?
 

  • ['xy', 'yz']
     

  •  ['XY', 'YZ']
     

  •  [None, None]
     

  • None of these

What will be the output of the following Python code snippet?
z=set('abc$de')
'a' in z

  • Error
     

  •  True
     

  • False
     

  • No output

Study the following function:
import math  
abs(math.sqrt(36))  
What will be the output of this code?

  •  Error
     

  •  -6
     

  •  6
     

  •  6.0

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

  • Every object in Python doesn’t have a unique id
     

  •  In Python Id function returns the identity of the object
     

  •  None of the mentioned
     

  •  All of the mentioned

Study the following program:
z = "xyz"  
j = "j"  
while j in z:  
    print(j, end=" ")  
What will be the output of this statement?

  • xyz
     

  • No output
     

  •  x y z
     

  • j j j j j j j..