u,p,k = float(input(" enter the values of viscoity, pressure , prmeability")).split(",")
l,A = int(input("enter the vaues of length and area").split(" "))
def flow_rate(u,p,k,l,A):
Q=k* A * p/l*u
print(f"the Q is {Q}")
flow_rate(u,p,k,l,A)
u, p, k = map(float, input("Enter the values of viscosity, pressure, and permeability: ").split(", ")
# I changed the split separator so the input can be prettier ;)
在第一行中,你要做的是取整个字符串,比如“3.5,5.6,9”,试着把它转换成float,然后把它分开。问题是python无法将包含3个数字和逗号的字符串转换为浮点。解决此问题的方法是首先拆分字符串,然后将每个元素转换为float,如下所示:
对第二行应用相同的逻辑
这是因为您不能在列表上调用
int
,而希望将值转换为int
使用
map
或者一份清单
相关问题 更多 >
编程相关推荐