def main(): print "My application starts..." a = 2 b = 3 x = True y = False print add(a, b) print mul(a, b) print and_(x, y) print or_(x, y)
def main(): print "debut" a=2 b=3 x=True y=False print add(a,b) print nul(a,b) print and_(a,b) print or_(a,b) print or_(x,y)
def fib(x): # Takes a variable x and will find that number in the Fibonacci Sequence if x == 0: return 0 elif x == 1: return 1 else: return add(fib(subtract(x, 1)), fib(subtract(x, 2)))
def pythagorean(a, b, mode="h"): if mode == "h": c = power(add(power(a, 2), power(b, 2)), .5) #c = ((a ** 2 + b ** 2) ** (1 / 2)) else: c = power(absolute_value(subtract(power(b, 2), power(a, 2))), .5) #c = ((b ** 2 - a ** 2) ** (1 / 2)) return c
def dft(k,n, message, fullTable, expos, logs): m = generateMessage(k,n,message) t = generateTransform(n,fullTable) code = np.zeros((n,1)) for row in range(0,n): rowSum = 0 for idx, val in enumerate(t[row]): product = operators.multiply(int(val), int(m[idx,0]), expos, logs) rowSum = operators.add(rowSum, product) code[row,0] = rowSum return code
def __sub__(self, X): "Y.__sub__(X) <==> X-Y" return add(self, -X)
def __radd__(self, X): "Y.__radd__(X) <==> Y+X" return add(X, self)
def __add__(self, X): "Y.__add__(X) <==> X+Y" return add(self, X)
def __add__(self, data): return op.add(self, data)
def test_add(): a = 10 b = 20 assert operators.add(10, 20) == 30
def continuous_fib(x): for i in range(add(x, 1)): print(fib(i)) return fib(x)
print("select") print("1.add") print("2.substract") print("3.multiply") print("4.divide") print("5.power") choice=input("enter choice 1/2/3/4/5 :") x=(int(input("enter 1st"))) y=(int(input("enter 2nd value"))) if choice == "1": operators.add(x,y) elif choice == "2": operators.subtract(x,y) elif choice== "3": operators.multiply(x,y) elif choice== "4": operators.divide(x,y) elif choice== "5": operators.power(x,y) else:
import numpy import operators x = int(input("enter 1st num: ")) y = int(input("enter 2nd num: ")) ans1 = operators.add(x, y) ans2 = operators.mult(x, y) print(ans1) print(ans2)
def __rsub__(self, X): "Y.__rsub__(X) <==> Y-X" return add(X, -self)
from operators import subtract from operators import multiply from operators import divide print("select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") # Take input from the user choice = input("Enter choice(1/2/3/4: ") num1 = float(input("Enter First Number: ")) num2 = float(input("Enter Second Number: ")) if choice == '1': print(num1, "+", num2, "=", add(num1, num2)) elif choice == '2': print(num1, "-", num2, "=", subtract(num1, num2)) elif choice == '3': print(num1, "*", num2, "=", multiply(num1, num2)) elif choice == '4': print(num1, "/", num2, "=", divide(num1, num2)) else: print("Invalid Input")
def __radd__(self, data): return op.add(data, self)
def test_add(self): self.assertEquals(operators.add(2,3),5)
import qiskit from qiskit import QuantumRegister, QuantumCircuit from operators import add from utils import print_vector q = qiskit.QuantumRegister(4) a, b, s, c = q circuit = qiskit.QuantumCircuit(q) circuit.h([a, b]) add(circuit, a, b, s, c) print_vector(circuit, width=4)
def test_add(self): a = 2 b = 3 self.assertEquals(operators.add(a, b), 5)
def add256(a,b): return operators.add(int(a),int(b))