What is the output of the following?
a = [0, 1, 2, 3]
for a[0] in a:
print(a[0])
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 is the two’s complement of -44?
Which of the following is the truncation division operator?
The following is displayed by a print function call:
tom
dick
harry
Select all of the function calls that result in this output
Why are local variable names beginning with an underscore discouraged?
Following set of commands are executed in shell, what will be the output?
1.>>>str="hello"
2.>>>str[:2]
3.>>>
What is the output of the code shown below?
'%s' %((1.23,),)
What is the output of the following?
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
The output of the code shown below is:
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
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?
for i in range(int(float('inf'))):
print (i)
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 arithmetic operators cannot be used with strings ?
What is the order of precedence in python?
i) Parentheses
ii) Exponential
iii) Division
iv) Multiplication
v) Addition
vi) Subtraction
What is the output of the following?
x = "abcdef"
i = "a"
while i in x:
print('i', end = " ")
Which of the following results in a SyntaxError ?
What is the output of the following?
print('*', "abcdef".center(7), '*')
What is the return type of function id ?
What is the output of the code shown below?
'%.2f%s' % (1.2345, 99)
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
i[x].upper()
print (x)
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 is the output when following statement is executed ?
>>>chr(ord('A'))
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
Consider the snippet of code shown below and predict the output.
X=”san-foundry”
print(“%56s”,X)
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)
The output of executing string.ascii_letters can also be achieved by:
What is the output of the following?
i = 2
while True:
if i%3 == 0:
break
print(i)
i += 2
What is the output of the following?
x = "abcdef"
i = "a"
while i in x[1:]:
print(i, end = " ")
What is the result of round(0.5) – round(-0.5)?
What is the output of the code shown below?
'{a}{b}{a}'.format(a='hello', b='world')
What is the output of the following?
print('*', "abcde".center(6), '*', sep='')
What is the output of the following?
True = False
while True:
print(True)
break
What is the value of the following expression:
24//6%3, 24//4//2
What is the output of the code shown?
x=3.3456789
'%f | %e | %g' %(x, x, x)
In order to store values in terms of key and value we use what core datatype.
What is the value of the following expression:
float(22//3+3/3)
Which of the following operators has its associativity from right to left?
What is the output of the following code ?
>>>example = "snow world"
>>>print("%s" % example[4:7])
What is the output of the following?
for i in range(float('inf')):
print (i)