Question

***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same...

***IN PYTHON:

Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same length Equilateral triangle: All sides are equal

Write a program to ask for the length of 3 sides a, b and c. Ask for three sides at a time Determine the type of triangle given three sides Handle all kinds of errors - 1. not integers, int() conversion fails 2. not enough args, 3. too many arguments HINT: use the len() function to check the number of arguments HINT: only call the function to determine triangle type ONLY when everything is correct.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#Code.py
s = input("Enter length of 3 sides a, b and c: ")
if(len(s.split(" "))==3):
    try:
        a,b,c = [int(x) for x in s.split(" ")]
        if(a == b and a == c):
            print("Equilateral Triangle.")
        elif(a == b or b == c or c == a):
            print("Isosceles Triangle.")
        elif(not (a == b or b == c or c == a)):
            print("Scalene Triangle.")
        else:
            print("The triangle is NOT valid")
    except Exception:
        print("Error: input should be three integers")
else:
    print("Error: input should be three integers")

Add a comment
Know the answer?
Add Answer to:
***IN PYTHON: Scalene triangle: All sides have different lengths Isosceles triangle: Two sides have the same...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT