I am unable to generate a random triangle inside the 5x5 square. Then find the area and perimeter of that random triangle.
I have to use basic python so below is what code I have tried.
from random import *
from math import *
#ask the user for how many triangles they want to test
trials = int(input("How many random triangles would you like to test? "))
#Create the 5x5 square
square = []
for length in range(5):
square.append([])
for width in range(5):
square[length].append("0")
for triangle in range(trials):
x = randint(0, len(square)-1)
y = randint(0, len(square[0])-1)
I am looking for the code that will allow a random triangle to be plotted within the square.