Discounted Price Calculator

Easy
Data Cleaning
Arithmetic

Discounted Price Calculator

The products table lists catalogue prices and the discount percentage currently offered on each item.

Return product_id, product_name, discounted_price, where discounted_price is the price after the discount, rounded to 2 decimal places. Sort by product_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.products6 rows
product_id (int)product_name (string)price (double)discount_pct (int)
1Aero Mug24.9910
2Trail Bottle39.4925
3Desk Lamp580
4Canvas Tote18.7540
5Wireless Pad49.9915
6Notebook Set12.55

Return these columns

product_id(int)
product_name(string)
discounted_price(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.