67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
class Factor:
|
|
simple_one = []
|
|
simple_two = []
|
|
compound_one = []
|
|
compound_two = []
|
|
complex_one = []
|
|
complex_two = []
|
|
complex_three = []
|
|
complex_four = []
|
|
|
|
def __init__(self, variable_name, base_list):
|
|
self.variable_name = variable_name
|
|
self.base_list = base_list
|
|
|
|
def calculate_factors(self, factor, include_compound = False, include_complex = False):
|
|
clear_factors_lists(self)
|
|
|
|
for item in self.base_list:
|
|
simple_one.append(factor / item)
|
|
simple_two.append(factor * item)
|
|
|
|
if include_compound:
|
|
for item in self.base_list:
|
|
compound_one.append(((1 + factor) ** (1 / item)) - 1)
|
|
compound_two.append(((1 + factor) ** item) - 1)
|
|
|
|
if include_complex:
|
|
for item in self.base_list:
|
|
complex_one.append(item * (((1 + factor) ** (1 / item)) - 1))
|
|
complex_two.append(1 / item * (((1 + factor) ** (1 / item)) - 1))
|
|
complex_three.append(item * (((1 + factor) ** item) - 1 ))
|
|
complex_four.append(1 / item * (((1 + factor) ** item) - 1))
|
|
|
|
def print_factors(self, include_simple = True, include_compound = True, include_complex = True):
|
|
print("Factors for %s." %(self.variable_name))
|
|
|
|
if include_simple and self.simple_one:
|
|
print("Simple Factors:")
|
|
print(self.simple_one)
|
|
print(self.simple_two)
|
|
print()
|
|
|
|
if include_compound and self.compound_one:
|
|
print("Compound Factors:")
|
|
print(self.compound_one)
|
|
print(self.compound_two)
|
|
print()
|
|
|
|
if include_complex and self.complex_one:
|
|
print("Complex Factors:")
|
|
print(self.complex_one)
|
|
print(self.complex_two)
|
|
print(self.complex_three)
|
|
print(self.complex_four)
|
|
print()
|
|
|
|
def clear_factors_lists(self):
|
|
self.simple_one = []
|
|
self.simple_two = []
|
|
self.compound_one = []
|
|
self.compound_two = []
|
|
self.complex_one = []
|
|
self.complex_two = []
|
|
self.complex_three = []
|
|
self.complex_four = []
|
|
|