Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Recall the geometry example from class. Create new modules for triangles, spheres, and cylinders and populate them with functions for calculating perimeter and area in the 2-D case (triangles) and...

1 answer below »
Recall the geometry example from class. Create new modules for triangles, spheres, and cylinders and populate them with functions for calculating perimeter and area in the 2-D case (triangles) and volume and surface area in the 3-D cases (spheres and cylinders). Now modify the geometry.py file to work with these as options for the user. SUBMIT: - A modified geometry.py file that works with the new modules you have created. - triangle.py, sphere.py, and cylinder.py files which contain the methods specified above. Attached: original geometry.py and an example for sphere.py # The circle module has functions that perform
# calculations related to circles.
import math
pi=math.pi
# The area function accepts a circle's radius as an
# argument and returns the area of the circle.
def area(radius):
return math.pi * radius**2
# The circumference function accepts a circle's
# radius and returns the circle's circumference.
def circumference(radius):
return 2 * math.pi * radius
Extracted text: # The circle module has functions that perform # calculations related to circles. import math pi=math.pi # The area function accepts a circle's radius as an # argument and returns the area of the circle. def area(radius): return math.pi * radius**2 # The circumference function accepts a circle's # radius and returns the circle's circumference. def circumference(radius): return 2 * math.pi * radius # This program allows the user to choose various
# geometry calculations from a menu. This program
# imports the circle and rectangle modules.
import circle
import rectangle
# The main function.
def main():
# The choice variable controls the loop
# and holds the user's menu choice.
choice = 0
while not(choice == 5):
# display the menu.
display_menu ( )
# Get the user's choice.
choice = int(input('Enter your choice: '))
# Perform the selected action.
if choice == 1:
r = float(input(
Extracted text: # This program allows the user to choose various # geometry calculations from a menu. This program # imports the circle and rectangle modules. import circle import rectangle # The main function. def main(): # The choice variable controls the loop # and holds the user's menu choice. choice = 0 while not(choice == 5): # display the menu. display_menu ( ) # Get the user's choice. choice = int(input('Enter your choice: ')) # Perform the selected action. if choice == 1: r = float(input("Enter the circle's radius: ")) print('The area is {:.3f}.'.format(circle.area(r))) elif choice == 2: radius = float(input("Enter the circle's radius: ")) print('The circumference is {:.3f}'.\ format(circle.circumference(radius))) elif choice == 3: width = float(input("Enter the rectangle's width: ")) length = float(input("Enter the rectangle's length: ")) print('The area is {:.3f}'.format(rectangle.area(width, length))) elif choice == 4: width = float(input("Enter the rectangle's width: ")) length = float(input("Enter the rectangle's length: ")) print ('The perimeter is {:.3f}'.\ format(rectangle.perimeter(width, length))) elif choice == 5: print("Exiting the program...") else: print ("Error: invalid selection.") # The display_menu function displays a menu. def display_menu(): print( print("1) Area of a circle") print ("2) Circumference of a circle") print ("3) Area of a rectangle") print ("4) Perimeter of a rectangle") print("5) Quit") MENU for ") # Call the main function. main()
Answered 121 days After Jun 02, 2022

Solution

Baljit answered on Oct 01 2022
73 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here