Order Total with Discount

Easy
Arithmetic

Order Total with Discount

The orders table contains quantity, unit price, and a percentage discount.

Return order_id, total_amount, where total_amount is quantity * unit_price * (1 - discount_pct / 100), rounded to 2 decimal places. Sort by order_id ascending.

Browser Engine: Evaluates PySpark DataFrame & SQL logic locally in Pyodide WebAssembly.

Input data

1 DataFrame

These DataFrames are passed to solve(spark, dfs). Access one with dfs['name'].

df.orders6 rows
order_id (int)quantity (int)unit_price (double)discount_pct (int)
125010
211200
342520
434025
551050
627515

Return these columns

order_id(int)
total_amount(double)

Column names and order must match. Sort order is specified in the question.

Browser engine
Loading Python editor…
Click Run to try the sample cases, or Submit to check the hidden cases. First run caches the browser Python engine (~8–15s once); all code stays on your device.