'Lab4 - trying to understand what I'm supposed to do
This is what I have to do; "Assume that you have the coordinates (x,y) of four points p1, p2, p3, and p4. Write a function name check_is_square() that asks the user for the coordinates of those four points (total of eight integer inputs) and prints the message Yes – it is a Square if those four points can form a square on the coordinate plane and the message No – it is not a square otherwise. Call check_is_square()from the main() function."
This is the code I have currently;
import math
def check_square(x1,x2,y1,y2):
if (math.sqrt((x1 - x2)**2+(y1-y2)**2) % 2 == 0):
print("Yes - it is a square")
else:
print("No - it is not a square")
def main():
x1 = int(input("Enter coordinate 1: "))
x2 = int(input("Enter coordinate 2: "))
y1 = int(input("Enter coordinate 3: "))
y2 = int(input("Enter coordinate 4: "))
check_square(x1,x2,y1,y2)
main()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
