triangle or not .py

# Side 3 side 1 must be longer than side 2 output

• Homework Help
• 2

This preview shows pages 1–2. Sign up to view the full content.

* Side #3 + Side #1 must be longer than Side 2 * Output whether or nota valid triangle is formed: a. YOU HAZ TRIANGLE b. Nope, not a triangle. Example Interaction 1: ----- Enter point #1 x: 0 Enter point #1 y: 0 Enter point #2 x: 100 Enter point #2 y: 0 Enter point #3 x: 50 Enter point #3 y: 2 Side #1 100.00 Side #2 50.04 Side #3 50.04 YOU HAZ TRIANGLE Example Interaction 2: ----- Enter point #1 x: 0 Enter point #1 y: 0 Enter point #2 x: 10 Enter point #2 y: 10 Enter point #3 x: 1 Enter point #3 y: 0 Side #1 14.14 Side #2 13.45 Side #3 1.00 YOU HAZ TRIANGLE Example Interaction 3: ----- Enter point #1 x: 0 Enter point #1 y: 0 Enter point #2 x: 50 Enter point #2 y: 50

This preview has intentionally blurred sections. Sign up to view the full version.

Enter point #3 x: 100 Enter point #3 y: 100 Side #1 70.71 Side #2 70.71 Side #3 141.42 Nope, not a triangle """ #Points x1= int(input('enter point #1 x')) y1= int(input('enter point #1 y')) x2= int(input('enter point #2 x')) y2= int(input('enter point #2 y')) x3= int(input('enter point #3 x')) y3= int(input('enter point #3 y')) #Calculate side one #Side lengths side1math= ((x1 - x2)**2 + (y1 - y2)**2) side2math= ((x2 - x3)**2 + (y2 - y3)**2) side3math= ((x3 - x1)**2 + (y3 - y1)**2) #sqrt import math #define side length with sqrt funtion length1 = math.sqrt(side1math) length2 = math.sqrt(side2math) length3 = math.sqrt(side3math) #print lengths print(length1) print(length2) print(length3) #rule compositions s1s2= length1 + length2 s2s3= length2 + length3 s3s1= length3 + length1 #add print statement if s1s2 > length3 and s2s3 > length1 and s3s1 > length2: print('YOU HAVE A TRIANGLE!')
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern