Programming Examples

Python program to check whether dart hit inside board or outside


dartboard

A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the boards 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)

Solutions:
import math
x=int(input("Enter the Coordinate x : "))
y=int(input("Enter the Coordinate y : "))
distance=math.sqrt(math.pow(x,2)+math.pow(y,2))
if distance<=10:
    print("Within Board")
else:
    print("Outside Board ")
Output

Enter the Coordinate x : 6

Enter the Coordinate y : 6

Within Board

>>> 

================= 

Enter the Coordinate x : 10

Enter the Coordinate y : 10

Outside Board 

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad