calc outputs
This commit is contained in:
parent
48a12044e7
commit
91842f6d1f
Binary file not shown.
|
@ -11,6 +11,59 @@ types = {
|
|||
'c': 'c'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def fromD(di):
|
||||
r = di/2
|
||||
return r
|
||||
|
||||
def fromC(ce):
|
||||
r = ce / 6.28
|
||||
return r
|
||||
|
||||
def fromA(ar):
|
||||
r = math.sqrt(ar/3.14)
|
||||
return r
|
||||
|
||||
def fromR(r):
|
||||
return r
|
||||
|
||||
fr = {
|
||||
'r': fromR,
|
||||
'd': fromD,
|
||||
'a': fromA,
|
||||
'c': fromC
|
||||
}
|
||||
|
||||
|
||||
|
||||
def rOP(self, t, i):
|
||||
r = fr[t](i)
|
||||
return "the radius of your circle is {} units".format(r)
|
||||
|
||||
def dOP(self, t, i):
|
||||
r = fr[t](i)
|
||||
return "the diameter of your circle is {} units".format(r*2)
|
||||
|
||||
def aOP(self, t, i):
|
||||
r = fr[t](i)
|
||||
return "the area of your circle is {} units".format(3.14 * (ra*2))
|
||||
|
||||
def cOP(self, t, i):
|
||||
r = fr[t](i)
|
||||
return "the circumference of your circle is {} units".format(3.14*(ra*ra))
|
||||
|
||||
ops = {
|
||||
'r': rOP
|
||||
'd': dOP,
|
||||
'a': aOP,
|
||||
'c': cOP
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def gettype(inp):
|
||||
i = inp[-1:]
|
||||
if i in types:
|
||||
|
@ -31,7 +84,7 @@ def circle(self, c,n,m):
|
|||
return
|
||||
t = gettype(m[0])
|
||||
m = float(m[0][:-1])
|
||||
self.say(c,"operation {} output type {} input {}".format(o,t,m))
|
||||
self.say(c, ops[o](self, t, m))
|
||||
|
||||
def init(self):
|
||||
self.registerCommand('circle', circle)
|
||||
|
|
Loading…
Reference in New Issue