Question: In Python Please: Task: Four shapes we can describe with only length and width: -squares: have same length and width -rectangles different lengths and width
In Python Please:
Task: Four shapes we can describe with only length and width:
-squares: have same length and width
-rectangles different lengths and width
-lines: have a single dimension
-points: have no dimensions
For this task, you are going to determine, based on the length and width of some shape, what type of shape it is. Additionally, youll apply some adjective to the shape if needed (big, long, or wide):
def shape_type(length, width): accepts two integer parameters for the shapes (length and width, in that order) and performs the following actions:
- determines if the measurement is valid (length and width must be between 0 and 100, inclusive.)
-if measurement is invalid return the string "bad measurement!"
determines the shape defined by the parameters ("point", "line", "square", or "rectangle") and an appropriate adjective based on the following rules:
-if length is greater than 75, the shape is "long"
-if the width is greater than 75, the shape is "wide"
-if the length and width is greater than 75, the shape is "big"
-lines can only be "long", not "wide"
-if none apply, then no adjective needed
-returns the shape as a string, e.g. "square", "long line", "point", "big rectangle", etc.
Examples:
# length and width are equal, both are greater than 75
shape_type(100, 100) -> 'big square'
#length can't be negative
shape_type(-1, 100) -> 'bad measurement!'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
