Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Run Write a Python program that promts the user to enter the sides of a triangle. After checking each side which must be positive,


student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below 

Run Write a Python program that promts the user to enter the sides of a triangle. After checking each side which must be positive, it will display one the following messages: The input values cannot represent the sides of a triangle Equilateral triangle Isosceles triangle Scalene triangle The first check is that all sides must be positive. If one of the sides is not positive, the program will display error message and stops and does not continue reading the remaining sides. The condition for the sides to form a triangle is that the sum of any 2 sides must be greater than the third side. For the remaining cases, the conditions are as follows: Equilateral triangle, all sides are equal. Isosceles triangle, two of the 3 sides are equal. Scalene triangle, all three sides are different. Note that your output message must match exactly the strings displayed by the sample runs. Sample run 1: Enter side1: -4.5 Sidei must be positive Sample run 21 Enter side1: 5.6 Enter side2: -7.8 Side2 must be positive 1104 E ENG 31C 10/9/20 For the remaining cases, the conditions are as follows: Equilateral triangle, all sides are equal. Isosceles triangle, two of the 3 sides are equal. Scalene triangle, all three sides are different. Note that your output message must match exactly the strings displayed by the sample runs. Sample run 1: Enter side1: -4.5 Sidel must be positive Sample run 2: Enter side1: 5.6 Enter side2: -7.8 Side2 must be positive Sample run 3: Enter side1: 6] Enter side2: 3.8 Enter side3: -10.9 Side3 must be positive Sample run 4: Enter side1: 5.6 Enter side2: 3.7 Enter side3: 11.5 The input values cannot represent the sides of a triangle sidel = float (input("Enter side1: ")) if sidel < 0: print("sidel must be positive") else: side2 = float(input("Enter side2: ")) if side2 < 0: print("side2 must be positive") else: side3 float (input("Enter side3: ")) if side3 < 0: print("side3 must be positive") if sidel side2 > side3 and side2 + side3 >sidel and sidel + side3 >side # Check the type of triangle else: if sidel side2 == == side3: print("Equilateral triangle") elif sidel == side2 or sidel == side3 or side2 == side3: print("Isosceles triangle") else: print("Scalene triangle") print("The input values cannot represent the sides of a triangle") Enter sidel: -4 sidel must be positive The input values cannot represent the sides of a triangle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Databases questions

Question

Questions are in the problem only

Answered: 1 week ago

Question

What does is a function of mean?

Answered: 1 week ago