コード例 #1
0
ファイル: run.py プロジェクト: EmersonBraun/certificates
def main():
    while True:
        print_menu()
        choice = int(input("Enter your choice [1-6]:"))
        if choice == 1:
            clear()
            add()
        elif choice == 2:
            clear()
            list_all()
        elif choice == 3:
            clear()
            report()
        elif choice == 4:
            clear()
            update()
        elif choice == 5:
            clear()
            delete()
        elif choice == 6:
            print("Exit")
            conn.close()
            exit(1)
            break
        else:
            clear()
            print("Wrong option selection.")
コード例 #2
0
def parser(komanda, repath=os.getcwd()):
    #Pretvara komandu u funkciju
    #Prima ukucanu komandu i put do repozitorijuma kao parametre

    operacija = komanda.split()
    operacija.append('')
    operacija.append('')

    if not operacija[0] in komande:
        print('Invalid command')
        return None

    if operacija[0] == 'commit':
        if operacija[1] == '-a':
            for the_file in os.listdir(repath):
                if not (the_file == '.backups' or the_file == 'stgarea'):
                    add.add(the_file, repath)
        komande[operacija[0]]()
    elif operacija[0] == 'revert':
        komande[operacija[0]](operacija[1], repath)
    elif operacija[0] == 'add':
        komande[operacija[0]](operacija[1], repath)
    elif operacija[1] == '':
        komande[operacija[0]]()
    else:
        komande[operacija[0]](operacija[1])
コード例 #3
0
ファイル: DbList_cmd.py プロジェクト: azz212/TKinterDesigner
def Button_8_onCommand(uiName, widgetName):
    topLevel = tkinter.Toplevel()
    topLevel.attributes("-toolwindow", 1)
    topLevel.wm_attributes("-topmost", 1)
    import add
    add.add(topLevel)
    tkinter.Tk.wait_window(topLevel)
コード例 #4
0
ファイル: app.py プロジェクト: viru2001/contactApp
def runApp():
    while True:
        print(
            "what you want to do ?\n1.Add Contact\n2.View all Contacts\n3.Edit Contact\n4.Delete Contact\n5.Search Contact\n6.Exit"
        )
        choice = int(input())
        if choice == 1:
            name = input("Enter a name : ")
            number = input("Enter Contact number : ")
            while not isValidPhoneNumber(number):
                print("Enter a valid phone number")
                number = input("Enter Contact number : ")
            add(name, number)
            print("contact added successfully")
        elif choice == 2:
            view()
        elif choice == 3:
            name = input("Enter a name : ")
            edit(name)
        elif choice == 4:
            name = input("Enter a name : ")
            deletee(name)
        elif choice == 5:
            search()
        elif choice == 6:
            break
        print("\n")
コード例 #5
0
ファイル: test_add.py プロジェクト: DaveVodrazka/calculator
 def test_values(self):
     # Test add for numbers
     self.assertEqual(add(5, 3), 8)
     self.assertEqual(add(0, 0), 0)
     self.assertEqual(add(-5, 3), -2)
     self.assertEqual(add(.2, 1.7), 1.9)
     self.assertEqual(add(-7.2, -1.7), -8.9)
コード例 #6
0
ファイル: main.py プロジェクト: krauson/Tic-Tac-Toe
def main():
    args = sys.argv[1:]

    if len(args) < 1:
        logging.warning('Usage: python <filename> <function> <parameters..>')

    elif args[0] == 'init':
        init()

    elif args[0] == 'add':

        data_to_copy_path = args[1]
        add(data_to_copy_path)

    elif args[0] == 'commit':
        message = args[1]
        commit(message)

    elif args[0] == 'status':
        status()

    elif args[0] == 'checkout':
        commit_id = args[1]
        checkout(commit_id)

    elif args[0] == 'graph':
        graph()

    elif args[0] == 'branch':
        branch_name = args[1]
        branch(branch_name)

    elif args[0] == 'merge':
        branch_name = args[1]
        merge()
