def main():
    a = int(input("Enter First no."))
    b = int(input("Enter Second no."))
    r1 = mymodule.add(a, b)
    r2 = mymodule.sub(a, b)
    r3 = mymodule.mul(a, b)
    r4 = mymodule.div(a, b)
    print("add:-", r1, "sub:-", r2, "Mul:-", r3, "division:-", r4)
Exemplo n.º 2
0
def main():
    a = int(input("enter 1st no."))
    b = int(input("enter 2nd no."))
    r1 = bdm.add(a, b)
    r2 = bdm.sub(a, b)
    r3 = bdm.mul(a, b)
    r4 = bdm.div(a, b)

    print("add:-", r1, "sub:-", r2, "Mul:-", r3, "div:-", r4)
Exemplo n.º 3
0
def lambda_handler(event, context):
    if 'queryStringParameters' not in event:
        return {
            'statusCode': 500,
            'headers': { 'Content-Type': 'application/json' },
            'body': json.dumps({ 'error': 'Missing queryStringParameters' })
        }
        
    
    if event['queryStringParameters'] == None or 'a' not in event['queryStringParameters'] or 'b' not in event['queryStringParameters'] or 'operation' not in event['queryStringParameters']:
        return {
            'statusCode': 400,
            'headers': { 'Content-Type': 'application/json' },
            'body': json.dumps({ 'error': 'Missing field' })
        }

    operation = event['queryStringParameters']['operation']
    if operation == 'add':
        result = mymodule.add(int(event['queryStringParameters']['a']), int(event['queryStringParameters']['b']))
        op = '+'
    elif operation == 'multiply':
        result = mymodule.multiply(int(event['queryStringParameters']['a']), int(event['queryStringParameters']['b']))
        op = '*'
    else:
        return {
            'statusCode': 400,
            'headers': { 'Content-Type': 'application/json' },
            'body': json.dumps({ 'error': 'Unsupported operation: "{}"'.format(operation) })
        }

    return {
        'statusCode': 200,
        'headers': { 'Content-Type': 'application/json' },
        'body': json.dumps({
            'a' : event['queryStringParameters']['a'],
            'b' : event['queryStringParameters']['b'],
            'op' : op,
            'result': result,
        })
    }
Exemplo n.º 4
0
import mymodule

print(mymodule.name)
print(mymodule.PI)
print(mymodule.add(45, 34))
def test_add2():
    assert abs(mymodule.add(-1, -1) - -2) < TOL
Exemplo n.º 6
0
print(mymodule.cvar.my_variable)

# Functions
print(mymodule.fact(6))
print(mymodule.my_mod(6, 4))

# Classes
w = mymodule.Wall(5)
print(w.getWall())
w.setWall(10)
print(w.getWall())
# Do not know how to construct int * type in Python...
print(w.x)

# In-place inputs & outputs
print(mymodule.add(3, 4))
print(mymodule.sub(3, 4))
print(mymodule.negate(5))
print(mymodule.next_fab(*mymodule.next_fab(3, 4)))

# C-arrays
a = mymodule.int_array(500)
for i in range(500):
    a[i] = i
print(a[300])
print(mymodule.sum_array(a, 500))

# C-strings
print(mymodule.half_str("aaabbbbccc"))

# C++ std::string
Exemplo n.º 7
0
import mymodule

print('xdfsadfasdf', mymodule.myint, mymodule.add(4, 32))
Exemplo n.º 8
0
import mymodule
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
print(mymodule.add(a, b))
print(mymodule.subtract(a, b))
print(mymodule.multiply(a, b))
print(mymodule.divide(a, b))
def test_add1():
    assert abs(mymodule.add(1, 1) - 2) < TOL
Exemplo n.º 10
0
 def testadd_types(self):
     """Different types raise exception"""
     x = mymodule.add(1, None)
     self.assertRaises(Exception)
Exemplo n.º 11
0
import mymodule
num = [5, 2, 8, 1]
print(num)
print(mymodule.add(num))
print(mymodule.sub(num))
print(mymodule.max(num))
print(mymodule.min(num))
print(mymodule.sort(num))
Exemplo n.º 12
0
import sys
sys.path.append('./build')
import mymodule as md

print(md.add(1,2))
Exemplo n.º 13
0
import mymodule

print("\"import\" sample")
print(mymodule.add(8, 2))
print(mymodule.sub(-5, 2))
print(mymodule.mul(1, 2))
print(mymodule.div(657, 2))
Exemplo n.º 14
0
import mymodule
import datetime as mx

print('1 + 8 =',mymodule.add(1,8))
print('4 - 2 =',mymodule.sub(4,2))
print('6 x 6 =',mymodule.mul(6,6))
print('8 / 2 =',mymodule.div(8,2))

x=mx.datetime.now()
print('Year: ',x.strftime('%Y'))
print('Month: ',x.strftime('%B'))
print('Day: ',x.strftime('%A'))
print('Time: ',x.strftime('%X'))
print('Date: ',x.strftime('%x'))

print('Tomorrow :',mx.datetime.now() + mx.timedelta(days=1))
print('Yesterday :',mx.datetime.now() - mx.timedelta(days=1))
Exemplo n.º 15
0
import mymodule
import datetime

print("Task one:")
mymodule.add(1, 8)
mymodule.sub(4, 2)
mymodule.multi(6, 6)
mymodule.dividing(8, 2)

