0

A. Write a triangle solver that takes 3 inputs consisting of angles in degrees and length
of sides in arbitrary units and, if possible (your program has to determine this),
supplies all other angles and side lengths. There will be either 0 triangles, 1 triangle,
2 triangles or an infinite number of triangles – you program must determine which
possibility. Classify the type of triangle (right triangle, isosceles, equilateral, acute,
obtuse – see any good geometry book. Finally, use the Turtle module to draw the
triangle(s) with correct relative dimensions.

7
Contributors
6
Replies
49
Views
5 Years
Discussion Span
Last Post by JamesCherrill
3

The first paragraph here will help get you started:
http://docs.python.org/py3k/library/turtle.html

This will help understand triangles:
http://www.freemathhelp.com/feliz-angles-triangle.html

The key part is understanding that all triangles will have a total of 180* as the sum of all angles. That means, given your 3 inputs, if they don't add up to 180* then it's not a triangle.

You have a lot of choices on how to start. A better way for us to help you is to start writing some code, and when you have trouble or get stuck, then ask. Homework is meant for you to learn, not for people on a message board to do it for you.

-1

import turtle
turtle.speed(0)

for i in range(52):
turtle.forward(100)
turtle.left(175)
turtle.forward(100)
turtle.left(90)
turtle.forward(10)
turtle.left(90)
turtle.right(2)

1
import turtle

def draw_triangle():
    window = turtle.Screen()
    window.bgcolor("green") #background color

    tom = turtle.Turtle()

    tom.forward(100) 
    tom.left(120)
    tom.forward(100)
    tom.left(120)
    tom.forward(100)

    window.exitonclick() #to exit 

draw_triangle()

Edited by Wadie

1

Hi Viral

This is a web site for people who work with computers and want to learn more. If you want to learn how to write turtle code then start your own topic here and someone will help you. If you just want someone to do it for you then you have come to the wrong place - wo don't do people's homework for them.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.