Class 11 Computer Science – Ch 8: Data Handling
Check Point 8.2
Sumita Arora Book Exercise Solution
1. What are floating point numbers? When are they preferred over integers?
Answer: Numbers having decimal points i.e. numbers written in a faction called Floating point numbers. Example: 5.2, 0.5698, 45698.3699895
The floating point number is required when you want to do calculations related to accounting and calculation needs accuracy.
2. What are complex numbers? How would Python represent a complex number with a real part as 3 and an imaginary part as 2.5?
Answer: A Complex number is in the form A + B i where i is the imaginary number equal to the square root of -1. Python represents complex numbers in the form of A + B j. That is to represent an imaginary number,
Python used j in place of traditional i. Python represents complex numbers as a pair of floating point numbers.
To represent a complex number with a real part as 3 and an imaginary part as 2.5 –
com_num = 3 + 2.5 j
3. What will be the output of following
p = 3j
q = p + ( 1 + 1.5j )
print (p)
print (q)
Answer: Output is :
3j
1 + 4.5j
Reason: p is a complex number which having only imaginary part. (1 + 1.5j) is a complex number having real part is 1 and imaginary part is 1.5j. So when you are doing arithmetic with complex number, it adds real part with real and imaginary part with imaginary.
That’s why the value of q is 1 + 4.5j
4. What will be the output of following
print (r . real)
print (r . imag)
Answer: Output :
2.5
3.9
5. Why does Python uses the symbol j to represent the imaginary part of a complex number instead of the conventional i ?
Answer: In the Electrical engineering, i is used to represent the current and they use the symbol j for the square root of -1. So for their simplicity, Python adheres to this convention.