Let's do a little geometry!
-
Create three variables
a,bandc. -
Assign a number to each to represent the lengths of the sides of a triangle.
-
Calculate the
perimeterof the triangleOutput
A triangle with sides of 3, 4, and 5 has a perimeter of 12.
-
Create variables with numbers representing the
baseandheightmeasurements of the triangle. Selecta,borcto represent thebase. -
Calculate the
areaof the triangle.Output
A triangle with a base of 5 and a height of 8 has an area of 20.0. --- A triangle with a base of 2.8 and a height of 2.02 has an area of 2.828.
-
Assign a number to a variable to represent the
radiusof a circle. -
Use the constant for
picontained within themathmodule and theradiusvariable to calculate thecircumferenceandareaof a circle.Output
Circle Radius: 5 Circumference: 31.4159... Area: 78.5398...
-
Calculate the
volumeof a sphere with the sameradius.Output
Sphere Radius: 5 Volume: 523.5987...
-
Assign a number to a variable to represent the
radiusof a second circle. -
Use the two radii to calculate the area of an annulus.
Output
Annulus Outer Radius: 5 Inner Radius: 3 Area: 50.26548245743669
-
Create two variables,
aandbto represent the adjacent sides of a right triangle. -
Find the hypotenuse of a triangle using
aandb. Assign the value to a variablec. -
Display the result to the user
A triangle with sides of 65 and 72 has a hypotenuse of 97.
Use the random module to generate random integer values for the circle and sphere's radius and the triangle's base and height.
Have the user enter all number values used in previous versions. Don't forget that input() always returns a string.