In Math, an equilateral triangle is a triangle in which all three sides are equal. You are provided with an input file (“Data.txt") containing a number of text lines. Each line contains a record of a supposed triangle. Each record has four attributes: record number, three sides values. The record number and the sides are separated by :' while the three attributes are separated by one space. Figure 1 shows a sample input file. You are asked to write a Python program that reads the content of the input file, checks whether the sides form a triangle or not. When the sides form a triangle, finds out its type ('Equilateral' or 'Not Equilateral' then computes its perimeter (P) and its area (A). There will be three cases according sides values:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use loop to solve this python program and use Error handling:
IOError (File not found)

In Math, an equilateral triangle is a triangle in which all three sides are equal.
You are provided with an input file (“Data.txt") containing a number of text lines. Each line
contains a record of a supposed triangle. Each record has four attributes: record number, three
sides values. The record number and the sides are separated by :' while the three attributes are
separated by one space. Figure 1 shows a sample input file.
You are asked to write a Python program that reads the content of the input file, checks whether
the sides form a triangle or not. When the sides form a triangle, finds out its type (Equilateral’ or
'Not Equilateral' then computes its perimeter (P) and its area (A). There will be three cases
according sides values:
> Equilateral triangle if all sides are equal (S = S1 = S2 = S3). Then compute the
perimeter (P) and area (A) of triangle as follows:
V3
P = 3S ; A :
4
%3D
= -
Not equilateral triangle if sides are not equal. Then compute the perimeter and area
of triangle as follows:
P = S, + S2 + S3 ; A = JP/2.(P/2- s.).(P/2- S2). (P/2 – S3)
Not triangle if one side or more, is less than or equal zero. Then add record number in
a list of records not forming a triangle then read next record.
Your program should display for each triangle, the sides of the triangle, its perimeter and its area
as well as its type (Equilateral or Not equilateral). Your program should also display, as a comma
separated list, the numbers of records that are not a triangle. The figure 2 shows a sample output.
1:4.5 5.5 6.555
2:0 4.56 2.9
Side1
Side2
Side3
Perimeter
Area
Туре
3:6.982 7.53 8.4
4.50
5.50
16.55
Not Equilateral
Not Equilateral
Equilateral
Equilateral
6.55
12.23
4:2.5 2.5 2.5
6.98
7.53
8.40
22.91
24.80
5:-3.0 5.678 5.01
2.50
2.50
2.50
7.50
2.71
6:6.0 6.0 6.0
6.00
6.00
6.00
18.00
15.59
7:9.3 10.032 -6.0213
======
Records not a triangle: 2, 5, 7
Figure 1. Sample input file
Figure 2. Sample output
Transcribed Image Text:In Math, an equilateral triangle is a triangle in which all three sides are equal. You are provided with an input file (“Data.txt") containing a number of text lines. Each line contains a record of a supposed triangle. Each record has four attributes: record number, three sides values. The record number and the sides are separated by :' while the three attributes are separated by one space. Figure 1 shows a sample input file. You are asked to write a Python program that reads the content of the input file, checks whether the sides form a triangle or not. When the sides form a triangle, finds out its type (Equilateral’ or 'Not Equilateral' then computes its perimeter (P) and its area (A). There will be three cases according sides values: > Equilateral triangle if all sides are equal (S = S1 = S2 = S3). Then compute the perimeter (P) and area (A) of triangle as follows: V3 P = 3S ; A : 4 %3D = - Not equilateral triangle if sides are not equal. Then compute the perimeter and area of triangle as follows: P = S, + S2 + S3 ; A = JP/2.(P/2- s.).(P/2- S2). (P/2 – S3) Not triangle if one side or more, is less than or equal zero. Then add record number in a list of records not forming a triangle then read next record. Your program should display for each triangle, the sides of the triangle, its perimeter and its area as well as its type (Equilateral or Not equilateral). Your program should also display, as a comma separated list, the numbers of records that are not a triangle. The figure 2 shows a sample output. 1:4.5 5.5 6.555 2:0 4.56 2.9 Side1 Side2 Side3 Perimeter Area Туре 3:6.982 7.53 8.4 4.50 5.50 16.55 Not Equilateral Not Equilateral Equilateral Equilateral 6.55 12.23 4:2.5 2.5 2.5 6.98 7.53 8.40 22.91 24.80 5:-3.0 5.678 5.01 2.50 2.50 2.50 7.50 2.71 6:6.0 6.0 6.0 6.00 6.00 6.00 18.00 15.59 7:9.3 10.032 -6.0213 ====== Records not a triangle: 2, 5, 7 Figure 1. Sample input file Figure 2. Sample output
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education