-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2. Q12.py
More file actions
24 lines (20 loc) · 926 Bytes
/
2. Q12.py
File metadata and controls
24 lines (20 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'''Given the coordinates (x,y) of center of a circle and its radius,
determine whether a point lies inside the circle, on the circle or outside
the circle. (Hint: Use sqrt( ), pow( ) )'''
import math
# Circle center and radius
x_center = float(input("Enter x coordinate of circle center: "))
y_center = float(input("Enter y coordinate of circle center: "))
radius = float(input("Enter radius of the circle: "))
# Point coordinates
x_point = float(input("Enter x coordinate of the point: "))
y_point = float(input("Enter y coordinate of the point: "))
# Calculate distance between point and center
distance = math.sqrt(math.pow(x_point - x_center, 2) + math.pow(y_point - y_center, 2))
# Compare with radius
if distance < radius:
print("The point lies inside the circle.")
elif distance == radius:
print("The point lies on the circle.")
else:
print("The point lies outside the circle.")