Browsed by
Author: yreece

Codecademy Python Course Update 4

Codecademy Python Course Update 4

In this guided project, I implemented functions to do physics calculations: converting temperatures, calculating force, energy, and work.

train_mass = 22680
train_acceleration = 10
train_distance = 100
bomb_mass = 1

# function to convert fahrenheit to celsius 
def f_to_c(f_temp):
  c_temp = (f_temp - 32) * 5/9
  return c_temp

#testing the f_to_c function
f100_in_celsius = f_to_c(100)
print(f100_in_celsius)

# function to convert celsius to fahrenheit
def c_to_f(c_temp):
  f_temp = (c_temp * 9/5) + 32
  return f_temp

#testing the c_to_f function
c0_in_fahrenheit = c_to_f(0)
print(c0_in_fahrenheit)

# function to calculate force using mass and acceleration
def get_force(mass, acceleration):
  return mass * acceleration

# Calculate the force exerted by the GE train
train_force = get_force(train_mass, train_acceleration)
print(train_force)
print("The GE train supplies", train_force, " Newtons of force.")

# function to calculate energy using mass and c constant
def get_energy(mass, c = 3*10**8):
  return mass * c**2

# calculating the energy produced by a  1kg bomb
bomb_energy = get_energy(bomb_mass)
print(bomb_energy)
print("A 1kg bomb supplies", bomb_energy, " Joules.")

# function to calculate work using mass, acceleration and distance
def get_work(mass, acceleration, distance):
  return (get_force(mass, acceleration)) * distance

# calculating the work exerted by a train
train_work = (get_work(train_mass, train_acceleration, train_distance))
print("The GE train does", train_work, "Joules of work over", train_distance, "meters.")

CodeCademy Python Course Update 3

CodeCademy Python Course Update 3

In this guided project, I analyzed data for a hair salon.

hairstyles = ["bouffant", "pixie", "dreadlocks", "crew", "bowl", "bob", "mohawk", "flattop"]

prices = [30, 25, 40, 20, 20, 35, 50, 35]

last_week = [2, 3, 5, 8, 4, 4, 6, 2]

# Calculate total price of all haircuts
total_price = 0
for price in prices:
  total_price += price

# Calculate average price of a haircut
average_price = (total_price / len(prices))
print("Average Haircut Price:", average_price)

# Reduce each price by $5
new_prices = [price - 5 for price in prices]
print("New Prices", new_prices)

# Calculate total weekly and daily revenue
total_revenue = 0
for i in range(len(hairstyles)):
  total_revenue += (prices[i] * last_week[i])
print("Total Revenue", total_revenue)
print("Average Daily Revenue", (total_revenue / 7))

# Find haircuts under 30
cuts_under_30 = [hairstyles[i] for i in range(len(hairstyles)) if new_prices[i] < 30]
print("Haircuts Under $30", cuts_under_30)


CodeCademy Python Course Update 2

CodeCademy Python Course Update 2

I am learning about lists in Python, and this code I wrote for my latest project in the course I’m taking.

toppings = ["pepperoni", "pineapple", "cheese", "sausage", "olives", "anchovies", "mushrooms"]

prices = [2, 6, 1, 3, 2, 7, 2]

#find out how many $2 slices we have
num_two_dollar_slices = prices.count(2)
#print(num_two_dollar_slices)

#how many kinds of pizza do we have?
num_pizzas = len(toppings)
#print("we sell", num_pizzas, "different kinds of pizza!")

#two dimensional list of pizzas and prices
pizza_and_prices = [[2, "pepperoni"], [6, "pineapple"], [1, "cheese"], [3, "sausage"], [2, "olives"], [7, "anchovies"], [2, "mushrooms"]]
#print(pizza_and_prices)

#sort the pizzas in order of ascending price
pizza_and_prices = sorted(pizza_and_prices)
#print(pizza_and_prices)

#store the cheapest pizza
cheapest_pizza = pizza_and_prices[0]
#print(cheapest_pizza)

#store the most expensive pizza
priciest_pizza = pizza_and_prices[-1]
#print(priciest_pizza)

#remove a slice from list
pizza_and_prices.pop(-1)
#print(pizza_and_prices)

#add a slice to the list
pizza_and_prices.insert(4, [2.5, "peppers"])
#print(pizza_and_prices)

#slice the three lowest-price pizzas
three_cheapest = pizza_and_prices[:3]
print(three_cheapest)
CodeCademy Python Course Update 1

CodeCademy Python Course Update 1

last_semester_gradebook = [["politics", 80], ["latin", 96], ["dance", 97], ["architecture", 65]]

# Your code below: 
subjects = ["physics", "calculus", "poetry", "history"]

grades = [98, 97, 85, 88]

gradebook = [["physics", 98], ["calculus", 97], ["poetry", 85], ["history", 88]]

#print(gradebook)

gradebook.append(["computer science", 100])
gradebook.append(["visual arts", 93])

#modify the visual arts grade +5
#print(gradebook[-1][-1])
gradebook[-1][-1] = 98
#print(gradebook[-1][-1])

#changing poetry to a pass/fail class
#print(gradebook)
gradebook[2].remove(85)
#print(gradebook)
gradebook[2].append("pass")
#print(gradebook)

full_gradebook = [[last_semester_gradebook]+[gradebook]]

print(full_gradebook)


Planting layout for a desert flower and cactus farm in Central New Mexico

Planting layout for a desert flower and cactus farm in Central New Mexico

Description: A planting layout for a sustainable agriculture model inspired by the environmental conditions of Central New Mexico. Design priorities are drought tolerance, commercial yield and ecological design. The row sequence is A-B-C-B-A where row A is honey mesquite with four-wing saltbush, row B is prickly pear cactus and row C is desert wildflowers. The rows are parallel to the general direction of the contour.