Beispiel #1
0
    def asHtml(self, level):
        """
            redefine html output for this object
            contents are put in header (usually brand)
            navigation table used to generate navlist
        """
        div_navbar_main = div.div('navbar-collapse collapse')
        div_navbar_main.add(self._nav_list(self.navmenu))

        div_navbar = div.div('navbar navbar-default').add(
            div.div('navbar-header').addList(self.contents).add(
                # mobile navbar ugliness
                pui.element(
                    'button',
                    _class='navbar-toggle',
                    type='button',
                    data_toggle='collapse',
                    data_target='.navbar-main'
                ).add(
                    pui.element('span', _class='icon-bar'),
                    pui.element('span', _class='icon-bar'),
                    pui.element('span', _class='icon-bar'),
                )
            ),
            div_navbar_main
        )

        return div_navbar.asHtml(level)
Beispiel #2
0
 def calculate():
     if symbol == '+':
         add.add()
     elif symbol == '-':
         sub.sub()
     elif symbol == '*':
         mul.mul()
     elif symbol == '/':
         div.div()
     else:
         print('Please use mathematical symbol')
def test_div(dividend, divisor):
    if divisor == 0:
        expected = -1
    else:
        expected = dividend // divisor
    actual = div(dividend, divisor)
    assert actual == expected
def main():
    """
    实例:测试多个命令,sum,sub,div
         依次添加命令,并为命令添加参数
    """
    # 创建解析对象
    parser = argparse.ArgumentParser(description="")
    # 需要解析多个命令时,创建子对象
    subparser = parser.add_subparsers(dest="command", help="commands")

    # 添加子命令,并为子命令添加参数
    parser_sum = subparser.add_parser("sum")
    parser_sum.add_argument("x", type=int)
    parser_sum.add_argument("y", type=int)

    parser_sub = subparser.add_parser("sub")
    parser_sub.add_argument("x", type=int)
    parser_sub.add_argument("y", type=int)

    parser_div = subparser.add_parser("div")
    parser_div.add_argument("x", type=int)
    parser_div.add_argument("y", type=int)

    args = parser.parse_args()

    command = args.command
    if command == "sum":
        print(sum(args.x, args.y))
    elif command == "sub":
        print(sub(args.x, args.y))
    elif command == "div":
        print(div(args.x, args.y))
    else:
        parser.parse_args(["--help"])
Beispiel #5
0
def test_div():
    for a, b in [
        (0, 1234),
        (9, 10),
        (10, 10),
        (11, 10),
        (1729, 10),
        (5673892567438593, 5465),
    ]:
        d, m = div.div(a, b)
        assert d == int(a / b)
        assert m == a % b
Beispiel #6
0
def main():

    while True:

        try:
            var_a = input('Введите первое число: ')
            if var_a == "exit":
                print('Выход')
                exit()
            else:
                var_a = float(var_a)
                pass

            var_c = input("Введите знак операции (+,-,*,/): ")

            if var_c in ('+', '-', '*', '/'):
                pass
            else:
                print("Неправильный знак. Попробуйте еще раз...")
                continue

            var_b = float(input('Введите второе число: '))

        except (TypeError, ValueError):
            print("Неправильный ввод. Попробуйте еще раз...")
            continue
        break

    if var_c == "/":
        count = div.div(var_a, var_b)

    elif var_c == "*":
        count = mult.mult(var_a, var_b)
    elif var_c == "+":
        count = add.add(var_a, var_b)
    elif var_c == '-':
        count = sub.sub(var_a, var_b)
    print("Результат равен  " + str(count))
Beispiel #7
0
def thissub(num1, num2):
    thisnum = num1 - num2
    return thisnum


def thismul(num1, num2):
    thisnum = num1 * num2
    return thisnum


def thisdiv(num1, num2):
    thisnum = num1 / num2
    return thisnum


if __name__ == "__main__":
    a = 10
    b = 10

#These num of import
print 'result add :', add.add(a, b)  #add모듈의 함수
print 'result sub :', sub.sub(a, b)  #sub모듈의 함수
print 'result mul :', mul.mul(a, b)  #mul모듈의 함수
print 'result div :', div.div(a, b)  #div모듈의 함수

#These thisnum of calc.py module
print 'this is result add :', thisadd(a, b)  #현재 모듈의 함수
print 'this is result sub :', thissub(a, b)  #현재 모듈의 함수
print 'this is result mul :', thismul(a, b)  #현재 모듈의 함수
print 'this is result div :', thisdiv(a, b)  #현재 모듈의 함수
Beispiel #8
0
 def test_div(self):
     eq_(div(10, 5), 2)
     eq_(div(10, 10), 1)
     eq_(div(9, 3), 3)