print("Task Two:")
x = datetime.datetime.now()
print(x.strftime("%c"))

print("task Three:")

today = datetime.date.today()

yesterday = today - datetime.timedelta(days=1)

tomorrow = today + datetime.timedelta(days=1)

print('Yesterday : ', yesterday)
print('Tomorrow : ', tomorrow)
Exemplo n.º 16
0
import mymodule
print("hello world")
mymodule.greeting("Manish")
mymodule.add(2, 3)
mymodule.diff(100, 100)
mymodule.mult(12, 3)
mymodule.div(12, 4)
x = mymodule.person1["age"]
print(x)
mymodule.int(100, 5, 10)
Exemplo n.º 17
0
import mymodule

print('asdfasdfasdf', mymodule.add(22, 33))
print(mymodule.myint)
Exemplo n.º 18
0
 def testadd(self):
     """1 and 2 is 3"""
     x = mymodule.add(1,2)
     self.assertEqual(x, 3)
Exemplo n.º 19
0
from mymodule import add, sub, multi, div

a = int(input("Enter the number of a:"))
b = int(input("Enter the number of b:"))
x = int(input("Choose the option:"))
if x == 1:
    add(a, b)
elif x == 2:
    sub(a, b)
elif x == 3:
    multi(a, b)
elif x == 4:
    div(a, b)
Exemplo n.º 20
0
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import mymodule
>>> import datetime
>>> mymodule.add(8, 1)
>>> mymodule.sub(4, 2)
>>> mymodule.multl(6, 6)
>>> mymodule.dividing(8, 2)

>>> x = datetime.datetime.now()
>>> print(x.strftime('%c'))
Sat Oct 12 15:08:28 2019
>>> 
def test_add3():
    assert abs(mymodule.add(-1, 1)) < TOL
Exemplo n.º 22
0
import urllib
import mymodule
import mymodule2

connection = urllib.urlopen(
    "http://www.learnpython.org/en/Modules_and_Packages")
#print "result = " + str(connection.info())
print "result code = " + str(connection.geturl())

# To make your own module, you just need to create a file with the module name

# To import the module, just use import command and filename without the extension
# To use the functions in the module, use <modulename>.<functionname>
print "Magic number in the module: %d" % mymodule.magic_number

print mymodule.add(3, 4)
print mymodule.subtract(3, 4)
print mymodule.divide(3, 4)
print mymodule.multiply(3, 4)

# You can import one module inside the other
from mymodule2 import average

# mymodule2 loads mymodule. But we'd expect that mymodule is loaded only once.
# this should NOT print 2
print "Magic number in the module: %d" % mymodule.magic_number

list = [1, 2, 5, 7, 8, 10, 15, -3]
x = mymodule2.average(list)

print x
Exemplo n.º 23
0
'''
title: 引入自定义模块
time: 2018.04.09 18:45
author: 杨龙(Alex)
'''
# import 模块名
import mymodule

print(mymodule.add(5, 2))
print(mymodule.sub(5, 2))
print(mymodule.mul(5, 2))
print(mymodule.div(5, 2))

print(mymodule.FILE_PATH)
print(mymodule.PI)
Exemplo n.º 24
0
import mymodule2
import mymodule

print(mymodule.add(10, 20))
print(mymodule.subtract(10, 20))
print(mymodule.multiply(10, 20))
print(mymodule2.power(10, 20))
Exemplo n.º 25
0
def test_add():
    assert add(2, 2) == 4
Exemplo n.º 26
0
def average(list):
    sum = 0

    for x in list:
        sum = mymodule.add(sum, x)
    return sum / len(list)
Exemplo n.º 27
0
import mymodule

mymodule.add([2, 4, 6, 8, 4, 2])
Exemplo n.º 28
0
import mymodule
import sys
#print(sys.path)
#sys.path.append(r'directory path of lib')
print(mymodule.msg)
print(mymodule.add(10,20))
line='='*40
print(line)

#import module using alias

import mymodule as m
print(m.msg)
print(m.add(30,40))
print(line)
#another way to import modules
from mymodule import msg,add
print(msg)
print(add(100,200))

#alias for each variable name

print(line)
from mymodule import msg as m, add as a
print(m)
print(a(10,10))

#one more way to import
print(line)
from mymodule import *
print(msg)
Exemplo n.º 29
0
from mymodule import Student
from mymodule import add
import mymodule

s = mymodule.Student(1, 'John')
s.print()
r = mymodule.add(10, 20)
print(f'Result of addtion is : {r}')
Exemplo n.º 30
0
 def test1(self):
     self.assertEqual(add(2,4),6)
     self.assertEqual(add(0,0),0)
     self.assertEqual(add(2.3,3.6),5.9)
     self.assertEqual(add('hello','world'),'helloworld')
Exemplo n.º 31
0
import mymodule as m

'''
//We can import lib from file also. Scope will be only for that file
import sys
sys.path.append(r'D:\training\lib')
'''

# print(mymodule.msg)

# r1 = mymodule.add(10, 20)
# print('r1=', r1)

print(m.msg)

r1 = m.add(10, 20)
print('r1=', r1)

from mymodule import msg, add

print(msg, add(10, 20))

from mymodule import msg as M

print('M=', M)

from mymodule import *

# msg = 'Hello'
print(msg, add(10, 20), M)