11. Hexadecimal values in Python are represented as :
a. Ox
b. oX
c. 0x
d. Ohex
View Answer
Ans. c
Explanation : 0x is used to represent the Hexadecimal values.
12. Find the output :
def sample(v1,v2,v3=10,v4=3,*v5):
v4+=2
v2= v1*v4
for v in v5:
v = v*v
print(v5)
sample(0,0,1,2,3,4,5)
What will the value of v5 ?
a. (1,2,3,4,5)
b. 3
c. Type Error
d. (3,4,5)
View Answer
Ans. d
Explanation : v1=0, v2=0, v3=1, v4=4, v5=(3, 4, 5)
13. Find the output :
class A:
def __init__(self,x=3):
self._x = x
class B(A):
def __init__(self):
super().__init__(5)
def display(self):
print(self._x)
def main():
obj = B()
obj.display()
main()
a. 5
b. 3
c. Error, class member x has two values
d. Error, protected class member can’t be accessed in a subclass
View Answer
Ans. a
Explanation : init of super class is called with x = 5
14. Find the output :
class A:
def __init__(self,x=3):
self._x = x
class B(A):
def __init__(self):
super().__init__()
def display(self):
print(self._x)
def main():
obj = B()
obj.display()
main()
a. 5
b. 3
c. Runtime Error
d. Error, protected class member can’t be accessed in a subclass
View Answer
Ans: b
Explanation : __init__ of super class is called assigning x = 3
15. Consider the following code below code using ‘Logic Coverage’ technique
if item_type =="Fashion":
if amount>500 and amount<=1000:
amount=amount-0.1*amount
elif item_type=="Electronics":
if amount>10000 and amount<15000:
amount=amount-0.15*amount
else:
if amount>2000:
amount= amount- 0.07*amount
print("final amount", amount)
a. Item_type : “Fashion” with amount as 100, “Electronics” with amount 2001.
b. Item_type : “Fashion” with amount as 700, “Electronics” with amount 7000,”Sports” with amount as -1500.
c. Item_type : “Fashion” with amount as 800, “Electronics” with amount 14999,”Sports” with amount as 2300.
d. Item_type : “Fashion” with amount as 760, “Electronics” with amount 5030,”Sports” with amount as 230.
View Answer
Ans. c
Explanation : Option ‘c’ covers all conditions