ha math teacher i made a python script
This commit is contained in:
parent
1700f8dc33
commit
7518a264b8
1 changed files with 37 additions and 0 deletions
37
bin/circomference.py
Executable file
37
bin/circomference.py
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import math
|
||||
|
||||
si = input('size append d r c a> ')
|
||||
|
||||
st = si[-1:]
|
||||
|
||||
si = float(si[:-1])
|
||||
|
||||
def fromD(di):
|
||||
r = di/2
|
||||
fromR(r)
|
||||
|
||||
def fromC(ce):
|
||||
r = ce / 6.28
|
||||
fromR(r)
|
||||
|
||||
def fromA(ar):
|
||||
r = math.sqrt(ar/3.14)
|
||||
fromR(r)
|
||||
|
||||
def fromR(ra):
|
||||
print("radius",ra)
|
||||
print("diam", ra*2)
|
||||
print("cerc", 3.14 * (ra*2))
|
||||
print("area", 3.14*(ra*ra))
|
||||
|
||||
funcs = {
|
||||
'd':fromD,
|
||||
'r':fromR,
|
||||
'c':fromC,
|
||||
'a':fromA
|
||||
}
|
||||
|
||||
funcs[st](si)
|
||||
|
Loading…
Reference in a new issue