Point Location on Axes
Take coordinates (x, y) and check if the point lies on the X-axis, Y-axis, or at the origin.
AdvancedPhase 1 - Level 5: Creative / Tricky Logical ScenariosExample 1 of 10
point-location-on-axes.py
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
What's going on
Check for zero coordinates to determine axis location.
Key Concepts:
Origin: both x and y are 0
Y-axis: x is 0, y is not 0
X-axis: y is 0, x is not 0
Check origin first, then axes
🔗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