Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In here, you will write two functions. 1) is_square() with four parameters x1, y1, x2, y2. The function checks whether (x1, y1) and (x2, y2)

In here, you will write two functions.

1) is_square() with four parameters x1, y1, x2, y2. The function checks whether (x1, y1) and (x2, y2) could be the opposite corners of a square.

The following is just one of several possibilities. This requires a little bit of analysis. If all of the following conditions are satisfied, we can say that the parameters have the x and y of the top-left corner in x1 and y1, respectively, and the x and y coordinates of the second corner in x2 and y2, respectively, and the parameters correspond to a square. x2 > x1

y1 > y2

x2 x1 == y1 y2 Consider what the other possibilities are and write conditions for them. Write ou the Boolean expression that considers all possibilities and correctly code the function

2) main() with no parameters. It prompts the user with a question Do you wish to process corners? y or n If the user enters y, the code within the function prompts for the four coordinates. Use the following statement. x1, y1 = eval(input("Enter the x and y coordinates for one corner: ")) The user has to put a comma between the values entered for x1 and y1. Similar code can be used for reading in the values of x2 and y2. The function then calls the is_square() function with the required parameters. It uses the return value to display whether the coordinates correspond to the opposite corners of a square.

The function continues to prompt until the user enters something other than y.

3) Code the function is_square() first. After that code the function main().

4) Do not forget to invoke the main() function.

5) Test and debug your program.

PLEASE USE PYTHON 3.6

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago