我的python类作业的一部分存在以下问题:
使用您先前创建的函数,创建一个flask应用程序,该应用程序接受参数并使用路线/视图显示计算结果。
例如,您会有3条路线,它们分别称为正方形,三角形和成本。您将GET查询字符串参数传递给这些路由,该视图将显示适当的结果。
我做了一些研究,但不知道该如何处理Flask。我的老师在Flask的课堂上作了简短的概述,而且我是Python的初学者,所以希望有人可以帮助我。
我只是不知道该怎么办。我能得到的任何帮助将不胜感激。谢谢!
这是功能代码(此代码有效)
functions.py文件:
# Using the input function ask the user for the base of a triangle and store in a variable
print()
b = int(input(str(user_name)+ ", please enter the base length of your triangle: "))
print()
#Using the input function ask the user for the height of a triangle and store the value in a variable
#Where b = length of base and h = length of height
h = int(input("Now please enter the height length of your triangle: "))
print()
#Call your function passing the two variables that contain the values for base and height
print("The area of your triangle", user_name, "is", str(area_tr(b,h)) +".")
print()
#Part 3: Total Cost
#Assume you work for an outdoor clothing company. Your job is to find out the total cost of buying raw materials for a winter jacket.
#Create a function that takes two arguments and returns the total cost using the formula:
#Total cost = Number of units X price per unit
def tc_wjacket(u,p):
"""
total cost of buying raw materials for a winter jacket.
Total cost = Number of units X price per unit.
"""
return u * p
#Using the input function ask the user for the numbers of units and store it in a variable.
print()
u = int(input(str(user_name)+ ", please enter the number of winter jackets you want for your store: "))
print()
#Using the input function ask the user for the price per unit
p = int(input("Now please enter the cost of the raw materials per jacket: "))
print()
#Call your function passing the two variables that contain the values for number of units and price per unit
print(str(user_name)+ ", according to my calculations, the cost to buy the raw materials for", b ,"jackets with at", p ,"dollars per jacket is", tc_wjacket(u,p) ,"dollars.")
print()
print("I hope this information was helpful " + str(user_name)+ ".")
print()
答案 0 :(得分:0)
column_names <- names(df_sel) %>% str_subset('^meds_0')