LearnPy Hub
← Pandas: Cleaning & Preprocessing problems
Medium

Outliers With the IQR Rule

Compute Q1 and Q3 of the amounts with quantile(0.25) and quantile(0.75), and IQR = Q3 − Q1. An amount is an outlier if it is below Q1 − 1.5·IQR or above Q3 + 1.5·IQR. Print the outlier amounts on one line (or none), then how many rows are left after removing them.

Input

Lines 'date region product amount', then END.

Output

Two lines.

Sample 1

Input
2026-01-01 Dhaka Tea 100
2026-01-02 Dhaka Tea 120
2026-01-03 Dhaka Tea 110
2026-01-04 Dhaka Tea 105
2026-01-05 Dhaka Tea 900
2026-01-06 Dhaka Tea 95
END
Output
900
5

Sample 2

Input
2026-01-15 Dhaka Tea 500
2026-01-20 Sylhet Tea 300
2026-02-03 Dhaka Rice 1200
2026-02-18 Khulna Tea 450
2026-03-07 Sylhet Rice 800
2026-03-21 Dhaka Tea 650
END
Output
none
6
solution.py
Output appears here
Outliers With the IQR Rule · Python practice problem · LearnPy Hub