What is the output of the following?
print("abcdef".center(7, 1))
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 code shown below?
def c(f):
def inner(*args, **kargs):
inner.co += 1
return f(*args, **kargs)
inner.co = 0
return inner
@c
def fnc():
pass
if __name__ == '__main__':
fnc()
fnc()
fnc()
print(fnc.co)
What is the output of the following?
d = {0, 1, 2}
for x in d:
print(x)
Why are local variable names beginning with an underscore discouraged?
Which of the following expressions can be used to multiply a given number ‘a’ by 4?
What is the value of the following expression?
2+4.00, 2**4.0
What is the output of the following?
x = ['ab', 'cd']
for i in x:
x.append(i.upper())
print(x)
Suppose i is 5 and j is 4, i + j is same as
What is the output of the following?
x = 'abcd'
for i in range(len(x)):
print(x)
x = 'a'
The output of the snippet of code shown below?
bool(‘False’)
bool()
The code shown above can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print("Sanfoundry")
return x(*args, **kwargs)
return f1
Which one of these is floor division?
What is the value of the expression:
~100?
What is the return value of trunc() ?
What is the output of the code shown?
def ordi():
print("Ordinary")
ordi
ordi()
What is the value of the following expression:
8/4/2, 8/(4/2)
What is the output of the code shown?
'%(qty)d more %(food)s' %{'qty':1, 'food': 'spam'}
What is the output of “hello”+1+2+3 ?
What is the output of the code shown below?
'The {} side {1} {2}'.format('bright', 'of', 'life')
What is the output of the following?
i = 1
while False:
if i%2 == 0:
break
print(i)
i += 2
Which of the following is not a keyword?
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 following?
string = "my name is x"
for i in string:
print (i, end=", ")
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?
x = "abcdef"
while i in x:
print(i, end=" ")
Which of these in not a core datatype?
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 output of the code shown below?
not(3>4)
not(1&1)
What is the output of the following code ?
>>>example="helloworld"
>>>example[::-1].startswith("d")
Which of the following is incorrect?
What is the output of the following?
x = 2
for i in range(x):
x += 1
print (x)
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?
string = "my name is x"
for i in string.split():
print (i, end=", ")
What is the output of the code shown below?
'%.2f%s' % (1.2345, 99)
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?
d = {0, 1, 2}
for x in d:
print(d.add(x))
What is the output of this expression, 3*1**3?
Which of the following results in a SyntaxError ?
What is the output of the following code if the system date is 21st June, 2017 (Wednesday)?
[ ] or {}
{} or [ ]