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)
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)
示例#3
0
# 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
print(mymodule.double_str("abc"))
示例#4
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)
示例#5
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
>>> 
示例#6
0
x = lambda a: a * 2
print(x(5))

####iterators

fruits = ["apple", "mango", "banana"]
myiter = iter(fruits)
print(next(myiter))
print(next(myiter))

####modules

import mymodule

print(mymodule.add(10))
print(mymodule.sub(10))
print(dir(mymodule))

from mymodule import sub
print(sub(20))

####handling json

import json

jsonvar = '{"name":"hello","id":"20"}'
dictvar = json.loads(jsonvar)
print(dictvar["id"])

fruits = ["apple", "mango", "banana"]
print(json.dumps(fruits))
示例#7
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)
示例#8
0
 def testsub(self):  
     self.assertEqual(mymodule.sub(2, 1), 1, 'test sub fail')     
示例#9
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))
示例#10
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))
示例#11
0
# Create data object
x = datetime.datetime(2020, 5, 17)
print(x)

# strftime() Method
x = datetime.datetime(2020, 5, 17)
print(x.strftime("%B"))

# Day_53_54

# Task_1

import mymodule

mymodule.sum(1, 8)
mymodule.sub(4, 2)
mymodule.multi(6, 6)
mymodule.divid(8, 2)

# Task_2
import datetime

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

# Task_3

from datetime import datetime, timedelta
# Use timedelta() calculating differences in dates
yesterday = datetime.now() - timedelta(days=1)
tomorrow = datetime.now() + timedelta(days=1)
示例#12
0
# 1 Env    var name - PYTHONPATH , var path =C:\Users\Rajat.Goel1\Desktop\training\lib
# 2 Prog
import mymodule
import sys

print(sys.path)
# sys.path.append(r'C:\Users\Rajat.Goel1\Desktop\training\lib')
print(mymodule.msg)
print(mymodule.sub(20, 30))

import mymodule as m

print(m.msg)

from mymodule import msg, sub

print(msg)
print(sub(20, 10))

#####################
from mymodule import msg as m, sub as s

print(m)
print(s(60, 10))

#####USING PACKAGE

# 1st way
import project.net.mymodule

print(project.net.mymodule.msg)