forked from david-gary/CalculatorLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscientificOperations.py
More file actions
36 lines (27 loc) · 1012 Bytes
/
scientificOperations.py
File metadata and controls
36 lines (27 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import math
def scientific_calculate(operation, num1):
"""
Performs the given scientific operation on the given number, which may be either an integer or a float.
args:
- operation: the operation to perform (sin, cos, tan, ln)
- num1: the number to perform the operation on
returns:
- the result of the operation on the given number
"""
if operation == 'sin':
return math.sin(num1)
elif operation == 'cos':
# TODO: finish this statement
# - should return the cosine of num1
return math.cos(num1)
elif operation == 'tan':
# TODO: finish this statement
# - should return the tangent of num1
return math.tan(num1)
elif operation == 'ln':
# TODO: finish this statement
# - should return the natural log of num1
return math.ln(num1)
else:
raise ValueError(
'Invalid Operation: Scientific Operations are (sin, cos, tan, ln, sqrt, !, ^, and %)')