示例#1
0
 def test1(self):
   self.assertEqual(1, fib(1))
示例#2
0
 def test2(self):
   self.assertEqual(fib(0)+fib(1), fib(2))
示例#3
0
 def test0(self):
   self.assertEqual(0, fib(0))
示例#4
0
 def test10(self):
   self.assertEqual(fib(8)+fib(9), fib(10))
示例#5
0
""" My final application :use user defined modules """
import mymath  #import creates mymath.pyc and module name of mymath chnages from main to mymath
print "********************************************************"

print "area of circle with radius 2 = ", mymath.area(2)
#fib(21) #NameError: name 'fib' is not defined
mymath.fib(21)
示例#6
0
"""at import statement level
if __name__  == "__main__":
of module file will not be executed
"""

import mymath  #mymath.pyc
print("*********************************")
print("pi = ", mymath.pi)
print("area = ", mymath.area(5))
mymath.fib(35)
#print pi
print("Learning Modules")
print("End")
示例#7
0
# testmath.py
# Testing many features of python

import mymath
import sys  # System library

# It's possible get the name of procces and to know if I'm in a script on
# interpreter. We can run any python file stand alone

if __name__ == "__main__" and len(sys.argv) > 0:
    print("On main module")

    if len(sys.argv) > 1:
        print(mymath.fib(int(sys.argv[1])))