Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a module that will only contain functions to compute the area of a circle, rectangle, square, and triangle. b. Look at this code and

Create a module that will only contain functions to compute the area of a circle, rectangle, square, and triangle.

b. Look at this code and fill out the missing parts that the comments want you to fill out.:

# 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 4: shape = int(input('Shape number (1-4): ')) return shapedef 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()

c. Test your program by comparing it to the sample output, Pay attention to the prompts and numeric output for things your code needs to account for.

Sample Output:

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

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

2. Write a program to play the popular rock-paper-scissors game with a computer.

a. Best of three wins the game

b. Use the random module.

Sample:

Rock - Paper - Scissor

Enter response: paper

Computer is rock, You are paper. You win.




Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

d. What is the value of the sample correlation coefficient?

Answered: 1 week ago