Page 13 - IPP-11
P. 13
(c) What is difference between implicit and explicit type conversion? (1)
Ans.
Implicit Conversion Explicit Conversion
Implicit Conversion is done automatically. Explicit Conversion is done by programmer.
In implicit conversion, no data loss takes place In explicit conversion, data loss may or may not
during data conversion. take place during data conversion. Hence, there
is a risk of information loss.
Implicit conversion does not require any special Explicit conversion requires cast operator to
syntax. perform conversion.
(d) What will be the output produced by the following code? (2)
A, B, C, D = 9.2, 2.0, 4, 21
print(A/4)
print(A//4)
print(B**C)
print(A%C)
Ans. Output:
2.3
2.0
16.0
1.1999999999999993
(e) Write the following arithmetic expressions using operators in Python: (2)
ab
+
(i) c = (ii) x = a + b + c 3
3
3
2a
-±b b 2 - 4ac
(iii) A = pr(r+h) 2 (iv) x =
Ans. (i) c = (a + b) / (2*a) 2a
(ii) x = a**3 + b**3 + c**3
(iii) A = math.pi *r* (r + h)**2 or A = 3.14*r*(r +h)**2
(iv) x = (–b + math.sqrt(b*b – 4*a*c))/ (2*a)
(f) Write a program to get input from the user to calculate EMI as per the formula: (3)
E=PR(1+R) / ((1+R) –1)
n
n
Where
E=EMI, P=Principal amount, R=Rate of interest, n=tenure of loan in months.
Ans. import math
p=float(input("Enter principal amount-"))
r=float(input("Enter rate of interest-"))
n=float(input("Enter tenure of loan in months-"))
e=(p*r*math.pow(1+r,n))/(math.pow(1+r,n)-1)
print("EMI :",e)
QUESTION 4
(a) What is empty statement? What is the role of empty statement? Which Python statement can be termed
as empty statement? (2)
Ans. A statement that does nothing is called an empty statement. It is used where the syntax of the language
requires the presence of statement but the logic of the program does not.
pass statement is an empty statement.
3