This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script> | |
<script src="sketch.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Menu: | |
# The constructor for the menu class. | |
# Define the initial values for the menu items | |
def __init__(self, name, items, start_time, end_time): | |
self.name = name | |
self.items = items | |
self.start_time = start_time | |
self.end_time = end_time | |
# Define the string representation for the menus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Circle: | |
pi = 3.14 | |
def __init__(self, diameter): | |
self.radius = diameter / 2 | |
def area(self): | |
return self.pi * self.radius ** 2 | |
def circumference(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
total_price = 0 | |
for price in prices: | |
total_price += price |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms'] | |
prices = [2, 6, 1, 3, 2, 7, 2] | |
num_pizzas = len(toppings) | |
print("We sell " + str(num_pizzas) + " different kinds of pizza!") | |
pizzas = list(zip(prices, toppings)) | |
print(pizzas) | |
pizzas.sort() | |
cheapest_pizza = pizzas[0] | |
priciest_pizza = pizzas[-1] | |
three_cheapest = pizzas[:3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letters = ["A", "B", "c", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] | |
points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] | |
letter_to_points = {key.upper():value for key, value in zip(letters,points)} | |
letter_to_points[" "] = 0 | |
print(letter_to_points) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "So Paulo, Brazil", "Cairo, Egypt"] | |
test_traveler = ['Erin Wilkes', 'Shanghai, China', ['historical site', 'art']] | |
def get_destination_index(destination): | |
""" | |
destination_index = -1 | |
for i in range(len(destinations)): | |
if destination == destinations[i]: | |
return i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daily_sales = \ | |
"""Edith Mcbride ;,;$1.21 ;,; white ;,; | |
09/15/17 ,Herbert Tran ;,; $7.29;,; | |
white&blue;,; 09/15/17 ,Paul Clarke ;,;$12.52 | |
;,; white&blue ;,; 09/15/17 ,Lucille Caldwell | |
;,; $5.13 ;,; white ;,; 09/15/17, | |
Eduardo George ;,;$20.39;,; white&yellow | |
;,;09/15/17 , Danny Mclaughlin;,;$30.82;,; | |
purple ;,;09/15/17 ,Stacy Vargas;,; $1.85 ;,; | |
purple&yellow ;,;09/15/17, Shaun Brock;,; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set human age | |
const myAge = 41; | |
// Set early years | |
let earlyYears = 2; | |
// Multiply the early years by 10.5 | |
earlyYears *= 10.5; | |
// Subtract 2 from current age since the age for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the initial value of kelvin and | |
// set to 293 degrees kelvin | |
const kelvin = 293; | |
// convert degrees kelvin to degrees celcius by subtracting 273 | |
const celsius = kelvin - 273; | |
// Convert to degrees fahrenheit and round down | |
let fahrenheit = Math.floor(celsius * (9/5) + 32); | |
console.log(`The temperature ${kelvin} is ${fahrenheit} degrees Fahrenheit.`); |
NewerOlder