100% Exercise 1: Write a python program that reads from a text file whose name is provided by the user and including lines relating to the dimensions of three kinds of shapes: Circle, Triangle,...

Use python Use basic format
100%<br>Exercise 1:<br>Write a python program that reads from a text file whose name is provided by the user and<br>including lines relating to the dimensions of three kinds of shapes: Circle, Triangle, Trapezoid<br>(see figure below for a sample input file). For each shape compute and display its area:<br>- Triangle area = base X height.<br>2<br>A Circle area = n radius?.<br>- Trapezoid area = (base , + base,)X height.<br>2<br>Your program should consider the following erroneous cases:<br>• The file does not open/exist<br>The format of the data in the file is incorrect (e.g. shape name = 'Polygon'), the shape's<br>I dimensions are incorrect (e.g. negative value or number of values for a trapezoid not<br>equal to 3: base,, base, and height, or), in which case RuntimeError exception should<br>be raised and the processing should continue.<br>48<br>Shape<br>Area<br>Triangle:<br>Circle: -10<br>50<br>1200.00<br>>> invalid dimension<br>770.00<br>Triangle<br>Trapezoid: 10 12 70<br>Trapezoid:<br>32<br>Circle<br>Trapezoid<br>Trapezoid<br>>> missing data.<br>Sample input file<br>Sample output<br>

Extracted text: 100% Exercise 1: Write a python program that reads from a text file whose name is provided by the user and including lines relating to the dimensions of three kinds of shapes: Circle, Triangle, Trapezoid (see figure below for a sample input file). For each shape compute and display its area: - Triangle area = base X height. 2 A Circle area = n radius?. - Trapezoid area = (base , + base,)X height. 2 Your program should consider the following erroneous cases: • The file does not open/exist The format of the data in the file is incorrect (e.g. shape name = 'Polygon'), the shape's I dimensions are incorrect (e.g. negative value or number of values for a trapezoid not equal to 3: base,, base, and height, or), in which case RuntimeError exception should be raised and the processing should continue. 48 Shape Area Triangle: Circle: -10 50 1200.00 >> invalid dimension 770.00 Triangle Trapezoid: 10 12 70 Trapezoid: 32 Circle Trapezoid Trapezoid >> missing data. Sample input file Sample output

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here