Skip to content

Instantly share code, notes, and snippets.

@utinajerolps
utinajerolps / student_tech.py
Created September 19, 2014 17:08
student_tech.py
lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
class Employee(object):
"""Models real-life employees!"""
def __init__(self, employee_name):
self.employee_name = employee_name
def calculate_wage(self, hours):
self.hours = hours
return hours * 20.00
# Add your code below!
def median(yum):
sort_yum = sorted(yum)
len_yum = len(sort_yum)
med = 0
if len_yum % 2 == 0:
med = (sort_yum[len_yum/2] + sort_yum[len_yum/2 - 1]) / 2.0
elif len_yum == 1:
med = sort_yum[len_yum - 1]
else:
med = sort_yum[len_yum/2]
def remove_duplicates(cats):
dogs = []
for dups in cats:
if dups not in dogs:
dogs.append(dups)
return dogs
def product(yum):
total = 1
for num in yum:
total *= num
return total
def purify(numbers):
lst = []
for number in numbers:
if number % 2 == 0:
lst.append(number)
return lst
def count(sequence,item):
total = 0
for i in sequence:
if i == item:
total += 1
return total
def censor(text,word):
text = str(text)
word = str(word)
new_stars = "*" * len(word)
text = text.replace(word,new_stars)
return text
@utinajerolps
utinajerolps / scrabble_score.py
Created September 11, 2014 20:33
scrabble_score
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
"x": 8, "z": 10}
def scrabble_score(word):
word = str(word).lower()
total = 0
for letters in word:
from random import randint
board = []
for x in range(5):
board.append(["O"] * 5)
def print_board(board):
for row in board:
print " ".join(row)