Quotes help make search much faster. Example: "Practice Makes Perfect"

Sunday, September 1, 2019

Codecademy Learn Statistics With Python Quantiles Exercise 3/5


# Sample Solution
from song_data import songs
import numpy as np

# Define quartiles, deciles, and tenth here:
quartiles = np.quantile(songs, [0.25, 0.50, 0.75])
cut_offs = []
for i in range (1,10):
  cut_offs.append(i/10)
print(cut_offs) 
deciles = np.quantile(songs, cut_offs)
song_length = 170
print("Song length is equal to " + str(song_length))
for i in range (1,10):
  if(song_length < deciles[i-1]):
    tenth = i
    break
  else:
    tenth = 10
print("Tenth is equal to " + str(tenth))   
#Ignore the code below here:
try:
  print("The quariles are " + str(quartiles) + "\n")
except NameError:
  print("You haven't defined quartiles.\n")
try:
  print("The deciles are " + str(deciles) + "\n")
except NameError:
  print("You haven't defined deciles.\n")

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts