Funnel Conversion Report

Easy ⏱ 8 min 87% acceptance ★★★★★ 4.7
Write funnel_report(visited, carted, purchased) returning a dict with cart_rate (carted/visited), purchase_rate (purchased/carted) and abandonment (1 − purchase_rate), each as a percentage rounded to 1 decimal. Any zero denominator makes that metric None — division-by-zero must not crash a dashboard.

Examples

Example 1
Input
funnel_report(1000, 200, 50)
Output
{'cart_rate': 20.0, 'purchase_rate': 25.0, 'abandonment': 75.0}
Explanation

Each stage is a ratio of the one before.

Constraints

  • Percentages, 1 decimal.
  • None on zero denominators.

Topics

Business Logicmetrics

Companies

ShopifyAmazonMeesho

Hints

Hint 1

A tiny helper pct(a, b) avoids repeating the guard.

Hint 2

abandonment = 100 - purchase_rate when defined.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.