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

Sunday, September 1, 2019

Codecademy Learn Statistics With Python Interquantile Range Exercise 2/4

# Sample Solution
from song_data import songs
import numpy as np

q1 = np.quantile(songs, 0.25)
#Create the variables q3 and interquartile_range here:
q3 = np.quantile(songs, 0.75)
interquartile_range = q3 - q1

# Ignore the code below here
try:
  print("The first quartile of the dataset is " + str(q1) + "\n")
except NameError:
  print("You haven't defined q1 yet\n")
 
try:
  print("The third quartile of the dataset is " + str(q3) + "\n")
except NameError:
  print("You haven't defined q3 yet\n")
 
try:
  print("The IQR of the dataset is " + str(interquartile_range) + "\n")
except NameError:
  print("You haven't defined interquartile_range yet\n")

Codecademy Learn Statistics With Python Interquantile Range Exercise 1/4

# Sample Solution
import codecademylib3_seaborn
from song_data import songs
import matplotlib.pyplot as plt

maximum = max(songs)
minimum = min(songs)
#Create the variable song_range here:
song_range = maximum - minimum

# Ignore the code below here
plt.hist(songs, bins = 200)
plt.xlabel("Song Length (Seconds)")
plt.ylabel("Count")
plt.show()

try:
  print("The range of the dataset is " + str(song_range) + " seconds")
except NameError:
  print("You haven't defined the variable song_range yet")

Codecademy Learn Statistics With Python Quantiles Exercise 4/5

# Sample Solution
from song_data import songs
import numpy as np

# Define percentile and answer here:
percentile = np.quantile(songs, 0.32)
# 3 minutes = 180 seconds < 189.936
answer = "below"

#Ignore the code below here:
try:
  print("Your percentile is " + str(percentile) + "\n")
except NameError:
  print("You haven't defined percentile")

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")

Saturday, August 31, 2019

Codecademy Learn Statistics With Python Quantiles Exercise 2/5

# Sample Solution
from song_data import songs
import numpy as np

# Define twenty_third_percentile here:
twenty_third_percentile = np.quantile(songs,.23)

#Ignore the code below here:
try:
  print("The value that splits 23% of the data is " + str(twenty_third_percentile) + "\n")
except NameError:
  print("You haven't defined twenty_third_percentile.")

Codecademy Learn Statistics With Python Quartiles Exercise 5/6

# Sample Solution
from song_data import songs
import numpy as np

#Create the variables songs_q1, songs_q2, and songs_q3 here:
songs_q1 = np.quantile(songs, 0.25)
songs_q2 = np.quantile(songs, 0.50)
songs_q3 = np.quantile(songs, 0.75)
number_of_songs = len(songs)
print("There are " + str(number_of_songs) + " songs in this list.")
#Generate a random number to pick a favorite song
import random
random_num = random.randint(0,(number_of_songs-1))
favorite_song = songs[random_num]
print("Song length in seconds is " + str(favorite_song))
if(favorite_song < songs_q1):
  quarter = 1 
elif(favorite_song < songs_q2):
  quarter = 2
elif(favorite_song < songs_q3):
  quarter = 3
else:
  quarter = 4
print("Favorite song is in quartile " + str(quarter))
#Ignore the code below here:
try:
  print("The first quartile of dataset one is " + str(songs_q1) + " seconds")
except NameError:
  print("You haven't defined songs_q1")
try:
  print("The second quartile of dataset one is " + str(songs_q2)+ " seconds")
except NameError:
  print("You haven't defined songs_q2")
try:
  print("The third quartile of dataset one is " + str(songs_q3)+ " seconds")
except NameError:
  print("You haven't defined songs_q3\n")

Codecademy Learn Statistics With Python Quartiles Exercise 4/6

# Sample Solution
dataset_one = [50, 10, 4, -3, 4, -20, 2]
#Sorted dataset_one: [-20, -3, 2, 4, 4, 10, 50]

dataset_two = [24, 20, 1, 45, -15, 40]
#Sorted dataset_two: [-15, 1, 20, 24, 40, 45]

dataset_one_q2 = 4
dataset_two_q2 = 22
#Define the first and third quartile of both datasets here:
dataset_one_q1 = -0.5
dataset_one_q3 = 7
dataset_two_q1 = 1
dataset_two_q3 = 40


#Ignore the code below here:
try:
  print("The first quartile of dataset one is " + str(dataset_one_q1))
except NameError:
  print("You haven't defined dataset_one_q1")
try:
  print("The second quartile of dataset one is " + str(dataset_one_q2))
except NameError:
  print("You haven't defined dataset_one_q2")
try:
  print("The third quartile of dataset one is " + str(dataset_one_q3) + "\n")
except NameError:
  print("You haven't defined dataset_one_q3\n")
try:
  print("The first quartile of dataset two is " + str(dataset_two_q1))
except NameError:
  print("You haven't defined dataset_two_q1")
try:
  print("The second quartile of dataset two is " + str(dataset_two_q2))
except NameError:
  print("You haven't defined dataset_two_q2")
try:
  print("The third quartile of dataset two is " + str(dataset_two_q3))
except NameError:
  print("You haven't defined dataset_two_q3")

This is an example of scrolling text using Javascript.

Popular Posts