def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
82
Questions
2/5
Page
Pick an option on a question to see the right answer and solution.
def d(f):
def n(*args):
return '$' + str(f(*args))
return n
@d
def p(a, t):
return a + a*t
print(p(100,0))Select an option to see the answer and solution.
print(“%f”%x)Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
i. '{0:.2f}'.format(1/3.0)
ii. '%.2f'%(1/3.0)Select an option to see the answer and solution.
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)Select an option to see the answer and solution.
'{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])Select an option to see the answer and solution.
Select an option to see the answer and solution.
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)Select an option to see the answer and solution.
def sf():
pass
sf = mk(sf)
@f
def sf():
returnSelect an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)Select an option to see the answer and solution.
x=3.3456789
'%-6.2f | %05.2f | %+06.1f' %(x, x, x)Select an option to see the answer and solution.
CODE 1
@f
def f1():
print(“Hello”)
CODE 2
def f1():
print(“Hello”)
f1 = f(f1)Select an option to see the answer and solution.
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
resSelect an option to see the answer and solution.
t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.