SyVe Python Mock Quiz

Is this your test? Login to manage it. If not, you can generate a quiz just like it.

This is a non-interactive preview of the quiz content.

1.
1 point
What is the output of the following?

print([i+j for i in "abc" for j in "def"])
2.
1 point
What arithmetic operators cannot be used with strings ?
3.
1 point
What is the output of the following code?

def foo(k):
<-> k[0] = 1
q = [0]
foo(q)
print(q)
print(q)
4.
1 point
What is the output when following code is executed ?

>>>print r"\nhello"
5.
1 point
What are the two types of functions?
6.
1 point
What is the output of the following?

i = 1
while True:
<-> if i%3 == 0:
<-><-> break
<-> print(i)
<-> i + = 1
7.
1 point
What is the output of the following?

print("Hello {0!r} and {0!s}".format('foo', 'bin'))
8.
1 point
What is the output of “hello”+1+2+3 ?
9.
1 point
Which operator is overloaded by __invert__()?
10.
1 point
What is the output of the following?

True = False
while True:
<-> print(True)
<-> break
11.
1 point
What is the output of below program?

def writer():

<-> title = 'Sir'

<-> name = (lambda x:title + ' ' + x)

<-> return name

who = writer()

who('Arthur')
12.
1 point
What is the output of the following?

for i in ''.join(reversed(list('abcd'))):
<-> print (i)
13.
1 point
What is the output of the following?

sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.group(2))
14.
1 point
Is the following code valid?

try:
<-> # Do something
except:
<-> # Do something
finally:
<-> # Do something
15.
1 point
Which of the following is an invalid variable?
16.
1 point
Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use
17.
1 point
What dataype is the object below ?
L = [1, 23, 'hello', 1]
18.
1 point
Python supports the creation of anonymous functions at runtime, using a construct called __________?
19.
1 point
What is the value stored in sys.argv[0]?
20.
1 point
Which of the following is not a valid attribute of a file object (fp)?
21.
1 point
Which of the following statement prints hello\example\test.txt ?
22.
1 point
Which of the following functions can be used to read data from a file using a file descriptor?
23.
1 point
What is the output of the following?

def foo(i, x=[]):
<-> x.append(x.append(i))
<-> return x
for i in range(3):
<-> y = foo(i)
print(y)
24.
1 point
What does ~~~~~~5 evaluate to?
25.
1 point
Following set of commands are executed in shell, what will be the output?

>>>str="hello"

>>>str[:2]

>>>str
26.
1 point
What is the output of the following?

sentence = 'we are humans'
matched = re.match(r'(.*) (.*?) (.*)', sentence)
print(matched.groups())
27.
1 point
What is the output when following code is executed ?

>>>list("a#b#c#d".split('#'))
28.
1 point
How many elements are in m?

m = [[x, y] for x in range(0, 4) for y in range(0, 4)]
29.
1 point
What is the output of the following?

for i in range(2.0):
<-> print(i)
30.
1 point
What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Division
iv) Multiplication
v) Addition
vi) Subtraction