Instantly share code, notes, and snippets.

View Basta Fazoolin'
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
View Area of a circle - Python
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):
View script.py
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
View script.py
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]
View scrabble.py
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)
View script.py
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
View script.py
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;,;
View app.js
// 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
View app.js
// 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.`);
View script.py
train_mass = 22680
train_acceleration = 10
train_distance = 100
bomb_mass = 1
def f_to_c(f_temp):
c_temp = (f_temp - 32) * 5/9
return c_temp
f100_in_celsius = f_to_c(100)