What is the output of the following expression if x=456?
print("%-06d"%x)
What is the value of this expression?
bin(0x8)
What is the output of the following?
d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d.items():
print(x, y)
Mathematical operations can be performed on a string. State whether true or false.
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
What is the output of the following?
for i in [1, 2, 3, 4][::-1]:
print (i)
What is the value of the following expression:
float(22//3+3/3)
In the code shown below, which function is the decorator?
def mk(x):
def mk1():
print("Decorated")
x()
return mk1
def mk2():
print("Ordinary")
p = mk(mk2)
p()
What is the value of the following expression?
2+4.00, 2**4.0
Which of the following is invalid?
What is the output of the following?
x = (i for i in range(3))
for i in x:
print(i)
What is the output of the following?
for i in 'abcd'[::-1]:
print (i)
Which of the following is not a complex number?
What is the output of this expression if X= -122?
print("-%06d"%x)
What is the output of the following code ?
>>>max("what are you")
The format function, when applied on a string returns :
What is the output of the following?
x = 'abcd'
for i in x:
print(i.upper())
Which one of the following have the same precedence?
What is the output of the following?
for i in range(float('inf')):
print (i)
Which of the following expressions can be used to multiply a given number ‘a’ by 4?
Which of the following expressions involves coercion when evaluated in Python?
What is the output of the code shown?
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
What is the output of the code shown below?
l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))
Consider the snippet of code shown below and predict the output.
X=”san-foundry”
print(“%56s”,X)
What is the output of the code shown below?
def f(x):
def f1(a, b):
print("hello")
if b==0:
print("NO")
return
return f(a, b)
return f1
@f
def f(a, b):
return a%b
f(4,0)
What is the value of this expression:
bin(10-2)+bin(12^4)
Fill in the blanks:
The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
What is the output of the following?
x = 123
for i in x:
print(i)
What is the output of the following code ?
>>>example = "helle"
>>>example.rfind("e")
What is the output of the code shown below?
'{a}{b}{a}'.format(a='hello', b='world')
The code shown above can work with ____ parameters.
def f(x):
def f1(*args, **kwargs):
print("Sanfoundry")
return x(*args, **kwargs)
return f1
What is the result of the expression if x=15 and y=12:
x & y
What is the result of round(0.5) – round(-0.5)?
In python we do not specify types,it is directly interpreted by the compiler, so consider the following operation to be performed.
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python 3.xx)
Identify the decorator in the snippet of code shown below.
def sf():
pass
sf = mk(sf)
@f
def sf():
return
What will be displayed by print(ord(‘b’) – ord(‘a’)) ?
What does 3 ^ 4 evaluate to?
Which one of these is floor division?
What is the value of the expression:
4+2**5//10
What is the output of the following?
print("abcdef".center(7, 1))