hi so im trying to do a code that will ask the user for 3 values,determine if those values make a triangle,find the angles if it does make a triangle ane draw the triangle if the values make one.im having trouble drawing the trangle.this is the code i have so far.Can someone plese help me do the triangle baced on the values that the user gives ?

from turtle import *
from math import *

a = float(input("enter the a value: "))
b = float(input("enter the b value: "))
c = float(input("enter the c value: "))

if (a + b >= c) and (b + c >= a) and (c + a >= b):
   print("it's a triangle")

   A = print(degrees(acos((b**2 + c**2 - a**2)/(2*b*c))))
   B = print(degrees(acos((c**2 + a**2 - b**2)/(2*c*a))))
   C = print(degrees(acos((a**2 + b**2 - c**2)/(2*a*b))))
else:
   print("it's not a triangle")

Recommended Answers

All 2 Replies

You didn't define what the user was inputting so I will GUESS! the inputs are the lengths of the sides. Armed with that I can google.
https://www.google.com/search?q=Python+draw+triangle+given+length+of+sides

First hit looks vaguely similar to your code and is explained well enough for most.

Don't leave out details to the user or others like this. What if you wanted the user to supply two of the angles? Don't make others GUESS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.