Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education