def tan(x): """ Action: The trigonometric function, tangent. :param x: an angle in degrees :return: result, float """ return tangent(degrees2radians(x))
import math as fun print("List of object names in __main__ namespace") print("After 'import math as fun' has executed:\n",dir()) print("The value of pi is: ",fun.pi) print("The tangent of 1 is: ",fun.tan(1)) del (fun) print() print("List of object names in __main__ namespace: \n",dir()) from math import pi, tan print("List of object names in __main__ namespace") print("After 'from math import pi, tan' has executed:\n",dir()) print("The value of pi is: ",pi) print("The tangent of 1 is: ",tan(1)) del (pi) del(tan) print() print("List of object names in __main__ namespace: \n",dir()) from math import pi as pie, tan as tangent print("List of object names in __main__ namespace") print("After 'from math import pi as pie, tan as tangent' has executed:\n",dir()) print("The value of pi is: ",pie) print("The tangent of 1 is: ",tangent(1)) del (pie) del(tangent) print() print("You want to avoid polluting the __main__ namespace like this: ") print(dir())
import random # fully for i in range(5): value = random.randint(1, 6) print(value) from math import pi #just one print(pi) from math import sqrt, cos #various import math print(math.cos == cos) from math import sqrt as square_root #import as a diferent name print(square_root(100)) from math import sqrt as square_root, cos as cosine, tan as tangent print(square_root(49)) print(cosine(0)) print(tangent(45)) print(dir(math)) import math as m print(math.sqrt(25))
print(dir()) from math import pi, tan print('List of object names in __main__ namespace', end=' ') print('after "from math import pi, tan" has executed:') print(dir()) print('The value of pi is', pi) print('The tangent of 1 is', tan(1)) del (pi) del (tan) # Import selectively with aliases into __main__ namespace print('List of object names in __main__ namespace:') print(dir()) from math import pi as pie, tan as tangent print('List of object names in __main__ namespace', end=' ') print('after "from math import pi, tan" has executed:') print(dir()) print('The value of pi is', pie) print('The tangent of 1 is', tangent(1)) del (pie) del (tangent) # Unless you are experimenting in the shell avoid "wildcard imports" as every # name in the module's namespace will be in the __main__namespace from math import * print('YOu want to avoid polluting the __main__namespace like this: ') print(dir())
print(dir()) from math import pi, tan print('List of object names in __main__ namespace', end=' ') print('"from math import pi as Pie, tan as tangent" has executed:') print(dir()) print('The value of pi is', pi) print('The value of 1 is', tan(1)) del (pi) del (tan) # use selectively the data attributes for "math" module print('List of objects names in __main__ namespace:') print(dir()) from math import pi as pie, tan as tangent print('List of object names in __main__ namespace', end=' ') print('"from math import pi as Pie, tan as tangent" has executed:') print(dir()) print('The value of pi is', pie) print('The value of 1 is', tangent(1)) del (pie) del (tangent) #wildcard usage of module namespace from math import * print('you want to avoid using this:') print(dir())
# Import a module from standard library import math print(math.cos(0)) print('-----------------------') # Import specific functions from standard library from math import sin, cos print(sin(0)) print(cos(0)) print('-----------------------') # Import a specific function from standard library with renaming from math import tan as tangent print(math.tan(0.1234)) print(tangent(0.1234))
def apothem(self): rads = radians(180/self.num_sides) return self.side_length / (2 * tangent(rads)) #the result is limited to 16 digits
import math print("Welcome to degree finder app") number = (input("Enter thr degree value to find in sin,cosine and tangent ")) search = int(input("Enter number to find it degree")) if number == "sin": degree = math.sin(search) print(degree) elif number == "cos": degree = math.cos(search) print(degree) elif number == "tangent": degree = math.tangent(search) print(degree)
# Import selectively into __main__ namespace print('List of object names in __main__ namespace:') print(dir()) from math import pi, tan print('List of object names in __main__ namespace', end=' ') print('after "from math import pi, tan" has executed:') print(dir()) print('The value of pi is', pi) print('The tangent of 1 is', tan(1)) del (pi) del (tan) # Import selectively with aliases into __main__ namespace print('List of object names in __main__ namespace:') print(dir()) from math import pi as pie, tan as tangent print('List of object names in __main__ namespace after', end=' ') print('"from math import pi as pie, tan as tangent" has executed:') print(dir()) print('the value of pi is', pie) print('the value of tan is', tangent(1)) del (pie) del (tangent) # Unless experimenting in the shell avoid "wildcard imports" as every # name in the module's namespace will be in the __main__ namespace from math import * print('You want to avoid polluting the __main__ namespace like this:') print(dir())
def apothem(self): rads = radians(180 / self.num_sides) return self.side_length / (2 * tangent(rads))