Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Determine Cartesian Quadrant

Given x and y coordinates, determine which Cartesian quadrant (or axis/origin) the point lies in.

Python practice14 minControl Flow (If–Else Logic)IntermediateLast updated March 15, 2026

Problem statement

Write a function determine_quadrant(x, y) that returns a string indicating where the point (x, y) lies: - Return 'Q1' if x > 0 and y > 0. - Return 'Q2' if x < 0 and y > 0. - Return 'Q3' if x < 0 and y < 0. - Return 'Q4' if x > 0 and y < 0. - If the point is on the x-axis (y == 0 but x != 0), return 'X axis'. - If the point is on the y-axis (x == 0 but y != 0), return 'Y axis'. - If the point is at the origin (0, 0), return 'Origin'. Use if/elif/else to implement the logic.

Task

Practice multi-branch decision making using if, elif, and else to return the correct quadrant label or axis/origin description.

Examples

Point in first quadrant

Input

determine_quadrant(3, 4)

Output

Q1

Both x and y are positive, so the point is in quadrant 1.

Input format

Two integers x and y passed to the function determine_quadrant(x, y).

Output format

A string among: 'Q1', 'Q2', 'Q3', 'Q4', 'X axis', 'Y axis', or 'Origin'.

Constraints

x and y are integers. Use only basic control flow (if/elif/else).

Samples

Sample 1

Input

determine_quadrant(-2, 3)

Output

Q2

x is negative and y is positive, so quadrant 2.