PYTHON-3 QUIZ DESCRIPTION

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

  • False

     

  •  Ture
     

  • Invalid code
     

  • 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?
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

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

  • 4

  • 4.6

  • 5

  • 4.5

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 correct output of this program?
 

  • ['xy', 'yz']
     

  •  ['XY', 'YZ']
     

  •  [None, None]
     

  • None of these

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

  • 33

  • 63

  • 0xA + 0xB + 0xC
     

  • None of these

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
     

Which of the following is a Python tuple?
 

  • {1, 2, 3}
     

  •  {}
     

  • [1, 2, 3]
     

  •  (1, 2, 3)

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

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

  • 9.0
     

  • None
     

  • 9
     

  • None of the mentioned

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
     

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 program:
class book:  
    def __init__(a, b):  
        a.o1 = b  
   
class child(book):  
    def __init__(a,

  • 32
     

  • 32 32
     

  • 32 None
     

  • Error is generated

What are the two main types of functions in Python?
 

  • System function
     

  •  Custom function
     

  • Built-in function & User defined function
     

  •  User function

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
     

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:
str1 = "javat"  
str2 = ":"  
str3 = "point"  
str1[-1:]  
What will be the output of this statement?

  • t

  • j

  • point

  • java

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

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

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
     

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

 

  • 4

  • 4.6

  • 5

  • 4.5

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

  • a+bc
     

  • abc
     

  •  a bc
     

  •  a

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

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