PYTHON XLSX WRITER QUIZ DESCRIPTION

True = False
while True:
    print(True)
    break

  • 1

  • 3

  • error

  • none of the mentioned

Suppose d = {“madhu”:521, “naveen”:532}, what happens when we try to retrieve a value using the expression d[“suresh”]?

  • Since “suresh” is not a value in the set, Python raises a KeyError exception
     

     

  • It is executed fine and no exception is raised, and it returns None

  • Since “suresh” is not a key in the set, Python raises a KeyError exception

  • Since “susan” is not a key in the set, Python raises a syntax error

What is the output when following code is executed ? 
>>>print(0xA + 0xB + 0xC) 

  • 0xA0xB0xC
     
     

  • Error
     

  • 0x22

  • 33

What is the output of the following piece of code?
 
>>> a=(2,3,1,5)
>>> a.sort()
>>> print(a)

 

  • (1,2,3,5)
     
     

  • (5,1,3,2)

  • (5,3,2,1)
     

  • error

What is the output of the following?
 
print(`ab,12`.isalnum())

  • 1
     
     

  • 6

  • Error

  • none of the mentioned

What is the output of the following?
 
string = "my name is m"
for i in string:
    print (i, end=", ")

  • m, y, , n, a, m, e, , i, s, , m,
     
     

  • m, y, , n, a, m, e, , i, s, , m
     

  • my, name, is, x,
     

  • Error

Following set of commands are executed in shell, what will be the output?  
>>>str="hello"
>>>str[:2]

  • he

  • lo

  • olleh

  • hello
     

Which of these about a dictionary is false?

  • The values of a dictionary can be accessed using keys
     
     

  • The keys of a dictionary can be accessed using values

  • Dictionaries aren’t ordered

  • Dictionaries are mutable

What is the output of the following?
 
d = {0: `a`, 1: `b`, 2: `c`}
for i in d:
    print(i)

  • 0 1 2
     
     

  • a b c

  • 0 a 1 b 2 c
     

  • none of the mentioned

What is the output of the following?
 
x = (i for i in range(3))
for i in x:
    print(i)
for i in x:
    print(i)

  • 0 1 2
     
     

  • error

  •  0 1 2 0 1 2

  • none of the mentioned

Which of the following is invalid identifier declaration?

  • _a = 1
     
     

  • __a = 1
     

  • __str__ = 1

  • none of the mentioned

What is the output of the code shown below?
 
l=[1, 2, 4, 5, 2, `xy`, 4]
print(set(l))
print(l)

  • {1, 2, 4, 5, 2, ‘xy’, 4} [1, 2, 4, 5, 2, ‘xy’, 4]
     
     

  • {1, 2, 4, 5, ‘xy’} [1, 2, 4, 5, 2, ‘xy’, 4]

  • {1, 5, ‘xy’} [1, 5, ‘xy’]

  • {1, 2, 4, 5, ‘xy’} [1, 2, 4, 5, ‘xy’]

What is the output of the following code?
 
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))

  • 8

  • Error, invalid syntax for formation of set
     

  • 4

  • 8

What is the output of the following?
 
x = [`ab`, `cd`]
for i in x:
    i.upper()
print(x)

  • [‘ab’, ‘cd’].
     
     

  • [‘AB’, ‘CD’].
     

  • Error
     

  • [None, None].
     

Set makes use of __________ and Dictionary makes use of ____________ ?

  • keys, key values
     
     

  • keys, keys

  • key values, keys

  • key values, key values

What is the output of the following?
 
x = [`ab`, `cd`]
for i in x:
    x.append(i.upper())
print(x)

  • [‘AB’, ‘CD’].
     
     

  • ‘ab’, ‘cd’, ‘AB’, ‘CD’].

  •  [‘ab’, ‘cd’].

  • none of the mentioned

Which of the following is an invalid statement?

  • abc = 1,000,000
     

  • a b c = 1000 2000 3000

  • a,b,c = 1000, 2000, 3000

  • a_b_c = 1,000,000

What is the output when following code is executed ?
 
myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i
 
>>>print(indexOfMax)

  • 1

  • 2

  • 3

  • 4

What will be the output?
 
def f(i, values = []):
    values.append(i)
    return values
 
f(1)
f(2)
v = f(3)
print(v)

  • [1] [2] [3].
     
     

  • [1] [1, 2] [1, 2, 3].

  • 1 2 3

  • [1, 2, 3].

What is the output when following code is executed ?
 
myList = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
    myList[i - 1] = myList[i]
 
for i in range(0, 6): 
    print(myList[i], end = " ")

  • 2 3 4 5 6 1
     
     

  • 6 1 2 3 4 5

  • 2 3 4 5 6 6
     

  • 1 1 2 3 4 5

What is the output of the following?
 
for i in range(10):
    if i == 5:
        break
    else:
        print(i)
else:
    print("Here")

  •  0 1 2 3 4 Here
     
     

  • 0 1 2 3 4 5 Here

  • 0 1 2 3 4

  • 1 2 3 4 5

Is Python case sensitive when dealing with identifiers?

  • yes
     

  • no

  • machine dependent

  • none of the mentioned

What is the output of the following piece of code?
 
>>> a={3,4,5}
>>> a.update([1,2,3])
>>> print(a)

  • Error, no method called update for set data type
     
     

  • {1, 2, 3, 4, 5}
     

  • Error, list can’t be added to set

  • Error, duplicate item present in list
     

 Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1) ?

  •  [3, 4, 5, 20, 5, 25, 3].
     

     

  • [1, 3, 3, 4, 5, 5, 20, 25].
     

  • [3, 5, 20, 5, 25, 1, 3].
     

  • [4, 5, 20, 5, 25, 1, 3].

def example(a):
    a = a + `2`
    a = a*2
    return a
print(example("hello"))

  • ndentation Error
     
     

  • cannot perform mathematical operation on strings
     

  • hello2
     

  • hello2hello2

What error occurs when you execute?  
>>>apple = mango

  • SyntaxError
     

     

  • NameError

  • ValueError

  • TypeError

Suppose t = (1, 2, 4, 3), which of the following is incorrect?

  • print(t[3])
     
     

  • t[3] = 45
     

  • print(max(t))
     

  • print(len(t))

What is the output of the following?
 
i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2

  • 2 4 6 8 10 …
     
     

  • 2 3

  • 2 4

  • Error

What is the output of the following?
 
x = `abcd`
for i in range(x):
    print(i)

  • a b c d
     
     

  •  0 1 2 3

  • Error

  • none of the mentioned

What is the output of the following code?
 
a={1:"A",2:"B",3:"C"}
for i,j in a.items():
    print(i,j,end=" ")

  • 1 A 2 B 3 C
     
     

  • 1 2 3

  • 1:”A” 2:”B” 3:”C”

  • A B C