コード例 #1
0
ファイル: real.py プロジェクト: bzhan/holpy
 def rec(t):
     if t.is_number():
         return t.dest_number()
     elif t.is_comb('of_nat', 1):
         return nat.nat_eval(t.arg)
     elif t.is_comb('of_int', 1):
         return integer.int_eval(t.arg)
     elif t.is_plus():
         return rec(t.arg1) + rec(t.arg)
     elif t.is_minus():
         return rec(t.arg1) - rec(t.arg)
     elif t.is_uminus():
         return -rec(t.arg)
     elif t.is_times():
         return rec(t.arg1) * rec(t.arg)
     elif t.is_divides():
         denom = rec(t.arg)
         if denom == 0:
             raise ConvException('real_approx_eval: divide by zero')
         else:
             return rec(t.arg1) / denom
     elif t.is_real_inverse():
         denom = rec(t.arg)
         if denom == 0:
             raise ConvException('real_approx_eval: divide by zero')
         else:
             return 1 / denom
     elif t.is_nat_power():
         return rec(t.arg1)**nat.nat_eval(t.arg)
     elif t.is_real_power():
         x, p = rec(t.arg1), rec(t.arg)
         return x**p
     elif t.is_comb() and t.head == sqrt:
         return math.sqrt(rec(t.arg))
     elif t == pi:
         return math.pi
     elif t.is_comb() and t.head == sin:
         return math.sin(rec(t.arg))
     elif t.is_comb() and t.head == cos:
         return math.cos(rec(t.arg))
     elif t.is_comb() and t.head == tan:
         return math.tan(rec(t.arg))
     elif t.is_comb() and t.head == cot:
         return math.cot(rec(t.arg))
     elif t.is_comb() and t.head == sec:
         return math.sec(rec(t.arg))
     elif t.is_comb() and t.head == csc:
         return math.csc(rec(t.arg))
     elif t.is_comb() and t.head == atn:
         return math.atan(rec(t.arg))
     elif t.is_comb() and t.head == log:
         return math.log(rec(t.arg))
     elif t.is_comb() and t.head == exp:
         return math.exp(rec(t.arg))
     elif t.is_comb() and t.head == hol_abs:
         return abs(rec(t.arg))
     else:
         raise NotImplementedError
コード例 #2
0
def sec():
    try:
        val = math.sec(eval(equation.get()))
    except ValueError or ZeroDivisionError or SyntaxError or NameError:
        equation.delete(0, END)
        equation.insert(0, 'Invalid Input')
        err = messagebox.showwarning(title='Invalid Input',
                                     message='Please Input valid Syntax')
        if err == 'ok':
            equation.delete(0, END)
    else:
        equation.delete(0, END)
        equation.insert(0, val)
コード例 #3
0
ファイル: calculator.py プロジェクト: shashankgandham/darsy
 def p_expresssion_unop(t):
     '''expression : LOG expression | TRIGO expression'''
     if 'log' in t[1].lower():
         t[0] = math.log(t[2])
     if 'sin' in t[1].lower():
         t[0] = math.sin(math.radians(t[2]))
     if 'cos' in t[1].lower():
         t[0] = math.cos(math.radians(t[2]))
     if 'tan' in t[1].lower():
         t[0] = math.tan(math.radians(t[2]))
     if 'cosec' in t[1].lower():
         t[0] = math.cosec(math.radians(t[2]))
     if 'cot' in t[1].lower():
         t[0] = math.cot(math.radians(t[2]))
     if 'sec' in t[1].lower():
         t[0] = math.sec(math.radians(t[2]))
コード例 #4
0
ファイル: trigonometry.py プロジェクト: yashverma38/visma
 def calculate(self, val):
     return self.coefficient * ((math.sec(val))**self.power)
コード例 #5
0
ファイル: math.py プロジェクト: satyamyadav-bot/MEGASTAR
async def find_sec(event):
    input_str = float(event.pattern_match.group(1))
    output = math.sec(input_str)
    await event.edit(f"**Value of Sec {input_str}\n==>>**`{output}`")
コード例 #6
0
import math as n
log = n.log10(100)
print(log)
log1 = n.log10(100.12)
print(log1)
#i=int(input('Enter the value of angle')
i = 0
cos = n.cos(i)
print("the value of cos(0)  ", cos)
sine = n.sin(i)
print('the value of sine(0)', sine)
tan = n.tan(i)
print('the value of tan (0)', tan)
cot = n.cot(i)
print('the value of cot (0)', cot)
sec = n.sec(i)
print('the value of sec (0)', sec)
コード例 #7
0
 def sec(self):
     self.current = float(self.current)
     self.current = float(math.sec((self.current)))
     text_box.delete(0, END)
     text_box.insert(0, self.current)
     self.new_num = True
コード例 #8
0
ファイル: solve.py プロジェクト: shreyash/project-calculator
 def sec(self, exp):
     if self.rad:
         return round(math.sec(exp), self.round_digit)
     else:
         return round(math.sec(math.radians(exp)), self.round_digit)
コード例 #9
0
def sec_val(r):
	p = m.sec(r)
	return p
コード例 #10
0
#arithmetic operations
print(10+3)#addition
print(10/3)#Divison (gives result in float form)
print(10//3)#Divison (gives result in int form)
print(5%2)#Modulus (Gives remainder of divison)
print(10**4)#Exponent
print(10*5)#Multiplication
print(100-45)#Subtraction
x=10
x=x+3 #Long form
x+=3 #Short form
print(x)
y=10+3*2**2#Operator precedence (Always follows BODMAS Rule
print(y)
z= (10+3)*2**2#Paranthesis takes importance first)
a=2.9
print(round(a))#Rounding off
print(abs(a))#Gives absolute value of numbers
import math
print(math.ceil(a))#prints ceiling of a number
print(math.tan(a))#finds tan of any value
print(math.cos(a))#finds cos of any value
print(math.sin(a))#finds sin of any value
print(math.cosec(a))#finds cosec of any value
print(math.sec(a))#finds sec of any value


コード例 #11
0
ファイル: functions.py プロジェクト: billmoyers/misc-python
	def _reduce(self, **methods):
		if isinstance(self.children[0], Constant):
			return Constant(math.sec(self.children[0].getValue()))
		else:
			return self