-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.py
More file actions
69 lines (54 loc) · 1.06 KB
/
calc.py
File metadata and controls
69 lines (54 loc) · 1.06 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Examples
from ast import Import
import math
def add(a, b):
result = a + b
return result
def subtract(a, b):
result = a - b
return result
def multiply(a, b):
result = a * b
return result
def divide(a, b):
if b != 0:
result = a / b
return result
else:
return "Division by zero error"
def power(a, b):
result = a ** b
return result
# More Examples
def modulus(a, b):
result = a % b
return result
def floor_division(a, b):
result = a // b
return result
# Additional Examples
def square(a):
result = a * a
return result
def cube(a):
result = a * a * a
return result
# More Additional Examples
def fourth_power(a):
result = a ** 4
return result
def fifth_power(a):
result = a ** 5
return result
# Call each function and print the result
print(add(3, 4))
print(subtract(3, 4))
print(multiply(3, 4))
print(divide(3, 4))
print(power(3, 4))
print(modulus(3, 4))
print(floor_division(3, 4))
print(square(3))
print(cube(3))
print(fourth_power(3))
print(fifth_power(3))