Name_______Paromita Tiwari___________ 02.
03 The Math Module
This assignment has three parts.
Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional
object. Use the following guidelines to write your program:
1. Create a word problem that involves calculating the volume and surface area of a three-
dimensional object. Choose one of the following:
Cube: surface area 6 s2, volume s3
Sphere: surface area 4πr², volume (4.0/3.0) π r3
Cylinder: surface area 2π r2 + 2 π rh, volume π r2 h
Cone: surface area πr(r + √ r 2 + h2 ), volume 1.0/3.0 π r2 h
2. Print the description of the word problem for the user to read.
3. Ask the user to enter the information necessary to perform the calculations. For
instance, the value for the radius.
4. Use 3.14 for the value of π as needed.
5. Print the results of each calculation.
6. Write the pseudocode for this program. Be sure to include the needed input,
calculations, and output.
Insert your pseudocode here:
Input:
Describe the problem of the gift box
Write code for input of side length of box
Write calculations to find surface area of cube using input value and volume.
Output:
Surface area and volume are given.
Part Two: Code the program. Use the following guidelines to code your program.
7. To code the program, use the Python IDLE.
8. Using comments, type a heading that includes your name, today’s date, and a short
description of the program.
9. Follow the Python style conventions regarding indentation and the use of white space to
improve readability.
10. Use meaningful variable names.
Example of expected output: The output for your program should resemble the following screen shot.
Your specific results will vary depending on the choices you make and the input provided.
Insert a copy of your code from IDLE here:
#Paromita Tiwari
#12/29/2019
#02.03 The Math Module- To create a word problem and code to solve it.
from math import *
def main():
print("You want to put a present in a cube shaped gift box and wrap it. You need to know the volume
of the box and the surface area so that you can determine if the gift will fit in it and how much
wrapping paper you will need. Using the length of one side, this program will find both values for
you.")
sideLength = float(input("What is the length of the cube's sides?"))
surfaceArea = ((6) * pow(sideLength, 2))
cubeVolume = pow(sideLength, 3)
print("The surface area of the cube is " + str(surfaceArea) + " square units")
print("The volume of the cube is " + str(cubeVolume) + " cubic units.")
main()
Part Three: Complete the Post Mortem Review (PMR). Write thoughtful two to three sentence responses
to all the questions in the PMR chart.
Review Question Response
What was the purpose of your program? The purpose of my program was to help someone
find the surface area and volume of a cube shaped
gift box based on its side length.
How could your program be useful in the real In the real world, someone who needs to buy a
world? proper gift box can use this to see if the box they
need is useful with the gift they have.
What is a problem you ran into, and how did you I got errors because I forgot to put quotations
fix it? around my strings when I tried printing the
statements that told the surface area and the
volume. I fixed this by adding the quotations in.
Describe one thing you would do differently the I would pay attention more to the smaller details in
next time you write a program. my code like quotations and parenthesis because a
small mistake there can lead to a whole line not
working.