Unit 3 - Lesson 9 | Codetantra Python

Unit 3 - Lesson 9 | Codetantra Python

Unit 3 - Lesson 9

32.1.1. Understanding Trigonometric Functions

import math

print("degrees 0 30 45 60 90")
#convert the given degrees to radians
a=0
b=math.radians(30)
c=math.radians(45)
d=math.radians(60)
e=math.radians(90)

#print the trigoometric values of the radians for sin, cos, tan
print("sin",math.sin(a), math.sin(b), math.sin(c), math.sin(d), math.sin(e))
print("cos",math.cos(a),math.cos(b),math.cos(c),math.cos(d),math.cos(e))
print("tan",math.tan(a),math.tan(b),math.tan(c),math.tan(d),math.tan(e))

32.2.1. Understanding Mathematical Constants

(c) math.tau is equal to 2π.
(e) math.nan stands for "Not a Number".
(f) math.pi is an irrational number.

32.2.2. Program to print values of mathematical constants

#import math module
import math

print("constant value   data type")
#print value and type of pi
print("pi   ",math.pi," ",type(math.pi))

#print value and type of e
print("e    ",math.e, " ",type(math.e))

#print value and type of inf
print("inf  ", "{:17}".format(math.inf), "  ", type(math.inf))

#print value and type of nan
print("NaN  ", "{:17}".format(math.nan), "  ", type(math.nan))