What is the output of the code shown below?
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')
What is the return type of function id ?
What is the output of the code shown below?
def c(f):
def inner(*args, **kargs):
inner.co += 1
return f(*args, **kargs)
inner.co = 0
return inner
@c
def fnc():
pass
if __name__ == '__main__':
fnc()
fnc()
fnc()
print(fnc.co)
What are the output of the code shown below?
def f(x):
def f1(*args, **kwargs):
print("*"* 5)
x(*args, **kwargs)
print("*"* 5)
return f1
def a(x):
def f1(*args, **kwargs):
print("%"* 5)
x(*args, **kwargs)
print("%"* 5)
return f1
@f
@a
def p(m):
print(m)
p("hello")
What is the output of the following?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
What is the output of the following?
print("abcdef".center(7, 1))
Say s=”hello” what will be the return value of type(s) ?
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
print(x)
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
The output of the two codes shown below is the same. State whether this statement is true or false.
bin((2**16)-1)
'{}'.format(bin((2**16)-1))
Which of the following is incorrect?
What is the output of the following?
string = "my name is x"
for i in string:
print (i, end=", ")
What is the output of the following code ?
class tester:
def __init__(self, id):
self.id = str(id)
id="224"
>>>temp = tester(12)
>>>print(temp.id)
Carefully observe the code and give the answer.
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
Which of the following is not a keyword?
What is the output of the following expression if X=345?
print(“%06d”%X)
What is the output of the following?
x = 2
for i in range(x):
x += 1
print (x)
What is the output of the following?
a = [0, 1, 2, 3]
for a[0] in a:
print(a[0])
What is the output of the code shown?
x=3.3456789
'%s' %x, str(x)
Which of the following expressions can be used to multiply a given number ‘a’ by 4?
What is the output of the following code ?
class Count:
def __init__(self, count = 0):
self.__count = count
c1 = Count(2)
c2 = Count(2)
print(id(c1) == id(c2), end = " ")
s1 = "Good"
s2 = "Good"
print(id(s1) == id(s2))
What dataype is the object below ?
L = [1, 23, ‘hello’, 1].
What is the output of the following?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
What is the output when following statement is executed ?
>>>"abcd"[2:]
What is the output of the following?
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
Which of the following expressions involves coercion when evaluated in Python?
The two snippets of codes shown below are equivalent. State whether true or false.
CODE 1
@f
def f1():
print(“Hello”)
CODE 2
def f1():
print(“Hello”)
f1 = f(f1)
What does 3 ^ 4 evaluate to?
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
print(i.upper())
What is the output of the following?
for i in range(float('inf')):
print (i)
What is the output of the following expression if x=456?
print("%-06d"%x)
What is the output of the following?
a = [0, 1, 2, 3]
i = -2
for i not in a:
print(i)
i += 1
What is the output of the code shown below?
if (9 < 0) and (0 < -9):
print("hello")
elif (9 > 0) or False:
print("good")
else:
print("bad")
What is the output of the following?
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
What is “Hello”.replace(“l”, “e”)
In order to store values in terms of key and value we use what core datatype.
The output of the code shown below is:
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
Given a string example=”hello” what is the output of example.count(l)
Operators with the same precedence are evaluated in which manner?