Problem

Find out the Net Promoter Score of this company


  1. import numpy as np
  2. url = "https://raw.githubusercontent.com/hamzamohdzubair/small-data/refs/heads/main/nps.txt"
  3. data = np.loadtxt(url)

Solution

  1. total = data.shape[0]
  2. detractors = data[data<7].shape[0]
  3. promoters = data[data>8].shape[0]
  4. perc_promoters = (promoters/total)*100
  5. perc_detractors = (detractors/total)*100
  6. nps = perc_promoters - perc_detractors

Google tag (gtag.js)