Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is the output of the following piece of code?
class Demo:
def __check(self):
return " Demo's check "
def display(self):
print(self.check())
class Demo_Derived(Demo):
def __check(self):
return " Derived's check "
Demo().display()
Demo_Derived().display()
Correct Answer is : Demo’s check Demo’s check
2. What is the output of the following piece of code?
class A:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return 1
def __eq__(self, other):
return self.x * self.y == other.x * other.y
obj1 = A(5, 2)
obj2 = A(2, 5)
print(obj1 == obj2)
Correct Answer is : TRUE
3. What is the output of the following piece of code?
class A:
def one(self):
return self.two()
def two(self):
return 'A'
class B(A):
def two(self):
return 'B'
obj2=B()
print(obj2.two())
Correct Answer is : B
4. Which of the following statements is true?
Correct Answer is : A non-private method in a superclass can be overridden
5. The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same. State whether true or false.
Correct Answer is : TRUE
6. The value of the expression:
4 + 3 % 5
Correct Answer is : 7
7. Evaluate the expression given below if A= 16 and B = 15.
A % B // A
Correct Answer is : 0
8. Which of the following operators has its associativity from right to left?
Correct Answer is : **
9. What is the value of x if:
x = int(43.55+2/2)
Correct Answer is : 44
10. What is the value of the following expression?
2+4.00, 2**4.0
Correct Answer is : (6.0, 16.0)
11. Which of the following is the truncation division operator?
Correct Answer is : //
12. What are the values of the following expressions:
2**(3**2)
(2**3)**2
2**3**2
Correct Answer is : 512, 64, 512
13. What is the value of the following expression:
8/4/2, 8/(4/2)
Correct Answer is : (1.0, 4.0)
14. What is the value of the following expression:
float(22//3+3/3)
Correct Answer is : 8
15. What is the output of the following expression:
print(4.00/(2.0+2.0))
Correct Answer is : 1
16. Consider the expression given below. The value of X is:
X = 2+9*((3*12)-8)/10
Correct Answer is : 27.2
17. Which of the following expressions involves coercion when evaluated in Python?
Correct Answer is : 1.7 % 2
18. What is the value of the following expression:
24//6%3, 24//4//2
Correct Answer is : (1,3)
19. Which among the following list of operators has the highest precedence?
+, -, **, %, /, <<, >>, |
Correct Answer is : **
20. What is the value of the expression:
float(4+int(2.39)%2)