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 of the following code ?
>>>example="helloworld"
>>>example[::-1].startswith("d")
What is the output of the following?
for i in range(int(2.0)):
print(i)
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
What is the output when following code is executed ?
>>>print("D", end = ' ')
>>>print("C", end = ' ')
>>>print("B", end = ' ')
>>>print("A", end = ' ')
The format function, when applied on a string returns :
What is the two’s complement of -44?
What does 3 ^ 4 evaluate to?
Which of the following is an invalid statement?
What is answer of this expression, 22 % 3 is?
What is the output of the following?
string = "my name is x"
for i in ' '.join(string.split()):
print (i, end=", ")
What is the output of the following?
print('*', "abcde".center(6), '*', sep='')
What is the maximum possible length of an identifier?
What is the output of the following?
print("abcdef".center())
What is the output of the following?
print("abcdef".center(0))
What is the output of the following code ?
class Name:
def __init__(self, firstName, mi, lastName):
self.firstName = firstName
self.mi = mi
self.lastName = lastName
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)
To return the length of string s what command do we execute ?
What is the output of the following expression if the value of x is 34?
print(“%f”%x)
What is “Hello”.replace(“l”, “e”)
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)
To retrieve the character at index 3 from string s=”Hello” what command do we execute (multiple answers allowed) ?
What is the output of the following?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
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 function do you use to read a string?
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 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 does ~4 evaluate to?
What is the output of the code shown?
s='%s, %s & %s'
s%('mumbai', 'kolkata', 'delhi')
Select all options that print
hello-how-are-you
Which is the correct operator for power(x^y)?
What is the output of the following?
for i in range(0):
print(i)
What is the output of the code shown below?
x=3.3456789
'%-6.2f | %05.2f | %+06.1f' %(x, x, x)
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 = "abcdef"
i = "a"
while i in x:
print(i, end = " ")
What is the output of the code shown below?
'{0:.2f}'.format(1.234)
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 following?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
What is the output of the code shown below?
class A:
@staticmethod
def a(x):
print(x)
A.a(100)
Which of the following cannot be a variable?
To concatenate two strings to a third what statements are applicable ?