Advertisements
Advertisements
Question
Observe the following program carefully, and identify the error:
from math import sqrt,ceil
def calc():
print cos(0)
calc() #function callShort/Brief Note
Advertisements
Solution
There are two errors in the given program.
- Only square root (sqrt) and ceiling (ceil) functions have been imported from the Math module, but here cosine function (cos) is used. ‘from math import cos’ should be written in the first line for the 'cos' function to work properly.
- The syntax of the ‘print’ function is incorrect. The correct syntax will be ‘print(cos(0))’.
shaalaa.com
Module
Is there an error in this question or solution?
