Tonyeli Zormelo Tonyeli Zormelo - 2 months ago 6
Python Question

How to draw right angled triangle with python

def drawTri(a):
b = (a*math.tan(45))
c = (a/math.cos(45))

t.forward(a)
t.left(135)
t.forward(c)
t.left(135)
t.forward(b)


enter image description here

Answer
import turtle

def drawTri(a):
    hyp = a * 2**0.5
    s = turtle.Screen()
    t = turtle.Turtle()
    t.forward(a)
    t.left(135)
    t.forward(hyp)
    t.left(135)
    t.forward(a)