forked from aowens04/git_practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
45 lines (34 loc) · 926 Bytes
/
Copy pathcalculator.py
File metadata and controls
45 lines (34 loc) · 926 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
37
38
39
40
41
42
43
44
45
# Simple Calculator
# Calculator - Updated from GitHub Web Interface
def add(a,b):
return a + b
def subtract(a,b):
return a - b
def multiply(a,b):
a * b
def divide(a,b):
if b == 0:
return "Error: Cannot divide by zero"
return a / b
def power(a, b):
return a ** b
# Work in progress
def new_feature():
pass
# Critical fix
def square(a):
"""Return the square of a number"""
return a**2
def cube(a):
"""Return the cube of a number"""
return a**3
def percentage(value, percent):
"""Calculate percentage of a value"""
return (value * percent) / 100
if __name__ == "__main__":
print("Calculator loaded!")
print('Calculator ready!')
print(f"5 + 3 = {add(5,3)}")
print(f"10 - 4 = {subtract(10, 4)}")
print(f"5 squared = {square(5)}")
print(f"3 cubed = {cube(3)}")