Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions calculate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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 changes: 0 additions & 10 deletions circle.py

This file was deleted.

23 changes: 20 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@

# 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²
- Circle: `S = πR²`
- Rectangle: `S = ab`
- Square: `S = a²`
- Triangle: `S = sqrt(p * (p-a) * (p-b) * (p-c))` where p is semiperimeter

## Perimeter
<<<<<<< HEAD
- Circle: P = 2πR
- Rectangle: P = 2a + 2b
- Square: P = 4a

# Some change for Lesson 6 practice
=======
- Circle: `P = 2πR`
- Rectangle: `P = 2a + 2b`
- Square: `P = 4a`
- Triangle: `P = a + b + c`

>>>>>>> 94b208f (L-04: Experimental commit)
7 changes: 0 additions & 7 deletions square.py

This file was deleted.