'The formatting of your code differs from the recommendation - I AM NEW its why im here

Here is the exercise: A right triangle has one angle of 90° A obtuse triangle has one angle of more than 90° A triangle is acute if all three angles are less than 90°

Write a program that asks the user for the values of three angles in degrees. First check if the entered values are valid. The values are only valid if they are >0 and if their sum is 180°. If the entered values are valid, classify the triangle as right, acute or obtuse.

Below are two example executions of the program with invalid values: Please enter the first angle: 60 Please enter the second angle: 60 Please enter the third angle: 100 The entered values are not valid.

Please enter the first angle: 200 Please enter the second angle: -10 Please enter the third angle: -10 Angles smaller than 0 are not valid

Please enter the first angle: 60 Please enter the second angle: 30 Please enter the third angle: 90 The triangle is a right triangle.

I keep getting these refactor messages: chained-comparison: Simplify chained comparison between the operands (exercise.py: 11)

a = int(input("Please enter the first angle: "))
b = int(input("Please enter the second angle: "))
c = int(input("Please enter the third angle: "))

if ((a + b + c) or (a == 0) or (b == 0) or (c == 0)):
    print("The entered values are not valid.")
elif a < 90 and b < 90 and c < 90:
  print("acute angle")
elif (a == 180) or (b == 180) or (c == 180):
    print("obtuse angle")
elif (a >= 200 and a <= 180) or (b <= -10) or (c <= -10):
    print("Angles smaller than 0 are not valid.")
elif (total == 180 and a > 0 and b > 0 and c > 0):
    print("The triangle is a right triangle.")


Solution 1:[1]

This seems to be a combination of overthinking the problem and being very new to programming. First, you should write out your logic clearly so you can understand it. Then you translate it to code.

If any input <= 0:
    Not a triangle
Else if total of inputs != 180:
    Not a triangle
Else if any input == 90:
    Right triangle
Else if any input > 90:
    Obtuse triangle
Else
    Acute triangle

Now see if you can convert that to python without thinking about the specific example values you were given. Those values are used to test your logic, not to define it.

Solution 2:[2]

In Python:

a >= 200 and a <= 180

can be written as

180 <= a <= 200

You can see the docs comparisons for more details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Kraigolas