[英]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.我一直想知道是否可以使用 python 或某种带有 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.
如果您想节省时间,您可以完全使用 python 作为命令行应用程序来完成。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.