コード例 #7
0
def Calculator():
    print("************MAIN MENU**************")
    print()

    choice = int(
        input("""
                      1: Addition
                      2: Subtraction
                      3: Division
                      4: Multiplication
                      5: Remainder
                      6: Quit/log out
                      
                      Please enter your choice: """))
    if choice == 1:
        add()
    elif choice == 2:
        subtract()
    elif choice == 3:
        divide()
    elif choice == 4:
        multiply()
    elif choice == 5:
        modulus()
    elif choice == 6:
        sys.exit
    else:
        print("You must only select either 1,2,3,4,5, or 6.")
        print("Please try again")
        Calculator()
コード例 #8
0
ファイル: main.py プロジェクト: manpreetsran93/movies_db
def main():
    """Get user input to either add movie to collection,
     view entire collection, find movie from collection,
     or enter 'Q' to quit program.

     object: dict1 is the dictionary the movie collection is stored in.

    :return:
    """

    user_command = (input("Enter 'A' to add a movie to collection\n"
                          "Enter 'V' to view entire collection\n"
                          "Enter 'F' to find a movie from collection\n"
                          "Enter 'Q' to quit\n")).lower()

    # Continue looping through until user quits program
    while user_command in {'v', 'a', 'f'}:
        # if user input is 'a' call add function from add module and pass in dict1
        if user_command == 'a':
            add(dict1)

        # if user input is 'v' call view function from view module and pass in dict1
        elif user_command == 'v':
            view(dict1)

        # if user input is 'f' call find function from find module and pass in dict1
        elif user_command == 'f':
            find(dict1)

        user_command = (input("Enter 'A' to add a movie to collection\n"
                              "Enter 'V' to view entire collection\n"
                              "Enter 'F' to find a movie from collection\n"
                              "Enter 'Q' to quit\n")).lower()
コード例 #9
0
def edit_marks(class_name):
    print('all info compile module')
    a = class_name[0]
    b = class_name[1]
    b = b.upper()
    file_name = b + '_' + str(a)
    file_name1 = file_name + '.db'
    con = _sqlite3.connect(file_name1)
    csr = con.cursor()
    try:
        a = 'select * from ' + file_name + ';'
        csr.execute(a)
        x = csr.fetchall()
        print(x)
        con.commit()
        con.close()
        a = str(input('input if you want to add(a) or modify(m) values '))
        if (a.lower() == 'a'):
            add.add_new(file_name)
        elif (a.lower() == 'm'):
            modify.modify(file_name)
        else:
            print('wrong input ')
    except:
        file_name = file_name.rstrip(';')
        add.add(file_name)
コード例 #10
0
ファイル: sub.py プロジェクト: AntonMoroziuk/long_arithmetic
def sub(a, b):
	if a < 0 and b < 0:
		return sub(b, -a)
	elif a < 0:
		return '-' + add(-a, b)
	elif b < 0:
		return add(a, -b)
	if greater(b, a):
		return '-' + sub(b, a)
	carry = 0
	i = len(b) - 1;
	j = len(a) - 1;
	res = ''
	while i >= 0:
		k = int(a[j]) - int(b[i]) - carry;
		if k < 0:
			k += 10
			carry = 1
		else:
			carry = 0
		res = str(k) + res
		i -= 1
		j -= 1
	while j >= 0:
		k = int(a[j]) - carry;
		if k < 0:
			k += 10
			carry = 1
		else:
			carry = 0
		res = str(k) + res
		j -= 1
	return res
コード例 #11
0
 def test_input_unchanged(self):
     m1 = [[6, 6], [3, 1]]
     m2 = [[1, 2], [3, 4]]
     m1_original = deepcopy(m1)
     m2_original = deepcopy(m2)
     add(m1, m2)
     self.assertEqual(m1, m1_original)
     self.assertEqual(m2, m2_original)
コード例 #12
0
 def test_any_number_of_matrixes(self):
     m1 = [[6, 6], [3, 1]]
     m2 = [[1, 2], [3, 4]]
     m3 = [[2, 1], [3, 4]]
     m4 = [[9, 9], [9, 9]]
     m5 = [[31, 32], [27, 24]]
     self.assertEqual(add(m1, m2, m3), m4)
     self.assertEqual(add(m2, m3, m1, m1, m2, m4, m1), m5)
コード例 #13
0
ファイル: test_add.py プロジェクト: tartley/romannumeral
 def test_too_many_symbols(self):
     self.assertEqual(
         add('IIIII', 'I'),
         'VI'
     )
     self.assertEqual(
         add('VVV', 'I'),
         'XVI'
     )
コード例 #14
0
 def test_input_unchanged(self):
     """ Tests for input unchanged """
     matrix_1 = [[6, 6], [3, 1]]
     matrix_2 = [[1, 2], [3, 4]]
     matrix_1_original = deepcopy(matrix_1)
     matrix_2_original = deepcopy(matrix_2)
     add(matrix_1, matrix_2)
     self.assertEqual(matrix_1, matrix_1_original)
     self.assertEqual(matrix_2, matrix_2_original)
コード例 #15
0
ファイル: test_add.py プロジェクト: tartley/romannumeral
 def test_L(self):
     self.assertEqual(
         add('L', 'II'),
         'LII'
     )
     self.assertEqual(
         add('XXXX', 'X'),
         'L'
     )
コード例 #16
0
ファイル: lgit.py プロジェクト: thuanhong/lgit
def handle_add(list_file):
    """
    execute command add
    use recursive to take file in directory if input is directory
    """
    list_path = []
    get_path_recursive(list_path, list_file)
    set_path(__file__)
    for file in list_path:
        add(file)
コード例 #17
0
ファイル: pr1.py プロジェクト: huyangh/Learn-python-100-days
def main():
    print(add(1, 2, 3))
    print(add(1, 2))
    print(add(1))
    print()
    print(addv(1, 2, 3))
    print(addv(1, 2))
    print(addv(1))
    print(addv())
    pass
コード例 #18
0
def add_entry_click(path):
    temp = []
    for i in range(len(E) - 2):
        temp.append(E[i].get())
        E[i].delete(0, len(
            temp[len(temp) -
                 1]))  # deletes the entry once add entry is clicked

    print(temp)  # prints on terminal
    A.add(temp, path)  # Adds the entry in file
コード例 #19
0
ファイル: main.py プロジェクト: PopovaMariia/homework
 def calculate():
     if symbol == '+':
         add.add()
     elif symbol == '-':
         sub.sub()
     elif symbol == '*':
         mul.mul()
     elif symbol == '/':
         div.div()
     else:
         print('Please use mathematical symbol')
コード例 #20
0
def multiply(multiplicand, multiplier, accumulator, c_multiplier, circ,
             cl_index):
    """
    Multiply two numbers stored in QuantumRegisters multiplicand and 
    multiplier using repeated fourier transform based
    addition.

    """
    try:
        from qiskit import QuantumRegister, ClassicalRegister, \
            QuantumCircuit, execute
        from qiskit import Aer
    except ImportError:
        raise QForestMathError("Please install qiskit! " +
                               "You can install it using the pip tool:" +
                               " pip install qiskit.")

    if isinstance(multiplicand, QuantumRegister) and \
            isinstance(multiplier, QuantumRegister) and \
            isinstance(accumulator, QuantumRegister) and \
            isinstance(c_multiplier, ClassicalRegister) and \
            isinstance(cl_index, int) and \
            isinstance(circ, QuantumCircuit):
        pass
    else:
        raise QForestMathError(
            "Expected three QuantumRegister" +
            " objects, one ClassicalRegister object, one " +
            "QuantumCircuit object and an integer! Please check the objects passed"
            + " to the multiply() function.")

    if len(c_multiplier) < len(multiplier):
        raise RegisterError(
            "Expected ClassicalRegister of same" +
            " or greater length than associated QuantumRegister!" +
            " Passed Register objects have lengths " + str(len(multiplier)) +
            " and " + str(len(c_multiplier)) + ".")

    d = QuantumRegister(1)
    circ.add(d)
    circ.x(d[0])

    multiplier_str = '1'

    while (int(multiplier_str) != 0):
        add.add(accumulator, multiplicand, circ)
        subtract.subtract(multiplier, d, circ)
        for i in range(len(multiplier)):
            circ.measure(multiplier[i], c_multiplier[i])
        result = execute(circ,
                         backend=Aer.get_backend('qasm_simulator'),
                         shots=2).result()
        counts = result.get_counts("qc")
        multiplier_str = list(counts.keys())[0].split()[cl_index]
