this post was submitted on 14 Jul 2023
4 points (100.0% liked)

bad code

59 readers
1 users here now

A sub for complaining about bad code, whether you made it yourself or not.

founded 1 year ago
MODERATORS
 

Triangle=turtle.Turtle#Making the turtle easily callable. Side_1=float(input("How many pixels should the 1st side of the triangle be?"))#Asking the user the length of the 1st side of the triangle. Side_2=float(input("How many pixels should the 2nd side of the triangle be?"))#Asking the user the length of the 2nd side of the triangle. Side_3=float(input("How many pixels should the 3rd side of the triangle be?"))#Asking the user the length of the 3rd side of the triangle. Angle_1=float(input("How many degrees should the 1st angle be?"))#Asking the user the measure of the 1st angle of the triangle. Angle_2=float(input("How many degrees should the 1st angle be?"))#Asking the user the measure of the 2nd angle of the triangle. Angle_3=float(input("How many degrees should the 1st angle be?"))#Asking the user the measure of the 3rd angle of the triangle. if Angle_1+Angle_2+Angle_3!= 180:#If the angles of the triangle do not add up to 180 degrees. print("The angles of a traingle must add up to 180 degrees.") elif (Side_1>Side_2 and Angle_1<Angle_2) or (Side_2>Side_1 and Angle_2>Angle_1) or (Side_3>Side_2 and Angle_3>Angle_2) or (Side_3<Side_2 and Angle_3<Angle_2) or (Side_3>Side_1 and Angle_3>Angle_1):#If both the side and its opposing angle are larger than another side and its respective opposive angle. print("If an angle is greater than another angle, then the side opposing the 2nd angle should be greater than the side opposing the 1st angle.")#Printing an appropriate message. else:#If everything works fine. pass#The rest fo the code happens. class Side(Triangle):#Drawing a side. def init(self,Side,Angle):#Making the attributes easily callable. self.Side=Side#The side of the triangle. self.Angle=Angle#The angle of the triangle. def Draw(self):#Drawing a side. Triangle.forward(self.Side)#Drawing the side. Triangle.left(self.Angle)#Turning the pen. Sides=[Side_1,Side_2,Side_3]#The sides of the triangle. Angles=[Angle_1,Angle_2,Angle_3]#The angles of the triangle. for Side_number in range(0,2):#This loop will run until all 3 sides have been drawn. Side=Side(Sides[Side_number],Angles[Side_number])#Creating an object for the sides and angles. Side.Draw#Drawing the sides.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here