def pc(args): try: if args[0] != '' and args[1] != "": base_population = e.Decimal(float(args[0])) try: rate_of_change = e.Decimal(float(args[1])/100) except ZeroDivisionError: rate_of_change = 1.75 except IndexError: e.separator(1) print("Enter Base Population:") base_population = e.Decimal(float(input("--> "))) print("Enter Rate of Change (1.4 = 1.4%):") try: rate_of_change = e.Decimal(e.div(float(input("--> ") / 100))) except ZeroDivisionError: rate_of_change = 1.75 e.separator(2) annual = round(e.mul(base_population, rate_of_change, e.TWOPLACES)) monthly = round(e.div(annual, 12, e.TWOPLACES)) weekly = round(e.div(annual, 52, e.TWOPLACES)) daily = round(e.div(annual, 365, e.TWOPLACES)) print("Annual amount = " + str(annual)) print("Monthly amount = " + str(monthly)) print("Weekly amount = " + str(weekly)) print("Daily amount = " + str(daily)) e.separator(0)
def ci2(args): try: if args[0] != '' and args[1] != "": principal = e.Decimal(float(args[0])) try: rate = e.Decimal(float(args[1]) / 100) except ZeroDivisionError: rate = 1.75 except IndexError: e.separator(1) print("Enter the Principal:") principal = float(input("--> ")) print("Enter the Rate (15 = 15%):") try: rate = float(input("--> ")) / 100 except ZeroDivisionError: rate = 1.75 e.separator(2) ca = principal * (rate / 12) print("Credit Interest Amount = ", e.qnt(ca, e.TWOPLACES)) e.separator(0)
def sct(args): try: if args[0] != '': angle = e.Decimal(float(args[0])) except IndexError: e.separator(1) print("Enter an Angle:") angle = e.Decimal(radians(float(input("--> ")))) e.separator(2) ang_sin = sin(angle) ang_cos = cos(angle) ang_tan = tan(angle) print("Sine = " + str(e.qnt(ang_sin))) print("Cosine = " + str(e.qnt(ang_cos))) print("Tangent = " + str(e.qnt(ang_tan))) e.separator(0)
def ci(args): try: if args[0] != '' and args[1] != "" and args[2] != "" and args[3] != "": principal = e.Decimal(float(args[0])) try: rate = e.Decimal(float(args[1]) / 100) except ZeroDivisionError: rate = 1.75 num_times = e.Decimal(int(args[2])) time = e.Decimal(float(args[3])) except IndexError: e.separator(1) print("Enter the Principal:") principal = float(input("--> ")) print("Enter the Rate (15 = 15%):") try: rate = float(input("--> ")) / 100 except ZeroDivisionError: rate = 1.75 print("Enter Number of Times Per Year:") num_times = float(input("--> ")) print("Enter Time Number:") time = float(input("--> ")) if num_times <= 0: num_times = 1 e.separator(2) amount = principal * pow((1 + e.div(rate, num_times)), num_times * time) print("Compound Interest Amount = ", amount) total_amount = principal + amount print("Total Amount = ", total_amount) e.separator(0)
def tc(args): try: if args[0] != '' and args[1] != "": money_amount = e.Decimal(float(args[0])) tax_percent = e.Decimal(float(args[1])/100) except IndexError: e.separator(1) print("Enter Money Amount:") money_amount = e.Decimal(float(input("--> "))) print("Enter Tax Percent (15 is 15%):") tax_percent = e.Decimal(float(input("--> "))/100) e.separator(2) tax_amount = e.mul(money_amount, tax_percent) total_amount = e.add(money_amount, tax_amount) print("Tax amount = " + "$"+ str(e.qnt(tax_amount, e.TWOPLACES))) print("Total amount = " + "$" + str(e.qnt(total_amount, e.TWOPLACES))) e.separator(0)
def bc(args): try: if args[0] != '' and args[1] != "": num1 = e.Decimal(float(args[0])) num2 = e.Decimal(float(args[1])) except IndexError: e.separator(1) print("Enter Number 1:") num1 = e.Decimal(float(input("--> "))) print("Enter Number 2:") num2 = e.Decimal(float(input("--> "))) e.separator(2) print("Addition = " + str(e.add(num1, num2))) print("Subtraction = " + str(e.sub(num1, num2))) print("Multiplication = " + str(e.mul(num1, num2))) print("Division = " + str(e.div(num1, num2))) e.separator(0)
def c2f(args): try: if args[0] != '': centigrade = e.Decimal(float(args[0])) except IndexError: e.separator(1) print("Enter Temperature in Centigrade:") centigrade = float(input("--> ")) e.separator(2) fahrenheit_calc = 1.8 * centigrade + 32 print(str(e.qnt(centigrade)) + " Centigrade in Fahrenheit = " + str(e.qnt(fahrenheit_calc))) e.separator(0)
def f2c(args): try: if args[0] != '': fahrenheit = e.Decimal(float(args[0])) except IndexError: e.separator(1) print("Enter Temperature in Fahrenheit:") fahrenheit = float(input("--> ")) e.separator(2) centigrade_calc = (fahrenheit - 32) * (5.0 / 9.0) print( str(e.qnt(fahrenheit)) + " Fahrenheit in Centigrade = " + str(e.qnt(centigrade_calc))) e.separator(0)
def mccc(args): try: if args[0] != '': width = e.Decimal(float(args[0])) except IndexError: e.separator(1) print("Enter an Width:") width = abs(int(input("--> "))) required_blocks = 0 if width <= 1: width = 1 required_blocks = 1 if width == 2: required_blocks = 8 if width >= 3: required_blocks = ((width * width) + (width * (width - 2)) + ((width - 2) * (width - 2))) * 2 e.separator(2) print("Required Blocks = " + str(required_blocks)) e.separator(0)