This file contains hidden or 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
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) |
This file contains hidden or 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
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: |
This file contains hidden or 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
def censor(text,word): | |
text = str(text) | |
word = str(word) | |
new_stars = "*" * len(word) | |
text = text.replace(word,new_stars) | |
return text |
This file contains hidden or 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
def count(sequence,item): | |
total = 0 | |
for i in sequence: | |
if i == item: | |
total += 1 | |
return total |
This file contains hidden or 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
def purify(numbers): | |
lst = [] | |
for number in numbers: | |
if number % 2 == 0: | |
lst.append(number) | |
return lst |
This file contains hidden or 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
def product(yum): | |
total = 1 | |
for num in yum: | |
total *= num | |
return total |
This file contains hidden or 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
def remove_duplicates(cats): | |
dogs = [] | |
for dups in cats: | |
if dups not in dogs: | |
dogs.append(dups) | |
return dogs |
This file contains hidden or 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
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] |
This file contains hidden or 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 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! |
This file contains hidden or 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
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], |
OlderNewer