Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code snippet? x=3.3456789 '%s' %x, str(x)
Q2
What will be the output of the following Python code? '%x %d' %(255, 255)
Q3
What will be the output of the following Python expression if the value of x is 34? print(“%f”%x)
Q4
The following python code can work with . . . . . . . . parameters. def f(x): def f1(*args, **kwargs): print("Examveda") return x(*args, **kwargs) return f1
Q5
The . . . . . . . . symbol along with the name of the decorator function can be placed above the definition of the function to be decorated works as an alternate way for decorating a function.
Q6
What is the purpose of the @staticmethod decorator compared to the @classmethod decorator?
Q7
What is the output of the code: print("{:<10}".format("hello"))?
Q8
What will be the output of the following Python code? def mk(x): def mk1(): print("Decorated") x() return mk1 def mk2(): print("Ordinary") p = mk(mk2) p()
Q9
Which built-in function is used to check if an object is an instance of a particular class?
Q10
In Python, what is the purpose of the locals() function?
Q11
What will be the output of the following Python code? '{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
Q12
What will be the output of the following Python code? 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)
Q13
The formatting method {1:<10} represents the . . . . . . . . positional argument, . . . . . . . . justified in a 10 character wide field.
Q14
What is the primary use of the @staticmethod decorator?
Q15
What will be the output of the following Python code? 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))
Q16
What will be the output of the following Python expression if X=345? print(“%06d”%X)
Q17
What will be the output of the following Python code? class A: @staticmethod def a(x): print(x) A.a(100)
Q18
In Python, what is the purpose of the @classmethod decorator?
Q19
Identify the decorator in the snippet of code shown below. def sf(): pass sf = mk(sf) @f def sf(): return
Q20
What will be the output of the following Python code? 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)
Q21
What will be the output of the following Python code? l=list('HELLO') p=l[0], l[-1], l[1:3] 'a={0}, b={1}, c={2}'.format(*p)
Q22
Which module must be imported to use the @abstractmethod decorator in Python?
Q23
What will be the output of the following Python code? '{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
Q24
The output of the two codes shown below is the same. i. '{0:.2f}'.format(1/3.0) ii. '%.2f'%(1/3.0)
Q25
What will be the output of the following two codes? i. '{0}'.format(4.56) ii. '{0}'.format([4.56,])