コード例 #21
0
def karat(a, b):
    '''
    Implementation of the
    :param a: (int) or list reverse order
    :param b: (int) or list reverse order
    :return: a reversed list of the product a * b
    '''
    if (type(a) == int):
        a, b = create_reverse_lists(a, b)
    if len(a) == 1 and len(b) == 1:
        d, e = create_reverse_lists(a[0] * b[0], 0)
        return d
    if (len(a) > len(b)):
        b = b + [0] * (len(a) - len(b))
    if (len(b) > len(a)):
        a = a + [0] * (len(b) - len(a))
    k = len(a) // 2

    A2 = a[:k]
    A1 = a[k:]
    B2 = b[:k]
    B1 = b[k:]

    a1b1 = karat(A1, B1)
    a12b12 = karat((add(A1, A2)), (add(B1, B2)))
    a2b2 = karat(A2, B2)
    # print(a12b12)
    # print('k: ' + str(k) + '\n')
    # print ('a1b1: ' + str(a1b1))
    stepone = power(a1b1, 2 * k)
    # print('stepone: ' + str(stepone) + '\n')
    # stepone = (a1b1 * (10 ** (2 * k)))

    # print ('a12b12: ' + str(a12b12))
    steptwo = subtract(a12b12, a1b1)
    # print('steptwo: ' + str(steptwo) + '\n')
    # steptwo = (a12b12) - a1b1

    # print ('a2b2: ' + str(a2b2))
    stepthree = subtract(steptwo, a2b2)
    # print('stepthree: ' + str(stepthree) + '\n')
    # stepthree = steptwo - a2b2

    stepfour = power(stepthree, k)
    # print('stepfour: ' + str(stepfour))
    # stepfour = (10 ** k)

    stepfive = add(stepone, stepfour)
    # print('stepfive: ' + str(stepfive))

    stepsix = add(stepfive, a2b2)
    # print('stepsix: ' + str(stepsix))

    return stepsix
コード例 #22
0
ファイル: test_add.py プロジェクト: tartley/romannumeral
 def test_v(self):
     self.assertEqual(
         add('III', 'II'),
         'V'
     )
     self.assertEqual(
         add('V', 'I'),
         'VI'
     )
     self.assertEqual(
         add('V', 'II'),
         'VII'
     )
コード例 #23
0
 def test_ordering(self):
     self.assertEqual(add('I', 'V'), 'VI')
     self.assertEqual(add('I', 'X'), 'XI')
     self.assertEqual(add('V', 'X'), 'XV')
     self.assertEqual(add('V', 'VIII'), 'XIII')
     self.assertEqual(add('V', 'XVVV'), 'XXX')
     self.assertEqual(add('I', 'VV'), 'XI')
     self.assertEqual(add('X', 'V'), 'XV')
     self.assertEqual(add('XI', 'V'), 'XVI')
     self.assertEqual(add('X', 'L'), 'LX')
コード例 #24
0
ファイル: test_add.py プロジェクト: tartley/romannumeral
    def test_simple_adds(self):
        self.assertEqual(
            add('I', 'I'),
            'II'
        )

        self.assertEqual(
            add('I', 'II'),
            'III'
        )
        self.assertEqual(
            add('II', 'II'),
            'IIII'
        )
コード例 #25
0
ファイル: DbList_cmd.py プロジェクト: azz212/TKinterDesigner
def Button_13_onCommand(uiName, widgetName):
    item = GridBase.getSelected(uiName, 'TreeView_12')
    if (item == None):
        Fun.MessageBox("请先选择数据,在进行修改!")
        return
    topLevel = tkinter.Toplevel()
    topLevel.attributes("-toolwindow", 1)
    topLevel.wm_attributes("-topmost", 1)
    import add
    add.add(topLevel)
    #设置修改页的值
    Fun.SetText('add', 'Entry_5', item[0])
    Fun.SetText('add', 'Entry_6', item[1])
    Fun.SetText('add', 'Button_8', '修改')
    tkinter.Tk.wait_window(topLevel)
