PYTHON-3 QUIZ DESCRIPTION

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..
     

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

Which of the following is a Python tuple?

  •  {1, 2, 3}
     

  •  {}

     

  •  [1, 2, 3]

     

  •  (1, 2, 3)
     

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 will be the output of the following Python program?
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

 

  • 5

  • 8

  • 2

  • 1

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 is output of print(math.pow(3, 2))?
 

  • 9.0
     

  • None
     

  •  9
     

  •  None of the mentioned
     

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:

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

 

  • 4
     

  •  5
     

  •  546
     

  • 5.0

What will be the output of the following Python program?

def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

  • 5

  • 8

  • 2

  • 1

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

  •  javatpoint
     

  • java

     

  • point
     

  •  None of these
     

What will be the output of the following Python code?
print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

 

  •  Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
     

  •  Error
     

  •  Hello foo and bin
     

  •  None of the mentioned

What will be the output of the following Python code?
print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

 

  • Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
     

  •  Error
     

  •  Hello foo and bin
     

  •  None of the mentioned

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

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

Study the following code:
print (r"\njavat\npoint")  
What will be the output of this statement?

 

  •  javapoint
     

  •  java point
     

  • javat point

     

  •  Print the letter r and then javat and then point
     

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
     

The process of pickling in Python includes ____________

  • conversion of a Python object hierarchy into byte stream
     

  • conversion of a datatable into a list
     

  •  conversion of a byte stream into Python object hierarchy
     

  • conversion of a list into a datatable

Which of the following is correct output of this program?
 

  • ['xy', 'yz']
     

  •  ['XY', 'YZ']
     

  •  [None, None]
     

  • None of these

Study the following statement:
"a"+"bc"  
What will be the output of this statement?

  • a+bc
     

  • abc
     

  •  a bc
     

  •  a

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

The output to execute string.ascii_letters can also be obtained from:?
 

  • character
     

  •  ascii_lowercase_string.digits
     

  • lowercase_string.upercase

     

  •  ascii_lowercase+string.ascii_upercase
     

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

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 function:
any([5>8, 6>3, 3>1])  
What will be the output of this code?

  • False

     

  •  Ture
     

  • Invalid code
     

  • 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 statements:
print(ord('h') - ord('z'))  
What will be the output of this statement?

  • 18

  • -18

  • 17

  • -17

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

  • 9.0
     

  •  None
     

  •  9

     

  • None of the mentioned