Page 250 - Computer Science Class 11 Without Functions
P. 250
Let's Summarise
Ø Some commonly used built-in functions from the math module are illustrated in the following table:
Sr No Function Description of Return Value(s) Examples
Argument(s)
1 math.ceil(num) Integer or Ceiling (highest >>> math.ceil(13.3)
floating-point closest integer) 14
number value of num >>> math.ceil(-15.4)
-15
-16<-15.4<=-15
2 math.floor(num) Integer or floating Floor(lowest >>> math.floor(13.3)
point number closest integer) 13
value of num >>> math.floor(-15.4)
-16
3 math.fabs(num) Integer or floating Absolute value of >>> math.fabs(-14.7)
point number num (returns 14.7
floating Point >>> math.fabs(62.1)
number as 62.1
the absolute
value)
4 math.factorial(num) Positive integer Factorial of num >>> math.factorial(5)
120
5 math. Integer or floating num1%num2 >>> math.fmod(19,3)
fmod(num1,num2) point numbers (sign of num1) 1.0
6 math.gcd(num1,num2) Integers Greatest common >>> math.gcd(56,78)
divisor of num1 2
and num2 >>> math.gcd(-10,4)
2
7 math.pow(num1,num2) Integers or num1 num2 >>> math.pow(14,3)
floating point num1 raised to the 2744.0
numbers power of num2 >>> math.pow(-4,2)
16.0
8 math.sqrt(num) Positive integer Square root of num >>> math.sqrt(25)
or floating point 5.0
number >>> math.sqrt(40.5)
6.363961030678928
9 math.sin(num) Integer or floating Arc Sine of num in >>> math.sin(0)
point number in radians 0.0
radians >>> math.sin(0.2)
0.19866933079506122
10 math.cos (num) Integer or floating Arc cosine of num >>> math.cos(0)
point number in in radians 1.0
radians >>> math.cos(10)
-0.8390715290764524
11 math.tan (num) Integer or floating Arc tangent of num >>> math.tan(0)
point number in in radians 0.0
radians >>> math.tan(1)
1.5574077246549023
248 Touchpad Computer Science-XI

