def check_func(a): ret = 0 ret = test.func(a) print "input a= %d: return = %d " % (a, ret) if ret == a * a: print "OK!" else: print "NG"
import test print(test.func())
matplot.hist(grades, 50) matplot.show() # ## Writing Own Moduels # In[31]: # Save this code in a test.py file def func(): print("This is a Function") func() # In[ ]: # Create another .py file from test import func() func() # Run it from Command Line # ## Import and Direct
import test import time import numpy as np #a = np.array([[1.,2.],[17.,15.]]) #b = np.array([[2.,1.],[7.,5.]]) a = np.random.rand(50, 50) a = np.float32(a) b = np.random.rand(50, 50) b = np.float32(a) start = time.time() for i in range(0, 10000): c = test.func(a, b) end = time.time() print(end - start) start = time.time() for i in range(0, 10000): d = np.matmul(a, b) end = time.time() print(end - start) print(d - c)
def main(): test.func()
def test_func(self): from test import func self.assertIsNone(func('ドコドコ'))
# file two.py import test print("top-level in two.py") test.func() if __name__ == "__main__": print("two.py is being run directly") else: print("two.py is being imported into another module")
import test a, b = 100, 100 print(test.func(a,b)) from test import func print(func(a, b))