added lint fix for liketerm file.

This commit is contained in:
shyambhu
2020-10-23 19:00:19 +05:30
parent 07419e6a0f
commit d4bf6e523d

View File

@@ -1,11 +1,3 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 23 15:44:50 2020
@author: shyambhu.mukherjee
"""
from .__init__ import * from .__init__ import *
@@ -19,7 +11,7 @@ def likeTermCombineFunc(maxCoef=10, maxExp=20, maxTerms=10):
problem += " + " problem += " + "
solution += " + " solution += " + "
coefficient = random.randint(1, maxCoef) coefficient = random.randint(1, maxCoef)
exponent = random.randint(1, max(numTerms-1,2)) exponent = random.randint(1, max(numTerms - 1, 2))
problem += str(coefficient) + "x^" + str(exponent) problem += str(coefficient) + "x^" + str(exponent)
@@ -30,7 +22,8 @@ def likeTermCombineFunc(maxCoef=10, maxExp=20, maxTerms=10):
def combineTerms(string): def combineTerms(string):
each_terms = string.split("+") each_terms = string.split("+")
dict_power_wise_terms = {} dict_power_wise_terms = {}
for i in range(11): dict_power_wise_terms[i] = [] for i in range(11):
dict_power_wise_terms[i] = []
for term in each_terms: for term in each_terms:
term = term.split("^") term = term.split("^")
appendee = term[0].split("x")[0] appendee = term[0].split("x")[0]
@@ -38,14 +31,15 @@ def combineTerms(string):
dict_power_wise_terms[1].append(int(appendee)) dict_power_wise_terms[1].append(int(appendee))
else: else:
dict_power_wise_terms[int(term[1])].append(int(appendee)) dict_power_wise_terms[int(term[1])].append(int(appendee))
#print(dict_power_wise_terms)
final_string = '' final_string = ''
for i in range(11): for i in range(11):
if len(dict_power_wise_terms[i]) != 0: if len(dict_power_wise_terms[i]) != 0:
total = sum(dict_power_wise_terms[i]) total = sum(dict_power_wise_terms[i])
final_string += str(total)+"x^"+str(i) + " + " final_string += str(total)+"x^" + str(i) + " + "
final_string = '+'.join(final_string.split("+")[:-1]) final_string = '+'.join(final_string.split("+")[:-1])
return final_string return final_string
power_rule_integration = Generator("Power Rule Integration", 48, "nx^m=",
"(n/m)x^(m+1)", powerRuleIntegrationFunc) combineLikeTerm = Generator("Combine Like terms", 102, "nx^m+lx^k+bx^m",
"(n+b)x^m+lx^k", likeTermCombineFunc)