CBSE Class 11 Computer Science Question 137 of 173

Data Handling — Question 26

Back to all questions
26
Question

Question 18d

Find the errors(s)

pi = 3.14
print (type (pi))
print (type ("3.14"))
print (type (float ("3.14")))
print (type (float("three point fourteen")))

Answer

In the line print (type (float("three point fourteen"))), string "three point fourteen" is given as an argument to float() but it cannot be converted into a valid floating-point number so it causes an error.

Answer