9 /11 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,...


9 /11<br>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 =<br>2<br>base X height.<br>→ Circle area n radius2.<br>- Trapezoid area =<br>; (base 1 + base2)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>dimensions are incorrect (e.g. negative value or number of values for a trapezoid not<br>equal to 3: base,, basez and height, or), in which case RuntimeError exception should<br>be raised and the processing should continue.<br>50<br>48<br>Shape<br>Area<br>Triangle:<br>Circle: -10<br>Triangle<br>Circle<br>1200.00<br>Trapezoid: 10 12 70<br>Trapezoid:<br>>> invalid dimension<br>770.00<br>>> missing data.<br>9 32<br>Trapezoid<br>Trapezoid<br>Sample input file<br>Sample output<br>

Extracted text: 9 /11 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 = 2 base X height. → Circle area n radius2. - Trapezoid area = ; (base 1 + base2)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 dimensions are incorrect (e.g. negative value or number of values for a trapezoid not equal to 3: base,, basez and height, or), in which case RuntimeError exception should be raised and the processing should continue. 50 48 Shape Area Triangle: Circle: -10 Triangle Circle 1200.00 Trapezoid: 10 12 70 Trapezoid: >> invalid dimension 770.00 >> missing data. 9 32 Trapezoid Trapezoid 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