Point Location on Axes
Identify the origin and coordinate axes with Python conditions. Students learn why the most specific zero-coordinate case belongs before the broader axis tests.
1# Take coordinates2x = float(input("Enter x coordinate: "))3y = float(input("Enter y coordinate: "))45# Check location6if x == 0 and y == 0:7 print("At origin")8elif x == 0:9 print("On Y-axis")10elif y == 0:11 print("On X-axis")12else:13 print("Not on any axis")
Output
Enter x coordinate: 0 Enter y coordinate: 0 At origin Enter x coordinate: 0 Enter y coordinate: 5 On Y-axis Enter x coordinate: 3 Enter y coordinate: 0 On X-axis
In this one
- Prioritize a specific case
- Understand coordinate axes
- Cover off-axis points
How it works
- 1
Read x and y.
- 2
Check both zero before checking either zero alone.
- 3
Print origin, the relevant axis, or neither.
Edge cases
Where is (0, 5)?
Where is (0, 5)?
On the Y-axis, since x is zero.
Where is (0, 0)?
Where is (0, 0)?
At origin, caught before either broader axis case.
What's going on
The origin satisfies both axis conditions, so it must be tested first. The program reads x and y as floating-point coordinates and checks whether both are zero.
If only x is zero, the point lies on the Y-axis. If only y is zero, it lies on the X-axis. A point with neither zero is off both axes; this program does not name its quadrant.
Where is (0, 5)? On the Y-axis, since x is zero.
Where is (0, 0)? At origin, caught before either broader axis case.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
Why test the origin first?
Pick an answer to check it.
Question 2
Where is (0, 5)?
Pick an answer to check it.
Questions people ask
Where is (0, 5)?
On the Y-axis, since x is zero.
Where is (0, 0)?
At origin, caught before either broader axis case.
Why test the origin first?
It would also satisfy the individual axis tests.
๐Related Content
- ๐
Phase 1 - Learn Concepts
Review Phase 1 concepts and explanations
- ๐
Phase 1 - Quiz
Test your Phase 1 understanding with quiz questions
- ๐ป
Phase 1 - All Practice Problems
Explore all practice problems for Phase 1
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum