
multiplication_commutative_test
By:
waterapple on
Jul 11th, 2013 | syntax:
Python | size: 1.28 KB | hits: 42 | expires: Never
#-------------------------------------------------------------------------------
# Name: multiplication_commutative_test
# Purpose: Prove that any order of multiplying the same vales results
# in the same answer
#
# Author: new
#
# Created: 11/07/2013
# Copyright: (c) new 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python
def test_multiplication_commutative(start_int,stop_int):
for int_one in xrange(start_int,stop_int):
for int_two in xrange(start_int,stop_int):
for int_three in xrange(start_int,stop_int):
print "testing :", int_one, int_two, int_three,
all_same = (
(int_one * int_two * int_three) == # 123
(int_one * int_three * int_two) == # 132
(int_two * int_one * int_three) == # 213
(int_two * int_three * int_one) == # 231
(int_three * int_two * int_one) == # 312
(int_three * int_one * int_two) # 321
)
print all_same
assert(all_same)
def main():
test_multiplication_commutative(1,1000)
if __name__ == '__main__':
main()