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
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 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
for number in range (1, 101): | |
if number % 3 == 0 and number % 5 == 0: | |
print ('CracklePop') | |
elif number % 3 == 0: | |
print ('Crackle') | |
elif number % 5 == 0: | |
print ('Pop') | |
else: | |
print (number) |
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
def spy_coder(input): | |
encode = '' | |
decode = '' | |
result_input = input.split() | |
del result_input[0] | |
result_input = " ".join(result_input) | |
if 'encode' in input: | |
print 'encoding...' | |
for letter in result_input: | |
if letter == 't': |
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
def market_analyze(price_arr): | |
min = price_arr[0] | |
max = price_arr[0] | |
for num in price_arr: | |
if num < min: | |
min = num | |
print min | |
for num in price_arr: | |
if num > max: | |
max = num |
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
def is_prime(number): | |
if number <=1: | |
return False | |
else: | |
for num in range(2, number): | |
if (number % num == 0) and (number != num): | |
return False | |
return True | |
def prime_finder(num): |
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 Calculator(object): | |
def __init__(self): | |
self.cache = {} | |
def add(self, x, y): | |
if not self.cache.has_key('add'): | |
self.cache.setdefault('add', []) | |
for previous_x, previous_y, res in self.cache['add']: | |
if previous_x == x and previous_y == y: | |
return res |
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
def create_bookstore(name): | |
authors = [] | |
books = [] | |
bookstore = {'name': name, 'authors': authors, 'books' : books} | |
return bookstore | |
def add_author(bookstore, name, nationality): | |
ID = name[:3] + nationality | |
author = {'name': name, 'nationality': nationality, 'id': ID} |
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
def fahrenheit_to_Celsius(): | |
fahrenheit = float(input('Please enter the temperature in Fahrenheit: ')) | |
celsius = (5/9.0) * (fahrenheit - 32) | |
print('{:.2} degrees Fahrenheit is {:.2} degrees Celsius.'.format(str(fahrenheit), str(celsius))) | |
def celsius_to_Fahrenheit(): | |
celsius = float(input('Please enter the temperature in Celsius: ')) | |
fahrenheit = 32 + (celsius * (9/5.0)) | |
print('{:.2} degrees Celsius is {:.2} degrees Fahrenheit.'.format(str(celsius), str(fahrenheit))) |
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
def longest_key(a_dict): | |
if a_dict == {}: | |
return None | |
else: | |
longestkey = '' | |
for key in a_dict: | |
if len(key) > len(longestkey): | |
longestkey = key | |
return longestkey |
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
theBoard = {'top-L': ' ', 'top-M': ' ', 'top-R': ' ', | |
'mid-L': ' ', 'mid-M': ' ', 'mid-R': ' ', | |
'low-L': ' ', 'low-M': ' ', 'low-R': ' '} | |
def printBoard(board): | |
print(board['top-L'] + '|' + board['top-M'] + '|'+ board['top-R']) | |
print('-+-+-') | |
print(board['mid-L'] + '|' + board['mid-M'] + '|'+ board['mid-R']) | |
print('-+-+-') | |
print(board['low-L'] + '|' + board['low-M'] + '|'+ board['low-R']) |
OlderNewer