To check whether string s1 contains another string s2, use
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
The output of the snippet of code shown below?
bool(‘False’)
bool()
To find the decimal value of 1111, that is 15, we can use the function:
What is the output of the following?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
Which of the following expressions results in an error?
What is the output of the code shown?
def ordi():
print("Ordinary")
ordi
ordi()
What is the result of cmp(3, 1)?
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)
What is the output of the following?
i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1
What is the output of the following code ?
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
What is the value of the following expression:
24//6%3, 24//4//2
What is the value of the expression:
~100?
What is the output of the following?
for i in [1, 2, 3, 4][::-1]:
print (i)
What is the value of the following expression:
8/4/2, 8/(4/2)
Which of the following represents the bitwise XOR operator?
What is the output of the following?
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
What is the output of the following?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
What is the output of the following?
print('*', "abcdef".center(7), '*', sep='')
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
Mathematical operations can be performed on a string. State whether true or false.
What arithmetic operators cannot be used with strings ?
Which of the following is the truncation division operator?
What is the output of the code shown below?
class Truth:
pass
x=Truth()
bool(x)
Which of the following expressions involves coercion when evaluated in Python?
What is the output of the following?
i = 5
while True:
if i%0O9 == 0:
break
print(i)
i += 1
Consider the expression given below. The value of X is:
X = 2+9*((3*12)-8)/10
What is the output of the following?
for i in ''.join(reversed(list('abcd'))):
print (i)
Which one of these is floor division?
What is the value of the following expression?
2+4.00, 2**4.0
What is the output of this expression, 3*1**3?
The one’s complement of 110010101 is:
What is the value of x if:
x>>2=2
The output of the two codes shown below is the same. State whether true or false.
'{0:.2f}'.format(1/3.0)
'%.2f'%(1/3.0)
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 expression if the value of x is 34?
print(“%f”%x)
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?
string = "my name is x"
for i in string.split():
print (i, end=", ")
Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
Which of the following is incorrect?