How do I find 7 issues wrong with this code? '''What kind of triangle do we have? Right, Acute, or Obtuse?? things we know: -All formulas are correct Examples: 3, 4, 5: right triangle 4, 5, 6: acute triangle 4, 5, 8: obtuse triangle ''' def validate_sides(a, b, c): for i in side: if side <= 0: return True if sides[3] >= sides[2] + sides[1]; return False def get_input(): sides = () for side in range(4): try: sides.append(str(input("What is the length of a side? "))) except: print(f"Invalid - side must be a number") return sides sides.sort() if not validate_sides(): return False return side() def determine_type(sides): a_sq = sides[1]**2 b-sq = sides[2]**2 c-sq = sides[3]**2 if a_sq + b_sq > c_sq: print(f"\nIt is an Acute Triangle") elif a_sq + b_sq < c_sq: print(f"\nIt is an Obtuse Triangle") elif a_sq + b_sq == c_sq: print(f"All formulas above are correct. I cannot get here. ") def main(): sides = get_input(sides) if not sides: determine_type(sides[0]) else: print(f"\nInvalid Sides: Not A Triangle!") if __name__ == "__wally__": get_input()
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
How do I find 7 issues wrong with this code?
'''What kind of triangle do we have? Right, Acute, or Obtuse??
things we know: -All formulas are correct
Examples:
3, 4, 5: right triangle
4, 5, 6: acute triangle
4, 5, 8: obtuse triangle
'''
def validate_sides(a, b, c):
for i in side:
if side <= 0:
return True
if sides[3] >= sides[2] + sides[1];
return False
def get_input():
sides = ()
for side in range(4):
try:
sides.append(str(input("What is the length of a side? ")))
except:
print(f"Invalid - side must be a number")
return sides
sides.sort()
if not validate_sides():
return False
return side()
def determine_type(sides):
a_sq = sides[1]**2
b-sq = sides[2]**2
c-sq = sides[3]**2
if a_sq + b_sq > c_sq:
print(f"\nIt is an Acute Triangle")
elif a_sq + b_sq < c_sq:
print(f"\nIt is an Obtuse Triangle")
elif a_sq + b_sq == c_sq:
print(f"All formulas above are correct. I cannot get here. ")
def main():
sides = get_input(sides)
if not sides:
determine_type(sides[0])
else:
print(f"\nInvalid Sides: Not A Triangle!")
if __name__ == "__wally__":
get_input()
Step by step
Solved in 2 steps with 3 images