drawtrirt.py

Created by ews31415

Created on June 01, 2024

284 Bytes

Draws an 45-45-90 degree right triangle. Enter the length of the one of the legs (s), not the hypotenuse. The base is set on the x-axis. The screen is set up to fit the proportion of the 320 x 220 screen. The vertical axis ranges from y = -44 to y = 44 while the horizontal axis ranges from x = -64 to x = 64.


from math import *
from matplotlib.pyplot import *

print("Draw a 45-45-90 triangle\nusing pyplot")
s=eval(input("short length? "))

# set axis
axis((-64,64,-44,44))

# set points
xl=[-s/2,s/2,-s/2,-s/2]
yl=[0,0,s,0]

# draw the triangle
c='blue'
plot(xl,yl,c)
show()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.