What is the value of x if:
x>>2=2
What is the output when following statement is executed ?
>>>"abcd"[2:]
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)
What is the output of the following code?
hex(255), int('FF', 16), 0xFF
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")
Which of the following results in a SyntaxError ?
What is the output of the following?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
Suppose x is 345.3546, what is format(x, “10.3f”) (_ indicates space)
What is the output of the following?
x = 'abcd'
for i in x:
print(i)
x.upper()
Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.
What is the output when following code is executed ?
>>>str1="helloworld"
>>>str1[::-1]
What is the output of the following?
x = 'abcd'
for i in range(x):
print(i)
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.
What is the output of the following?
for i in [1, 2, 3, 4][::-1]:
print (i)
What is the output of the following?
i = 1
while True:
if i%2 == 0:
break
print(i)
i += 2
To concatenate two strings to a third what statements are applicable ?
What is the output of the code shown?
def ordi():
print("Ordinary")
ordi
ordi()
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
print(d[x])
What is the output of the following?
x = "abcdef"
i = "i"
while i in x:
print(i, end=" ")
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
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 output of the code shown below?
'%x %d' %(255, 255)
What is the output when following code is executed ?
>>>print("D", end = ' ')
>>>print("C", end = ' ')
>>>print("B", end = ' ')
>>>print("A", end = ' ')
What is the value of the following expression:
float(22//3+3/3)
What is the output of this expression, 3*1**3?
What is the value of this expression?
bin(0x8)
What is the output of the following code ?
>>>example = "snow world"
>>>print("%s" % example[4:7])
What is the output of the code shown below?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
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?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
The expression 2**2**3 is evaluates as: (2**2)**3. State whether this statement is true or false.
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))
Which one of these is floor division?
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.keys():
print(d[x])
What is the value of x if:
x = int(43.55+2/2)
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
What is the output of the code shown below?
D=dict(p='san', q='foundry')
'{p}{q}'.format(**D)
Which of the following cannot be a variable?
Say s=”hello” what will be the return value of type(s) ?
Fill in the blanks:
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.