Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
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)))
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
 def __sub__(self, X):
     "Y.__sub__(X) <==> X-Y"
     return add(self, -X)
Exemple #7
0
 def __radd__(self, X):
     "Y.__radd__(X) <==> Y+X"
     return add(X, self)
Exemple #8
0
 def __add__(self, X):
     "Y.__add__(X) <==> X+Y"
     return add(self, X)
Exemple #9
0
 def __sub__(self, X):
     "Y.__sub__(X) <==> X-Y"
     return add(self, -X)
Exemple #10
0
 def __add__(self, X):
     "Y.__add__(X) <==> X+Y"
     return add(self, X)
Exemple #11
0
 def __add__(self, data):
     return op.add(self, data)
def test_add():
    a = 10
    b = 20
    assert operators.add(10, 20) == 30
Exemple #13
0
def continuous_fib(x):
    for i in range(add(x, 1)):
        print(fib(i))
    return fib(x)
Exemple #14
0
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:
Exemple #15
0
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)
Exemple #16
0
 def __rsub__(self, X):
     "Y.__rsub__(X) <==> Y-X"
     return add(X, -self)
Exemple #17
0
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")
Exemple #18
0
 def __radd__(self, data):
     return op.add(data, self)
 def test_add(self):
     self.assertEquals(operators.add(2,3),5)
Exemple #20
0
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)
Exemple #21
0
 def __radd__(self, X):
     "Y.__radd__(X) <==> Y+X"
     return add(X, self)
Exemple #22
0
 def test_add(self):
     a = 2
     b = 3
     self.assertEquals(operators.add(a, b), 5)
Exemple #23
0
 def __rsub__(self, X):
     "Y.__rsub__(X) <==> Y-X"
     return add(X, -self)
Exemple #24
0
def add256(a,b):
	return operators.add(int(a),int(b))