Mathematical operations can be performed on a string. State whether true or false.
What is the output of the following?
x = "abcdef"
i = "a"
while i in x:
x = x[1:]
print(i, end = " ")
Bitwise _________ gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
What is the result of the expression shown below if x=56.236?
print("%.2f"%x)
What is the output of the following?
for i in [1, 2, 3, 4][::-1]:
print (i)
What is the output of the following?
for i in 'abcd'[::-1]:
print (i)
What is the output of the code shown?
['f', 't'][bool('spam')]
What is the maximum possible length of an identifier?
Say s=”hello” what will be the return value of type(s) ?
The output of the code shown below is:
s='{0}, {1}, and {2}'
s.format('hello', 'good', 'morning')
What is the output of the code shown?
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
What is the result of the expression:
0x35 | 0x75
What is the output of the following?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
The following is displayed by a print function call:
tom
dick
harry
Select all of the function calls that result in this output
What is the output of the following?
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)
What is the output of the code shown below?
def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))
What is the output of the following?
x = "abcdef"
i = "a"
while i in x[:-1]:
print(i, end = " ")
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
x[i].upper()
print (x)
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 value of the expression:
4+2**5//10
What is the output of the following?
string = "my name is x"
for i in string.split():
print (i, end=", ")
What is the output of the code shown?
l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)
What is the return value of trunc() ?
What is the output of the code shown below?
'{0:.2f}'.format(1.234)
Which of the following is true for variable names in Python?
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?
s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')
What is the output of the following?
i = 1
while False:
if i%2 == 0:
break
print(i)
i += 2
What is the output of the following?
for i in range(0):
print(i)
To return the length of string s what command do we execute ?
What is the output of the code shown?
x=3.3456789
'%f | %e | %g' %(x, x, x)
Which of the following cannot be a variable?
What is the output of the code shown below?
l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)
What is the output of the following?
print("abc DEF".capitalize())
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
print(x)
Suppose s is “\t\tWorld\n”, what is s.strip() ?
What is the output of the following?
print("abcdef".center(7, 1))
What is the result of round(0.5) – round(-0.5)?
Why are local variable names beginning with an underscore discouraged?