Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

A bottle green sports jacket is hard to find.

Answered: 1 week ago