コード例 #26
0
def multiply(k, G):
    n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
    k %= n
    if k == 0:
        return [0, 0]
    elif k == 1:
        return G
    elif k == 2:
        return add(G, G)
    else:
        if k % 2 == 0:
            result_half = multiply(k // 2, G)
            return add(result_half, result_half)
        else:
            result_half = multiply(k // 2, G)
            return add(add(result_half, result_half), G)
コード例 #27
0
ファイル: server.py プロジェクト: odora/add-mask-and-goggle
def url():
    if request.method == 'POST':
        url = request.form['url']
        mode = (int)(request.form['mask'])
        isGoggle = request.form.get('goggle')
        if re.match(r'^https?:/{2}\w.+$', url):
            if allowed_file(url):
                filename = url.split('/')[-1]
                path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
                r = requests.get(url)
                if r.status_code == 200:
                    c = r.content
                    if not c.startswith(b'<!DOCTYPE html>'):
                        with open(path, 'wb') as f:
                            f.write(c)
                        output = add(path, filename, mode, isGoggle)
                        return render_template('index.html', output=output)
                    else:
                        return render_template('index.html',
                                               alert='URL地址无法识别!')
                else:
                    return render_template('index.html', alert='URL地址不能访问!')
            else:
                return render_template('index.html', alert='URL地址不是图片!')
        else:
            return render_template('index.html', alert='URL格式错误!')

    else:
        return render_template('index.html')
コード例 #28
0
ファイル: bilin.py プロジェクト: narasimha-123/EE3250
def bilin(p, om):
    p = np.array(p)
    N = p.shape[0]
    const = np.array([-1, 1])
    v = 1
    if (N > 2):
        for i in range(1, N):
            v = np.convolve(v, const)
            v = add(v, p[i] * polypower([1, 1], i))

        digden = v

    elif (N == 2):
        M = v.shape[0]
        v[M - 2] = v[M - 2] + p[N - 1]
        v[M - 1] = v[M - 1] + p[N - 1]
        digden = v

    else:
        digden = p

    dignum = polypower([-1, 0, 1], int((N - 1) / 2))
    G_bp = np.abs(
        np.polyval(digden, np.exp(-1j * om)) /
        np.polyval(dignum, np.exp(-1j * om)))

    return dignum, digden, G_bp
コード例 #29
0
ファイル: test_add.py プロジェクト: kjsnow/python-morsels
 def test_different_matrix_size(self):
     m1 = [[6, 6], [3, 1]]
     m2 = [[1, 2], [3, 4], [5, 6]]
     m3 = [[6, 6], [3, 1, 2]]
     # with self.assertRaises(ValueError):
     #     add(m1, m2)
     # with self.assertRaises(ValueError):
     #     add(m1, m3)
     # with self.assertRaises(ValueError):
     #     add(m1, m1, m1, m3, m1, m1)
     # with self.assertRaises(ValueError):
     #     add(m1, m1, m1, m2, m1, m1)
     self.assertRaises(ValueError, add(m1, m2))
     self.assertRaises(ValueError, add(m1, m3))
     self.assertRaises(ValueError, add(m1, m1, m1, m3, m1, m1))
     self.assertRaises(ValueError, add(m1, m1, m1, m2, m1, m1))
コード例 #30
0
ファイル: modulo.py プロジェクト: DaveVodrazka/calculator
def modulo(a, b):
    # Return the remainder of whole division
    int_check(a)
    int_check(b)
    while a >= b:
        a = add(a, -b)
    return a
コード例 #31
0
    def __call__(self, x, t):

        self.clear()
        h = F.relu(self.bn1(self.conv1(x), test=not self.train))
        h = self.res2(h, self.train)
        h = F.max_pooling_2d(h, 2, stride=2)
        h = self.res3(h, self.train)
        h = self.res4(h, self.train)
        inter = F.identity(h)
        h = self.hg1(h, self.train)

        # Residual layers at output resolution
        h = self.res5(h, self.train)
        h = F.relu(self.bn6(self.conv6(h), test=not self.train)) 
        ll_ = self.conv7(h) 

        # Predicted heatmaps
        tmpOut = self.inter_conv1(h)
        tmpOut_ = self.inter_conv2(tmpOut)
           
        h = add(ll_, tmpOut_, inter)
        h = self.hg2(h, self.train)
        h = self.res8(h, self.train)
        h = F.relu(self.bn9(self.conv9(h), test=not self.train))
        h = self.final_conv1(h)
        h = F.concat((tmpOut, h))

        t = F.concat((t, t))
         
        self.loss = F.mean_squared_error(h,t)
        if self.train:
            return self.loss
        else:
            self.pred = h
            return self.pred
コード例 #32
0
ファイル: test_add.py プロジェクト: valentk777/codewars
def test_add():
    assert add([1, 2, 3, 4, 5]) == [1, 3, 6, 10, 15]
    assert add([20, 21, 22, 23, 24, 25]) == [20, 41, 63, 86, 110, 135]
    assert add([2, 4, 6, 8, 10]) == [2, 6, 12, 20, 30]
    assert add([6, 7, 8, 9, 10, 'a', 'z']) == 'Invalid input'
    assert add([1, 4, 9, 16, 25, 36]) == [1, 5, 14, 30, 55, 91]
    assert add('Invalid input') == 'Invalid input'
    assert add([1, 2, 'a', '6', 3, 6, 's']) == 'Invalid input'
    assert add([1, 8, 27, 64, 125]) == [1, 9, 36, 100, 225]
コード例 #33
0
    def __call__(self, x, t):

        h = F.relu(self.conv1_1(x))
        h = F.relu(self.conv1_2(h))
        h = F.max_pooling_2d(h, 2, stride=2)

        h = F.relu(self.conv2_1(h))
        h = F.relu(self.conv2_2(h))
        h = F.max_pooling_2d(h, 2, stride=2)

        h = F.relu(self.conv3_1(h))
        h = F.relu(self.conv3_2(h))
        h = F.relu(self.conv3_3(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        pool3 = h

        h = F.relu(self.conv4_1(h))
        h = F.relu(self.conv4_2(h))
        h = F.relu(self.conv4_3(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        pool4 = h

        h = F.relu(self.conv5_1(h))
        h = F.relu(self.conv5_2(h))
        h = F.relu(self.conv5_3(h))
        h = F.max_pooling_2d(h, 2, stride=2)
        pool5 = h

        p3 = self.score_pool3(pool3)
        self.p3_shape = p3.data.shape

        p4 = self.score_pool4(pool4)
        self.p4_shape = p4.data.shape

        p5 = self.score_pool5(pool5)
        self.p5_shape = p5.data.shape

        u4 = self.upsample_pool4(p4)
        self.u4_shape = u4.data.shape

        u5 = self.upsample_pool5(p5)
        self.u5_shape = u5.data.shape

        h = add(p3, u4, u5)

        h = self.upsample_final(h)
        self.final_shape = h.data.shape

        self.loss = F.softmax_cross_entropy(
            h, t)  #self.loss = F.mean_squared_error(h,t)#
        if math.isnan(self.loss.data):
            raise RuntimeError("ERROR in MyFcn: loss.data is nan!")

        self.accuracy = self.calculate_accuracy(h, t)
        if self.train:
            return self.loss
        else:
            self.pred = F.softmax(h)
            return self.pred
コード例 #34
0
 def add_words(self, filename):
     print("Adding words from {}...".format(filename))
     added, skipped = set(), []
     with open(filename) as f:
         for term in f.readlines():
             term = clean_and_qualify_term(term)
             if term:
                 slug = slugify(term)
                 if slug not in added:
                     time.sleep(config.add_word_interval)
                     added.add(slug)
                     add(term)
                 else:
                     skipped.append(term)
             else:
                 skipped.append(term)
     print "Added {} terms, skipped {}".format(len(added), len(skipped))
コード例 #35
0
ファイル: multiply.py プロジェクト: uohzxela/fundamentals
def multiply(x, y):
	res = 0
	while y:
		if y & 1:
			res = add(res, x)
		y >>= 1
		x <<= 1
	return res
コード例 #36
0
 def add_words(self, filename):
     print("Adding words from {}...".format(filename))
     added, skipped = set(), []
     with open(filename) as f:
         for term in f.readlines():
             term = clean_and_qualify_term(term)
             if term:
                 slug = slugify(term)
                 if slug not in added:
                     time.sleep(config.add_word_interval)
                     added.add(slug)
                     add(term)
                 else:
                     skipped.append(term)
             else:
                 skipped.append(term)
     print "Added {} terms, skipped {}".format(len(added), len(skipped))
コード例 #37
0
ファイル: dummy.py プロジェクト: hn269/dummy
def calc(n1, op, n2):
    result = 0
    if op == "+":
        from add import add

        result = add(n1, n2)
        return result
    else:
        if op == "-":
            from sub import sub

            result = sub(n1, n2)
            return result
        else:
            print "dummy does not support this operation"
コード例 #38
0
ファイル: test_add.py プロジェクト: tartley/romannumeral
 def test_ordering(self):
     self.assertEqual(
         add('I', 'V'),
         'VI'
     )
     self.assertEqual(
         add('I', 'X'),
         'XI'
     )
     self.assertEqual(
         add('V', 'X'),
         'XV'
     )
     self.assertEqual(
         add('V', 'VIII'),
         'XIII'
     )
     self.assertEqual(
         add('V', 'XVVV'),
         'XXX'
     )
     self.assertEqual(
         add('I', 'VV'),
         'XI'
     )
     self.assertEqual(
         add('X', 'V'),
         'XV'
     )
     self.assertEqual(
         add('XI', 'V'),
         'XVI'
     )
     self.assertEqual(
         add('X', 'L'),
         'LX'
     )
コード例 #39
0
 def test_long_delimiter(self):
     self.assertEqual(10, add("//[...]\n1...2...3...4"))
コード例 #40
0
from div import divide
from sub import substract
import math
prev=0;
while 1:
	print "Enter your choice \n Arithmetic\n1.Addition\n2.Substraction\n3.Multiplication\n4.Division\nTrigonometric\n5.sin\n6.cos\n7.tan\n8.cot\n9.sec\n10.cosec\n11.Exit";
	c=input();
#ADD
	if c==1:
		if prev==0:
			a=input("Enter one number");
			b=input("Enter another number");
		elif prev==1:
			a=k;
			b=input("Enter another number");
		k=add(a,b);
		print "The current sum is "+str(k);
#SUBSTRACT
	elif c==2:
		if prev==0:
			a=input("Enter one minuend");
			b=input("Enter subtrahend");
		elif prev==1:
                        while 1:
				print "Enter your choice\n1.Use answer as minuend\n2.Use answer as subtrahend";
				e=input();
				if e==1:
					a=k;
					b=input("Enter subtrahend");
					break;
				elif e==2:
コード例 #41
0
ファイル: main.py プロジェクト: ValentinaSinitsyna/spam
import buy as b
import add as a
import inf as i
import delete as d


while 1:
    print(' 1:продажа товара\n 2:поставка товара\n 3:данные по продажам\n 4:удалить\n 0:выход \n')
    c=input("введите номер пункта меню")
    if c=='1': b.buy()
    if c=='2': a.add()
    if c=='3': i.inf()
    if c=='4': d.delete()
    if c=='0': break
コード例 #42
0
ファイル: main.py プロジェクト: alexlibi/save
import add, sub, mult_div, getopt, sys

if __name__ == '__main__':
    
    try:
        arg, opt = getopt.getopt(sys.argv[1:],"a:")
    except getopt.GetoptError as err:
        sys.exit(2)
    
    a, b=float(opt[0]), float(opt[1])
        
    print(add.add(a,b))
    print(sub.sub(a,b))
    print(mult_div.div(a, b))
    print(mult_div.div(a, b))
コード例 #43
0
 def test_one_hundred(self):
     self.assertEqual(2, add("2,1001"))
     self.assertEqual(1002, add("2,1000"))
コード例 #44
0
ファイル: test_add.py プロジェクト: sastryduri/core
 def test_add(self):
     self.assertEqual(7, add.add(3,4))
コード例 #45
0
ファイル: test.py プロジェクト: Taps1/Junkkk_Box
	def test_add_two_numbers(self):
		result=add(10,1)
		print result
		assert 11==result
		print "Test Case 1 is executed successfully"
コード例 #46
0
 def test_empty(self):
     self.assertEqual(0, add())
     self.assertEqual(0, add(""))
     self.assertEqual(0, add(None))
コード例 #47
0
def test_negative():
    assert add.add(-12, 5) == -7
コード例 #48
0
 def test_add_return_sum_of_two_value(self):
     result = add(1, 2)
     self.assertEqual(result, 3)
コード例 #49
0
 def test_multiple_delimiters(self):
     self.assertEqual(10, add("//[..][oo]\n1..2\n3oo4"))
     self.assertEqual(20, add("//[..][oo]\n1..2\n3oo4..10"))
コード例 #50
0
def test_add():
    assert(add(0,0) == 0)
    assert(add(12,2) == 14)
コード例 #51
0
def test_basic():
    assert add.add(3,4) == 7
コード例 #52
0
 def test_6_6(self):
     self.assertEqual(6+6, add(6,6))
コード例 #53
0
def test_float():
    with pytest.raises(TypeError):
        add.add(3, 4.0)
コード例 #54
0
 def test_6_7(self):
     self.assertEqual(6+7, add(6,7))
コード例 #55
0
 def test_6_8(self):
     self.assertEqual(6+8, add(6,8))
コード例 #56
0
ファイル: test_add.py プロジェクト: yohhoy/practice
 def test_add(self):
     self.assertEqual(add(1, 2), 3)
コード例 #57
0
ファイル: test.py プロジェクト: Taps1/Junkkk_Box
	def test_add_lists(self):
		result=add(["Hello"],["Talat"])
		print result
		assert ['Hello','Talat']==result
		print "Test Case 3 is executed successfully"
コード例 #58
0
ファイル: 00test.py プロジェクト: podhmo/individual-sandbox
 def _callFUT(self, x, y):
     from add import add
     return add(x, y)
コード例 #59
0
ファイル: test.py プロジェクト: Taps1/Junkkk_Box
	def test_add_strings(self):
		result=add("User","Case")
		print result
		assert "UserCase"==result
		print "Test Case 2 is executed successfully"
コード例 #60
0
def postProcess(up, post, c):
   postkeys = post.keys()
   if not len(postkeys):
      return

   # for each host in turn...
   for i in up:
      spoofStr = getIp(i) + ':' + i

      if i not in postkeys:
         sys.stderr.write( 'ipmiLanGmetric: Error: host ' + i + ' not in post\n' )
         continue
      h = post[i]

      # power ->
      #   add up the ps0 and ps1 and print a total for 'in' == cmm_power_in, 'out' == cmm_power_out
      if 'power' not in h.keys():
         sys.stderr.write( 'ipmiLanGmetric: Error: host ' + i + ' no power field\n' )
      else:
         p = h['power']
         if len(p) != 4:
            sys.stderr.write( 'ipmiLanGmetric: Error: host ' + i + ' not 4 power entries\n' )
         p_in = 0.0
         p_out = 0.0
         inCnt = 0
         outCnt = 0
         for t, v in p:
            # tag, val -> cmm_ps0_in, cmm_ps1_out, ...
            if t[-3:] == '_in':
               p_in += float(v)
               inCnt += 1
            else:
               p_out += float(v)
               outCnt += 1

         if inCnt == 2:
            c.append( '/usr/bin/gmetric -S ' + spoofStr + ' -t float -n "cmm_power_in" -u "W" -v %.2f\n' % p_in )
         if outCnt == 2:
            c.append( '/usr/bin/gmetric -S ' + spoofStr + ' -t float -n "cmm_power_out" -u "W" -v %.2f\n' % p_out )

      # fans ->
      #   add up all the fans on this cmm and compute stats
      if 'fans' not in h.keys():
         sys.stderr.write( 'ipmiLanGmetric: Error: host ' + i + ' no fans field\n' )
      else:
         p = h['fans']
         if len(p) != 16:
            sys.stderr.write( 'ipmiLanGmetric: Error: host ' + i + ' not 16 power entries\n' )
         ff = []
         for t, v in p:
            # fm0_f0 ... fm7_f1
            ff.append( str(v) )
         a = add.add()
         a.ll = ff
         a.process()

         dtype = 'float'
         d = 'fan_'
         unit = 'RPM'
         for f in ( 'ave', 'rms', 'min', 'max', 'sigma' ):
            val = a.q[f][0]
            # maybe add -x maxTime ?
            c.append( '/usr/bin/gmetric -S ' + spoofStr + ' -t ' + dtype + ' -n "' + d + f + '" -u "' + unit + '" -v %.2f\n' % val )