示例#1
0
文件: main.py 项目: Arsh2106/Gitviva
import add
import sub
import mult
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)

ans = 0
if choice == "1":
    print("Adding", a, b)
    ans = add.addition(a, b)
if choice == "2":
    print("Subtracting", a, b)
    ans = sub.subtraction(a, b)
if choice == "3":
    print("Multiplying", a, b)
    ans = mult.multiplication(a, b)
if choice == "4":
    print("Dividing", a, b)
    ans = div.divide(a, b)

print()
print(ans)
示例#2
0
'''
Created on Aug 16, 2014

@author: rocky
Script to demo module import
'''
import add
import math

print("This script will import a script for_01.py")
add.addition(4, 5)
print("sqrt of 9 is :", math.sqrt(9))
示例#3
0
import add

print add.addition(10, 4)
import add
n1 = int(input("enter the  first number "))
n2 = int(input("enter the second number "))
r = add.addition(n1, n2)
print(r)
print("Omar helped a girl")

while(True):

    num1=input("Enter the first number:")
    num2=input("Enter the second number:")

    num1=float(num1)
    num2=float(num2)

    op=input("Enter your operation:")

    mulobj=multiplication(num1,num2)
    subobj=subtraction(num1,num2)
    addobj=addition(num1,num2)
    divobj=divition(num1,num2)

    if (op == '*'):
        result=mulobj.mulfunction()
        print("your result is :",result)
    elif (op == '-'):
        result=subobj.subfunction()
        print("Subtraction is:", result)
    elif(op == '+'):
        result=addobj.addfunction()
        print("Addition is:", result)
    elif(op == '/'):
        result=divobj.divfunction()

    per=input("Do you want to run again?\nEnter Yes or No.")
示例#6
0
import add

num1=int(input("Enter num1 = "))
num2=int(input("Enter num2 = "))
result=add.addition(num1,num2)
print(result)
class subtract(object):
    def __init__(self,a,b):
        self.a=a
        self.b=b
    def sub(self):
        print("The subtraction value is:",self.a-self.b)

MUL.PY PYTHON FILE:

class multiplication(object):
    def __init__(self,a,b):
        self.a=a
        self.b=b
    def mul(self):
        return "The multiplication value is:",self.a*self.b

BASE.PY PYTHON FILE:

from add import addition
from sub import subtract
from mul import multiplication

obj=addition(5,4)
obj_two=subtract(8,2)
obj_three=multiplication(2,9)
obj.add()
obj_two.sub()
print(obj_three.mul())

(NOTE: CREATE __INIT__.PY PYTHON FILE TO CONVERT IT INTO PACKAGES)
示例#8
0
 def test_add(self):
     d = addition(3, 8)
     d = str(d)
     print("Hello")
     self.assertEqual(d, '11')
示例#9
0
import add
import divide
import mul
import sub
import sys

input_1 = int(sys.argv[1])
input_2 = int(sys.argv[2])

print("1: Addition\n 2: Subtraction \n3: Multiply \n4: Divide")

process = int(sys.argv[3])

if process == 1:
    add.addition(input_1, input_2)
elif process == 2:
    sub.sub(input_1, input_2)
elif process == 3:
    mul.multiplication(input_1, input_2)
elif process == 4:
    divide.divide(input_1, input_2)
else:
    print("Please select between 1 to 4 only")