Python 기본 사항쉬움

주어진 좌표가 있는 사분면

'주어진 좌표가 있는 사분면' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

데카르트 평면의 점을 나타내는 두 개의 정수 xy을 사용하고 점이 어느 사분면에 있는지 나타내는 문자열을 반환하는 함수 find_quadrant(x, y)을 작성하세요.

반환:

- x > 0이고 y > 0인 경우 '사분면 1'

- x < 0이고 y > 0인 경우 '사분면 2'

- x < 0이고 y < 0인 경우 '사분면 3'

- x > 0이고 y < 0인 경우 '사분면 4'

- x == 0이고 y == 0인 경우 '원점'

- y == 0이고 x != 0인 경우 'X축'

- x == 0이고 y != 0인 경우 'Y축'

제약
  • -10^4 <= x, y <= 10^4

Example 1
Input
find_quadrant(3, 5)
Output
'Quadrant 1'
Explanation

Both x=3 and y=5 are positive, so the point is in Quadrant 1 (upper-right).

Example 2
Input
find_quadrant(-2, 4)
Output
'Quadrant 2'
Explanation

x=-2 is negative and y=4 is positive, so the point is in Quadrant 2 (upper-left).

Example 3
Input
find_quadrant(-1, -7)
Output
'Quadrant 3'
Explanation

Both x=-1 and y=-7 are negative, so the point is in Quadrant 3 (lower-left).

Need a Hint?
세트나 힙과 같은 Numbers 관련 데이터 구조를 사용해 보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.