In the code shown below, which function is the decorator?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
What is the output of the following code ?
>>>max("what are you")
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 output of the following?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
Why are local variable names beginning with an underscore discouraged?
Which of the following expressions results in an error?
What is the return type of function id ?
It is not possible for the two’s complement value to be equal to the original value in any case. State whether this statement is true or false.
Is Python case sensitive when dealing with identifiers?
What is the value of the expression:
~100?
What is the output of the code shown below?
def f(x):
def f1(*args, **kwargs):
print("*", 5)
x(*args, **kwargs)
print("*", 5)
return f1
@f
def p(m):
p(m)
print("hello")
The output of the expression is:
bin(29)
What is the output of the following?
True = False
while True:
print(True)
break
Carefully observe the code and give the answer.
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
What is the two’s complement of -44?
What is the output when following code is executed ?
>>>str1="helloworld"
>>>str1[::-1]
What is the output of the code shown below?
not(3>4)
not(1&1)
What is the output of the following code ?
>>>example = "helle"
>>>example.rfind("e")
Which one of the following have the same precedence?
What is the output of the following?
print("abcdef".center(0))
What is the output of the code shown?
x=3.3456789
'%f | %e | %g' %(x, x, x)
What is the output of the following code ?
>>>example = "snow world"
>>>print("%s" % example[4:7])
Fill in the blanks:
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
What is the output of the following?
x = 2
for i in range(x):
x += 1
print (x)
The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or false.
What is the value of this expression:
bin(10-2)+bin(12^4)
What is the output of the following?
for i in range(2.0):
print(i)
What is the result of the expression:
int(1011)?
What is the output of the following?
x = 123
for i in x:
print(i)
Which one of these is floor division?
What is the output of the following?
i = 5
while True:
if i%0O11 == 0:
break
print(i)
i += 1
What is the result of round(0.5) – round(-0.5)?
Mathematical operations can be performed on a string. State whether true or false.
What is the output of the code show below if a=10 and b =20?
a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)
What is the output of the following?
d = {0, 1, 2}
for x in d:
print(x)
What is the output of the following?
print("abcdef".center(7, 1))
What is the output of the following?
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
Which of the following operators has its associativity from right to left?
If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
What is the output of the code shown?
s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')