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

Friday, August 30, 2019

Codecademy Learn Statistics With Python Median Exercise 2/4

# Sample Solution
import numpy as np

# Array of the first five author ages
five_author_ages = np.array([29, 49, 42, 43, 32])

# Fill in the empty array with the values sorted
sorted_author_ages = np.array([29, 32, 42, 43, 49])

# Save the median value to median_value
median_age = 42

# Print the sorted array and median value
print("The sorted array is: " + str(sorted_author_ages))
print("The median of the array is: " + str(median_age))

Codecademy Learn Statistics With Python Exercise 3/4

# Sample Solution
# Import packages
import numpy as np
import pandas as pd

# Read author data
greatest_books = pd.read_csv("top-hundred-books.csv")

# Set author ages to a NumPy array
author_ages = greatest_books['Ages']

# Use numpy to calculate the average age of the top 100 authors
average_age = np.average(author_ages)

print("The average age of the 100 greatest authors, according to a survey by Le Monde, is: " + str(average_age))

Codecademy Learn Statistics With Python Exercise 2/4

# Sample Solution
# Set total equal to the sum
total = 29 + 49 + 42 + 43

# Set mean_value equal to the mean
mean_value = total / 4

# The following code prints the total and mean
print("The sum total is equal to: " + str(total))
print("The mean value is equal to: " + str(mean_value))

Thursday, August 29, 2019

DataCamp Combining data types Sample Solution

# Update data types

year_1_str = str(year_1)

revenue_1_str = str(revenue_1)



# Create a complete sentence combining only the string data types

sentence = 'The revenue of ' + company_1 + ' in ' + year_1_str + ' was $' + revenue_1_str + ' billion.'



# Print sentence

print(sentence)

DataCamp Booleans in Python Sample Solution

# Test equality

test_company = 'apple'

print(company_1 == test_company)


# Compare revenue_1 and revenue_2

print(revenue_1 > revenue_2)

DataCamp Determining types Sample Solution

# Type of company_1

print(type(company_1))



# Type of year_1

print(type(year_1))



# Type of revenue_1

print(type(revenue_1))

DataCamp Creating variables Sample Solution

# Create company_1

company_1 = 'Apple'

print(company_1)


# Create year_1

year_1 = 2017

print(year_1)


# Create revenue_1

revenue_1 = 229.23

print(revenue_1)

This is an example of scrolling text using Javascript.

Popular Posts