|
| 1 | +#Python | math() function |
| 2 | + |
| 3 | +import math |
| 4 | + |
| 5 | +# Python code to demonstrate the working of |
| 6 | + |
| 7 | +#demonstrate of math module to pi value |
| 8 | +print ("The pi value is : ", end="") |
| 9 | +print (math.pi) |
| 10 | + |
| 11 | +#demonstrate of math module to math e value |
| 12 | +print ("The math e value is : ", end="") |
| 13 | +print (math.e) |
| 14 | + |
| 15 | +#demonstrate of math module sin formula |
| 16 | +print ("The sin(10) value is : ", end="") |
| 17 | +print (math.sin(10)) |
| 18 | + |
| 19 | +#demonstrate of math module cos formula |
| 20 | +print ("The cos(10) value is : ", end="") |
| 21 | +print (math.cos(10)) |
| 22 | + |
| 23 | +#demonstrate of math module log10 formula |
| 24 | +print ("The log10(10) value is : ", end="") |
| 25 | +print (math.log10(10)) |
| 26 | + |
| 27 | +#demonstrate of math module for factorial function |
| 28 | +print ("The factorial value of 5 is : ", end="") |
| 29 | +print (math.factorial(5)) |
| 30 | + |
| 31 | +#demonstrate of math module for square root function |
| 32 | +print ("The square root value of 9 is : ", end="") |
| 33 | +print (math.sqrt(9)) |
| 34 | + |
| 35 | +# Python code to demonstrate the working of |
| 36 | +# ceil() and floor() |
| 37 | + |
| 38 | +a = 2.3 |
| 39 | + |
| 40 | +# returning the ceil of 2.3 |
| 41 | +print ("The ceil of 2.3 is : ", end="") |
| 42 | +print (math.ceil(a)) |
| 43 | + |
| 44 | +# returning the floor of 2.3 |
| 45 | +print ("The floor of 2.3 is : ", end="") |
| 46 | +print (math.floor(a)) |
| 47 | + |
| 48 | + |
| 49 | +# Python code to demonstrate the working of |
| 50 | +# fabs() and factorial() |
| 51 | + |
| 52 | +a = -10 |
| 53 | +b= 5 |
| 54 | + |
| 55 | +# returning the absolute value. |
| 56 | +print ("The absolute value of -10 is : ", end="") |
| 57 | +print (math.fabs(a)) |
| 58 | + |
| 59 | +# returning the factorial of 5 |
| 60 | +print ("The factorial of 5 is : ", end="") |
| 61 | +print (math.factorial(b)) |
0 commit comments