Esempio n. 1
0
 def test1(self):
   self.assertEqual(1, fib(1))
Esempio n. 2
0
 def test2(self):
   self.assertEqual(fib(0)+fib(1), fib(2))
Esempio n. 3
0
 def test0(self):
   self.assertEqual(0, fib(0))
Esempio n. 4
0
 def test10(self):
   self.assertEqual(fib(8)+fib(9), fib(10))
Esempio n. 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)
Esempio n. 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")
Esempio n. 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])))