Beispiel #9
0
 def test_div_zerodiv(self):
     div(10, 0)
Beispiel #10
0
import add
import sub
import mul
import div
import exp
import sqrt

a = int(input("a-> "))
b = int(input("b-> "))
print("a+b")
print(add.add(a, b))
print("a-b")
print(sub.sub(a, b))
print("a*b")
print(mul.mul(a, b))
print("a/b")
print(div.div(a, b))
print("a^(b)")
print(exp.exp(a, b))
print("sqrt(a)")
print(sqrt.sqrt(a))
Beispiel #11
0
# Create a package Calculator having four files add.py, sub.py, mul.py 
# and div.py with functions to perform addition, subtraction, 
# multiplication and division respectively. Import Calculator package 
# in your code and implement simple calculator.
from add import add
from sub import sub
from mul import mul
from div import div

print(add(7,5))
print(sub(17,15))
print(mul(8,3))
print(div(7,5))
Beispiel #12
0
import add
import sub
import mul
import div

	c = add.add(2,3)
	print(c)
	d = sub.sub(2,3)
	print(d)
	a = mul.mul(2,3)
	print(a)
	b = div.div(2,3)
	print(b)
Beispiel #13
0
 def test_div(self):
     self.assertEquals(div.div(1, 2), 0.5)
     self.assertEquals(div.div(10, 2), 5)
     self.assertEqual(div.div(1, 0), None)
     self.assertEquals(div.div(0, 0), None)
Beispiel #14
0
#!/usr/bin/env python

from add3 import add
from subtract import sub
from div import div
from multiplication import mult


fn = raw_input("First number: ")
sn = raw_input("Second number: ")
op = raw_input("Operator : ")

if fn.isdigit() and sn.isdigit():
	if op == "/":
		print (div(fn,sn))
	elif op == "*":
		print (mult(fn,sn))
	elif op == "+":
		print (add(fn,sn))
	elif op == "-":
		print (sub(fn,sn))
	else:
		print("Operation not supported")
else:
	print("Numbers not entered")
Beispiel #15
0
#__INIT__

from add import add
from sub import sub
from multi import multi
from div import div

print(add(5, 5))
print(sub(20, 15))
print(mul(5, 3))
print(div(50, 5))
Beispiel #16
0
import ad
import sub
import mul
import div

print(ad.ad(6, 3))
print(sub.sub(6, 3))
print(mul.mul(6, 3))
print(div.div(6, 3))
Beispiel #17
0
import add
import sub
import prod
import div
import sys

global a, b

args = sys.argv
# print("enter operaton:\n1-add\n2-sub\n3-prod\n4-div\nchoice:\t")
choice, a, b = args[1], int(args[2]), int(args[3])
print(choice, a, b)
# a = int(input("a: "))
# b = int(input("b: "))
ans = 0
if choice == "1":
    print("Adding", a, b)
    ans = add.add(a, b)
if choice == "2":
    print("Subtracting", a, b)
    ans = sub.sub(a, b)
if choice == "3":
    print("Multiplying", a, b)
    ans = prod.product(a, b)
if choice == "4":
    print("Dividing", a, b)
    ans = div.div(a, b)

print()
print(ans)
Beispiel #18
0
    1 for '+'
    2 for '-'
    3 for 'x'
    4 for '/'
    """)
    return [x,y,op]

def output(result):
    print "The result is:", result

if __name__ == "__main__":
    print "Hello Dummy Cal!"
    
    # get input from user
    result = None
    while result is None:
        (x, y, op) = getUserInput()
        if op == 1: result = add(x, y)
        elif op == 2: result = sub(x, y)
        elif op == 3: result = mul(x, y)
        elif op == 4: result = div(x, y)
        else: print "Please enter a valid operator"
    
    # output result.
    output(result)





"""
num1, num2 = input(": ").split()
print(num1)
print(num2)

print("------")
"""

import sum
import mul
import dec
import div

number1 = input("num1 : ")
number2 = input("num2 : ")

sum.sum(int(number1), int(number2))
dec.dec(int(number1), int(number2))
mul.mul(int(number1), int(number2))
div.div(int(number1), int(number2))
Beispiel #20
0
import add
import sub as s
from div import floorDiv, intergerDiv as div
import print_name

print(add.addNum(3,4))
print(s.subNum(23,19))
print(floorDiv(6,4))
print(div(6,4))
print(__name__)
print(add.__name__)