Ejemplo n.º 1
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def sc(args):
    try:
        if args[0] != '' and args[1] != '':
            input_type = args[0]
            num = float(args[1])
    except IndexError:
        e.separator(1)
        print("Enter the input type: a, m, bm, w, bw")
        input_type = input("--> ")
        print('Enter a salary:')
        num = float(input("--> "))

    # Convert input to lowercase instead of checking variants
    input_type = str.lower(input_type)

    # Convert the salary to Annual
    if input_type == 'm':
        num *= 12
    elif input_type == 'bm':
        num *= 24
    elif input_type == 'w':
        num *= 52
    elif input_type == 'bw':
        num *= 26
    else:
        pass

    # Do calculation based on Annual
    a = num
    m = e.div(a, 12)
    bm = e.div(a, 24)
    w = e.div(a, 52)
    bw = e.div(a, 26)

    e.separator(2)

    print("Annual Salary = " + str(e.qnt(a)))
    print("Monthly Salary = " + str(e.qnt(m)))
    print("Bi-Monthly Salary = " + str(e.qnt(bm)))
    print("Weekly Salary = " + str(e.qnt(w)))
    print("Bi-Weekly Salary = " + str(e.qnt(bw)))

    e.separator(2)
Ejemplo n.º 6
0
def help(args):
    try:
        if args[0] != '':
            cmd = args[0]
    except IndexError:
        e.separator(1)
        print("Enter a Command:")
        cmd = input("--> ")

    try:
        desc = a.help_list[cmd]
        e.separator(2)
        print("Command: " + desc)
        e.separator(0)
    # If the command doesn't exist, give a help message
    # Note: "has_given_help_hint" is there to make sure
    # help message is only shown once per execution
    except KeyError:
        print('"' + args[0] + '"' + " is not a command.")
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def rand_num(args):
    try:
        if args[0] != '' and args[1] != "":
            min_num = int(args[0])
            max_num = int(args[1])
            count = int(args[2])
    except IndexError:
        e.separator(1)

        print("Enter Min Number:")
        min_num = float(input("--> "))

        print("Enter Max Number:")
        max_num = float(input("--> "))

        print("Enter Number Count:")
        count = int(input("--> "))

    e.separator(2)

    roll_array = []
    for i in range(0, count):
        roll = random.randrange(min_num, max_num + 1)
        roll_array.append(roll)

    print("Unsorted List:")
    print(str(roll_array))

    print("")

    roll_array.sort()
    print("Sorted List:")
    print(str(roll_array))

    print("")

    for i in range(int(min_num), int(max_num + 1)):
        if roll_array.count(i) > 0:
            print(str(i) + " appears " + str(roll_array.count(i)) + " times")

    e.separator(0)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
def rpg(args):
    try:
        import secrets
        try:
            if args[0] != '':
                try:
                    pass_length = int(args[0])
                except ValueError:
                    pass_length = 8
                if pass_length == 0:
                    pass_length = 8
        except IndexError:
            e.separator(1)
            try:
                pass_length = int(input("Enter password length --> "))
            except ValueError:
                pass_length = 8
            if pass_length == 0:
                pass_length = 8

        password = ''.join(
            secrets.choice(alphabet) for i in range(pass_length))
        passwords.append(password)

        e.separator(2)
        print(passwords[-1])
        e.separator(0)

        with open("Generated Passwords.txt", "a") as f:
            print("", file=f)
            print(passwords[-1], file=f)

    except ImportError:
        print("")
        print(
            "The Random Password Generator only works in python 3.6 or newer!")
        print("")
Ejemplo n.º 13
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)
Ejemplo n.º 14
0
def commands_list(args):  # args are picked up but not used
    e.separator(3)
    for i in a.help_list:
        print(i, "=", a.help_list[i])
    e.separator(0)