← All video projects

Free video project · Beginner

Is that Black Friday deal real? 🏷️

Eight weeks of price history decide whether a Black Friday discount is genuine, meh or fake, by comparing the claimed saving with the real one.

The video is out Friday 27 November at 6pm.

The code from the video

# Is that Black Friday deal real?
# prices for the last 8 weeks, oldest first, then the Black Friday price
DEALS = {
    "Air fryer": ([79, 79, 89, 89, 99, 99, 129, 129], 79),
    "Headphones": ([249, 249, 249, 239, 249, 249, 249, 249], 179),
    "Smart speaker": ([55, 49, 45, 55, 55, 55, 55, 59], 49),
    "Coffee machine": ([399, 349, 399, 399, 399, 399, 449, 449], 349),
}

def check(history, deal):
    was = history[-1]
    lowest = min(history)
    average = sum(history) / len(history)
    claimed = round((was - deal) / was * 100)
    real = round((average - deal) / average * 100)
    print(f"  Was £{was}, now £{deal}: claims {claimed}% off, really {real}% below average")
    if deal < lowest:
        return "GENUINE: cheapest in 8 weeks"
    if deal == lowest:
        weeks_ago = len(history) - history.index(lowest)
        return f"MEH: same price {weeks_ago} weeks ago"
    return f"FAKE: it was £{lowest} before"

for item, (history, deal) in DEALS.items():
    print(item)
    verdict = check(history, deal)
    print("  " + verdict)

Run it in your browser with nothing to install, right here on this page.

Make it your own

  1. Add a "lowest price ever" flag when the deal beats every week in the history.
  2. Rank all the deals from best real saving to worst.
  3. Work out how much you would actually save on a whole basket.

Skills: dictionaries, tuples, min and sum, f-strings

Start the free lessons More video projects