Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 124: 4.19

Answer

code

Work Step by Step

# 4.19 (Compute the perimeter of a triangle) Write a program that reads three edges for a # triangle and computes the perimeter if the input is valid. Otherwise, display that # the input is invalid. The input is valid if the sum of every pair of two edges is # greater than the remaining edge. e1, e2, e3 = eval(input("Enter three edges: ")) if e1 + e2 > e3 and e1 + e3 > e2 and e2 + e3 > e1: res = e1 + e2 + e3 print("The perimeter is", str(res)) else: print("The input is invalid")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.