Q. A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s center at coordinate (0,0). Variables x and y store

The x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates:

(a) (0, 0)

(b) (10, 10)

(c) (6, 6)

(d) (7, 8)


Answer:-



x = float (input ("Enter x coordinate: - "))
y = float (input ("Enter y coordinate: - "))
distance = ((x-0)**2 + (y-0)**2 )**(1/2)
if distance <= 10:
    print ("True")
else:
    print ("False")


Output:-

(a)
Enter x coordinate: - 0
Enter y coordinate: - 0
True
>>>

(b)
Enter x coordinate: - 10
Enter y coordinate: - 10
False
>>>

(c)
Enter x coordinate: - 6
Enter y coordinate: - 6
True
>>>

(d)
Enter x coordinate: - 7
Enter y coordinate: - 8
False
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post