. You should submit 2 files for this question. a. Create a
module that will only contain functions to compute the area of a
circle, rectangle, square, and triangle. b. Download JaneDoe3_1.py.
Look over the code and compare it to the sample output to get an
idea of what the code is meant to do. Fill out the missing parts
with the help of the code comments. c. Test your program by
comparing it with the sample output. Pay attention to the prompts
and numeric output for things your code needs to account for.
Please note: • Numeric input must be treated as floats and
displayed to 2 decimal places. • Strip your string input and make
sure you are accounting for upper and lower case input. • Module
names are traditionally lower case so use the format provided when
giving your module a name. SAMPLE OUTPUT ----------------------
SELECT SHAPE ---------------------- 1 - Circle 2 - Rectangle 3 -
Square 4 - Triangle Shape number: 0 Shape number (1-4): 5 Shape
number (1-4): 1 Circle radius: 10 Circle area = 314.16 Continue
(y/n): x Enter y or n: y ---------------------- SELECT SHAPE
---------------------- 1 - Circle 2 - Rectangle 3 - Square 4 -
Triangle Shape number: 2 Rectangle length: 5 Rectangle width: 10
Rectangle area = 50.00 Continue (y/n): Y ----------------------
SELECT SHAPE ---------------------- 1 - Circle 2 - Rectangle 3 -
Square 4 - Triangle Shape number: 3 Square length: 10 Square area =
100.00 Continue (y/n): y ---------------------- SELECT SHAPE
---------------------- 1 - Circle 2 - Rectangle 3 - Square 4 -
Triangle Shape number: 4 Triangle base: 2 Triangle height: 4
Triangle area = 4.00 Continue (y/n): n PROGRAM DONE code: # Part 1
# Import the necessary module (use an alias name during importation
to help with code readability) def selection():
print('----------------------') print('SELECT SHAPE')
print('----------------------') print('1 - Circle') print('2 -
Rectangle') print('3 - Square') print('4 - Triangle') # Code to
check that a valid shape has been selected shape = int(input('Shape
number: ')) while shape < 1 or shape > 4: shape =
int(input('Shape number (1-4): ')) return shape def main(): while
True: pass # Delete this statement and use the comments below to
fill out the missing code # Part 2 # Determine which shape the user
selected by calling the selection() function # Determine which area
should be computed based off the value returned by the selection()
function # Part 3 # Ask the user if they want to continue # If they
enter 'n', break out of the loop and display 'PROGRAM DONE' # If
they enter 'y' the loop should be repeated (go back to the top of
the loop) # Use a loop to check that they are entering a valid
response (y/n) if __name__ == '__main__': main()
. You should submit 2 files for this question. a. Create a module that will only contain functions to compute the area o
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
. You should submit 2 files for this question. a. Create a module that will only contain functions to compute the area o
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!