Example #1
0
def test_factorial_2():
    """ some big numbers - test for overflow problems."""    
    assert factorial(10) == 3628800
    assert factorial(20) == 2432902008176640000
    
#    assert factorial(10**3) == 6
    

# def test_factorial_3():
#     """other cases that should be handled"""
#     
#     assert factorial(4.0) == 24
#     assert factorial(3.9999999999999999) = 24
#     assert factorial(4.0 + 0.0j) == 24
#     
# def test_factorial_4():
#     """cases that should throw exceptions"""
# 	
# 	assert factorial("this is a string") == SOMEKINDOFEXCEPTION
# 	assert factorial(-4) == SOMEKINDOFEXCEPTION
# 	assert factorial(-4.0) == SOMEKINDOFEXCEPTION
# 	assert factorial(-4.0 + 2.0j) == SOMEKINDOFEXCEPTION
# 	assert factorial([2,3,4,6]) == SOMEKINDOFEXCEPTION
# 	assert factorial(nan) == SOMEKINDOFEXCEPTION
# 	assert factorial(np.nan) == SOMEKINDOFEXCEPTION
# 	assert factorial(inf) == SOMEKINDOFEXCEPTION
# 	assert factorial(np.inf) == SOMEKINDOFEXCEPTION
Example #2
0
def main():
    print("\nWhat function you would like to use?")
    print("1. Find factorial of number")
    print("2. Find square the number")
    print("3. Find cube the number")
    print("4. Find the root of the number")
    print("5. Find the root of a third degree number")
    print("6. Find logarithm of two numbers")
    print("7. Find natural logarithm of number")
    print("8. Find decimal logarithm of numbers")
    answer = input("Input number: ")
    if answer == "1":
        num = input_int("\nYour number: ", False)
        print("Factorial of", num, "=", factorial.factorial(num))
    elif answer == "2":
        num = input_float("\nYour number: ", False)
        print("Square of", num, "=", exponentiation.exp2(num))
    elif answer == "3":
        num = input_float("\nYour number: ", False)
        print("Cube of", num, "=", exponentiation.exp3(num))
    elif answer == "4":
        num = input_float("\nYour number: ", True)
        print("The root of", num, "=", root.root2(num))
    elif answer == "5":
        num = input_float("\nYour number: ", True)
        print("The third degree root of", num, "=", root.root3(num))
    elif answer == "6":
        a = input_int("\nYour a: ", True)
        b = input_int("Your b: ", False)
        print("Logarithm of", a, ",", b, "=", logarithm.log(a, b))
    elif answer == "7":
        num = input_int("\nYour number: ", False)
        print("Natural logarithm of", num, "=", logarithm.ln(num))
    elif answer == "8":
        num = input_int("\nYour number: ", False)
        print("Decimal logarithm of", num, "=", logarithm.lg(num))
    else:
        print("There is no option with such a number")
def test_factorial_good_values():
    for arg, val in good_input_output_pairs.items():
        yield assert_equal, factorial(arg), val
Example #4
0
def test_factorial_1():
    """ some simple numbers"""    
    assert factorial(1) == 1
    assert factorial(2) == 2
    assert factorial(3) == 6
    assert factorial(4) == 24
Example #5
0
 def test_empty(self):
     self.assertEqual(10, factorial.factorial(0))
Example #6
0
	def test_empty(self):
		self.assertEqual(10,factorial.factorial(0))