简体   繁体   中英

Is it possible to make a maths formula app using python and django?

I have been wondering if it is possible to make a math formula app using python or some kind of website with django. I want to refer it every time i need because there are tons of mathematics formulas and i don't want to memorize them. It would be easier if it is anything i can refer it anytime.

Yes, this probably would be possible. If you want to save time you can do it wholly with python as a command-line application. I recently did one for quadratic equations, see code below:

import math


def int_input(prompt):
    while True:
        try:
            variable_name = int(input(prompt))
            return variable_name
        except ValueError:
            print("Please enter a whole number (in digits)")


def float_input(prompt):
    while True:
        try:
            variable_name = float(input(prompt))
            return variable_name
        except ValueError:
            print("Please enter a numeric value (in digits)")


def yes_input(prompt):
    while True:
        variable_name = input(prompt).lower()
        if variable_name in ["y", "yes"]:
            return "yes"
        elif variable_name in ["n", "no"]:
            return "no"
        else:
            print("""Please enter either "y" or "n". """)


print("Quadratic Solver")

while True:

    print("Input below the values of a, b and c from an equation that is of the form : ax² + bx + c = 0")
    a = float_input('a: ')

    b = float_input('b: ')

    c = float_input('c: ')

    # calculate the discriminant
    d = (b ** 2) - (4 * a * c)

    # find two solutions
    solution1 = (-b - math.sqrt(d)) / (2 * a)
    solution2 = (-b + math.sqrt(d)) / (2 * a)

    if solution1 == solution2:
        print("There is one solution: x = {0}".format(solution1))

    elif solution1 != solution2:
        print('There are two solutions, x can be either {0} or {1}'.format(solution1, solution2))

    new_question = yes_input('New question? (y/n): ')
    if new_question == "no":
        break

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM