The distance formula can be used to calculate the distance between the points where the dart hits the dartboard and the centre of the dartboard.
The distance of a point P(x, y) from the origin is given by \(\sqrt{x^2+y^2}\)
To calculate the square root, the equation can be raised to the power 0.5.
Program:
x = int(input('Enter X Coordinate: '))
y = int(input('Enter Y Coordinate: '))
dis = (x ** 2 + y ** 2) ** 0.5
#if dis is greater than 10, means that dart is more than 10 units away from the centre.
print(dis <= 10)
The output for the dart coordinates are as follows:
a) (0,0): True
b) (10,10): False
c) (6,6): True
d) (7,8): False