2 Commits
Author SHA1 Message Date
Daniil Doroshenko 88bfc9eefc Add formulas for pentagon 2024-04-05 17:35:50 +00:00
Daniil Doroshenko 2facbde202 Add formulas for Hexagon 2024-04-05 17:26:14 +00:00
3 changed files with 10 additions and 57 deletions
-33
View File
@@ -1,33 +0,0 @@
import circle
import square
figs = ['circle', 'square']
funcs = ['perimeter', 'area']
sizes = {}
def calc(fig, func, size):
assert fig in figs
assert func in funcs
result = eval(f'{fig}.{func}(*{size})')
print(f'{func} of {fig} is {result}')
if __name__ == "__main__":
func = ''
fig = ''
size = list()
while fig not in figs:
fig = input(f"Enter figure name, avaliable are {figs}:\n")
while func not in funcs:
func = input(f"Enter function name, avaliable are {funcs}:\n")
while len(size) != sizes.get(f"{func}-{fig}", 1):
size = list(map(int, input("Input figure sizes separated by space, 1 for circle and square\n").split(' ')))
calc(fig, func, size)
+10 -18
View File
@@ -1,21 +1,13 @@
# How to use calculator:
1. Run `python calculate.py`
2. Enter the figure name. Available are Circle, Square.
3. Enter the function: Area or Perimeter.
4. Enter figure sizes. Radius for circle, one side for square.
5. Get the answer!
# Math formulas
## Area
- Circle: `S = πR²`
- Rectangle: `S = ab`
- Square: `S = a²`
- Triangle: `S = sqrt(p * (p-a) * (p-b) * (p-c))` where p is semiperimeter
- Circle: S = πR²
- Rectangle: S = ab
- Square: S = a²
- Hexagon: S = ((3 * 3**0.5)/2)a**2
- Pentagon: S = 5/2*a*h
## Perimeter
- Circle: `P = 2πR`
- Rectangle: `P = 2a + 2b`
- Square: `P = 4a`
- Triangle: `P = a + b + c`
- Circle: P = 2πR
- Rectangle: P = 2a + 2b
- Square: P = 4a
- Hexagon: P = 6a
- Pentagon: P = 5a
-6
View File
@@ -1,6 +0,0 @@
def area(a, b, c):
return (a + b + c) / 2
def perimeter(a, b, c):
return a + b + c