我想在python 3.5中创建一个程序,它基本上是一个计算器,如果用户输入的无花果组合在一起形成一个有效的三角形,那么这个计算器就可以运行。为什么不通过我的程序注册用户输入
但是,在运行程序时,控制台中输入的任何浮点数未注册。
我使用的是视觉编码工作室,而且我也是编码方面的小老手,所以任何建设性的批评都非常感谢。
print("************************")
print("** ASSIGNMENT (V 2.6) **")
print("************************")
# User input variables/functions
side_a = float(input("please input the length of the 1st side of the triangle "))
side_b = float(input("please input the length of the 2nd side of the triangle "))
base = float(input("please input the length of the base of the triangle "))
# Formulas
perim_halved = (side_a+side_b+base)/2
area_of_triangle = ((perim_halved*(perim_halved-side_a)*(perim_halved-side_b)*(perim_halved-base))**(1/2))
perimeter = (side_a+side_b+base)
height = (area_of_triangle/base)
# Def Functions
def valid_triangle():
print("******* Your triangle is valid ******** ")
print("******* Area of triangle =", area_of_triangle,"*******")
print("******* Perimeter of triangle =", perimeter,"*******")
print("******* Height of triangle = ", height,"*******")
def invalid_triangle():
print("******* Your triangle is not valid *******")
print("******** Goodbye ********")
def scalene():
print("******* Your triangle is a Scalene triangle *******")
def isosceles():
print("******* Your triangle is an Isosceles triangle *******")
def equilateral():
print("******* Your triangle is an Equilateral triangle *******")
def right_angle():
print("******* Your triangle is a Right angled triangle *******")
def scalene_right_angle():
print("******* Your triangle is a scalene and a right angled triangle ********")
def isosceles_right_angle():
print("******* Your triangle is an Isosceles and a right angled triangle *******")
# If statements
if side_a + base > side_b and side_a +side_b > base and base + side_b > side_a :
if side_a == side_b and side_b == base:
valid_triangle()
equilateral()
elif side_a == side_b and side_b != base:
if side_a**2+side_b**2==base**2:
valid_triangle()
isosceles_right_angle()
elif side_a**2+side_b**2!=base**2:
valid_triangle()
isosceles()
elif side_a != side_b or base and side_b != side_a or base and base != side_a or side_b:
if side_a**2+side_b**2==base**2:
valid_triangle()
scalene_right_angle()
elif side_a**2+side_b**2!=base**2:
valid_triangle()
scalene()
# Right angle only
elif side_a**2+side_b**2==base**2:
valid_triangle()
right_angle()
else:
invalid_triangle()
的“[图](https://www.google.de/search?q=figs&source=lnms&tbm= isch)“? – Matthias
嗨,对不起,我的意思是花车 –
你是什么意思“任何花车进入控制台没有注册。”。输入存储在side_a,side_b和base中。什么具体不工作? – Carcigenicate