Python Programming Exercises, Gently Explained
14
Figure 4-1: The components of area, volume, perimeter, and surface area.
These Python assert statements stop the program if their condition is False. Copy them to
the bottom of your solution program. Your solution is correct if the following assert statements’
conditions are all True:
assert area(10, 10) == 100
assert area(0, 9999) == 0
assert area(5, 8) == 40
assert perimeter(10, 10) == 40
assert perimeter(0, 9999) == 19998
assert perimeter(5, 8) == 26
assert volume(10, 10, 10) == 1000
assert volume(9999, 0, 9999) == 0
assert volume(5, 8, 10) == 400
assert surfaceArea(10, 10, 10) == 600
assert surfaceArea(9999, 0, 9999) == 199960002
assert surfaceArea(5, 8, 10) == 340
Try to write a solution based on the information in this description. If you still have trouble
solving this exercise, read the
Solution Design and
Special Cases and Gotchas sections for
additional hints.
Prerequisite concepts: math operators, operator precedence
Dostları ilə paylaş: