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 cqual (S = Si = S2 = Si). Then compute the perimeter (P) and area (A) of triangle as follows: P= 35 ; A =s

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

please use spyder

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 = Sı = S2 = S:). Then compute the
perimeter (P) and area (A) of triangle as follows:
v3
P= 35; A =-s?
- Not equilateral triangle if sides are not equal. Then compute the perimeter and area
of triangle as follows:
P = S, + S2 + S, ; A = P/2-(P/2-s.).(*/2- s2). (*/2– S»)
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
3:6.982 7.53 8.4
Sidel
Side2
Side3
Perimeter Area
Туре
4.50
5.5e
6.55
16.55
12.23
Not Equilateral
Not Equilateral
Equilateral
Equilateral
4:2.5 2.5 2.5
6.98
2.50
7.53
2.se
8.40
2.5e
22.91
7.se
24.80
2.71
5:-3.0 5.678 5.01
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 = Sı = S2 = S:). Then compute the perimeter (P) and area (A) of triangle as follows: v3 P= 35; A =-s? - Not equilateral triangle if sides are not equal. Then compute the perimeter and area of triangle as follows: P = S, + S2 + S, ; A = P/2-(P/2-s.).(*/2- s2). (*/2– S») 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 3:6.982 7.53 8.4 Sidel Side2 Side3 Perimeter Area Туре 4.50 5.5e 6.55 16.55 12.23 Not Equilateral Not Equilateral Equilateral Equilateral 4:2.5 2.5 2.5 6.98 2.50 7.53 2.se 8.40 2.5e 22.91 7.se 24.80 2.71 5:-3.0 5.678 5.01 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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Transmission media
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.
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