0% found this document useful (0 votes)
16 views4 pages

Math Module (FINISHED)

The document describes a math assignment to write a Python program to calculate the volume and surface area of a cylinder. It includes pseudocode for the program, showing input of the cylinder name, radius, and height from the user. It then shows calculations using the appropriate formulas and output of the results. The full code is also shown, with input from the user, calculations using math functions, and output of the volume and surface area. A post mortem review questions the purpose of the program, its real-world usefulness, problems encountered, and improvements for the future.

Uploaded by

bb.8chess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Math Module (FINISHED)

The document describes a math assignment to write a Python program to calculate the volume and surface area of a cylinder. It includes pseudocode for the program, showing input of the cylinder name, radius, and height from the user. It then shows calculations using the appropriate formulas and output of the results. The full code is also shown, with input from the user, calculations using math functions, and output of the volume and surface area. A post mortem review questions the purpose of the program, its real-world usefulness, problems encountered, and improvements for the future.

Uploaded by

bb.8chess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Fiona Chen 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:

 Ask for the cylinder name. (string)


 Ask for the radius of the cylinder. (float)
 Ask for the height of the cylinder. (float)

Calculations:

 Formula for the surface area of the cylinder: 2π r2 + 2 π rh


 Formula for the volume of the cylinder: π r2 h
 3.14 for pi
 Use pow() function to square the radius.

Output:

 Prints the name, the surface area, and the volume of the cylinder.

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:

#Fiona Chen
#5/25/23
#Finding the surface area and volume of a cylinder

from math import *

def main():
print("Tom is a store clerk who is investigating the new supplies
coming in from the manufacturer.")
print("He is suspicious that the manufacturer is making the
canned foods smaller due to high inflation.")
print("Therefore, he needs to calculate the volume and surface
area of the new cans. Can you help him?")
canName = input("Insert Name of the can: ")
print(" ")
print("The " + canName)
radius = float(input("What is the radius of the cylinder? (In
meters)"))
height = float(input("What is the height of the cylinder? (In
meters) "))
volume = pow(radius, 2) * 3.14 * height
surfaceArea = (2 * 3.14 * pow(radius, 2)) + (2 * 3.14 * radius *
height)
print("with a radius of " + str(radius) + ",")
print("and a height of " + str(height) + ",")
print("the volume of the " + canName + " is " + str(volume) + "
cubic centimeters and ")
print("the surface area of the " + canName + " is " +
str(surfaceArea) + " square centimeters.")

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 this program is to find the volume
and the surface area of a cylinder using the height
and radius. It also offers a chance for me to
practice and learn from my newly learned skills.
How could your program be useful in the real This program can be used to calculate the volume
world? and radius of any cylinder, including cans,
construction bases for highways, and
architectural columns. The volume and the
surface area can be used to scale how much space
something takes up, a crucial point when
designing a cylindrical structure.
What is a problem you ran into, and how did you One of the problems I ran into was that instead of
fix it? putting my float()before the input statement,
I put it in my input statement, resulting in an
error. I fixed it by simply reversing the role and
bingo…
Describe one thing you would do differently the One thing I would do differently is pay attention
next time you write a program. to where the str(), float(), and int() went. I spent
way too much time staring at my code and not
knowing where on one very specific line, what
went wrong. Also, I didn’t realize that the from
math import * has SPACES between and I had
to re-check that out from the lessons.

You might also like