What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
What is the output of the code shown?
a='hello'
q=10
vars()
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 following?
for i in range(2.0):
print(i)
What is the output of the following?
x = 'abcd'
for i in x:
print(i.upper())
What is the output when following statement is executed ?
>>>"abcd"[2:]
What is the output of the following?
x = "abcdef"
while i in x:
print(i, end=" ")
What is the output when following statement is executed ?(python 3.xx)
>>>print(format("Welcome", "10s"), end = '#')
>>>print(format(111, "4d"), end = '#')
>>>print(format(924.656, "3.2f"))
Which of the following is not a complex number?
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
i.upper()
print (x)
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 result of the snippet of code shown below if x=1?
x<<2
What is the output when following statement is executed ?
>>> print(‘x\97\x98’)
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 following?
i = 1
while True:
if i%0O7 == 0:
break
print(i)
i += 1
-
-
-
-
What is the value of this expression?
bin(0x8)
What is the output of the code shown below if the system date is 18th August, 2016?
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res
Which of these in not a core datatype?
What is the output of the code shown below?
'{0:.2f}'.format(1.234)
Mathematical operations can be performed on a string. State whether true or false.
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?
print("abcdef".center(7, 1))
What is the output of the following?
for i in '':
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 “hello”+1+2+3 ?
What is the output when following statement is executed ?
>>>print(chr(ord('b')+1))
What is the output of the code shown below?
'{a}{b}{a}'.format(a='hello', b='world')
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 code shown below?
D=dict(p='san', q='foundry')
'{p}{q}'.format(**D)
What is the value of the expression:
float(4+int(2.39)%2)
What is the output of the following?
print("abcdef".center())
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)
What is the value of the expression:
4+2**5//10
To find the decimal value of 1111, that is 15, we can use the function:
What is the value of x if:
x = int(43.55+2/2)
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 code ?
>>>example = "helle"
>>>example.find("e")
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?
i = 0
while i < 3:
print(i)
i += 1
else:
print(0)
What is the output of the following function?
def f(p, q):
return p%q
f(0, 2)
f(2, 0)