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
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], |
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
#!/usr/local/bin/python3.3 | |
import random | |
grep_a = {} | |
grep_b = {} | |
grep_c = {} | |
offspring = {} | |
dom_colors = 'red yellow green blue orange white brown black violet'.split() | |
rec_colors = 'indigo pink magenta khaki crimson gray turquoise gold silver'.split() | |
parts = 'eyes fur ears tail claws paws whiskers crest'.split() | |
dom_fur_accents = 'stripes spots'.split() |
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
>>> spam = ['first', 'second', 'last'] | |
>>> spam | |
['first', 'second', 'last'] | |
>>> spam.sort() | |
>>> spam | |
['first', 'last', 'second'] | |
>>> spam.append(1) | |
>>> spam | |
['first', 'last', 'second', 1] | |
>>> spam.sort() |
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
#!/usr/local/bin/python3.3 | |
#Tic Tac Toe | |
import random | |
def drawBoard(board): | |
print(' | |') | |
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) | |
print(' | |') | |
print('-----------') |
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
#!/usr/local/bin/python3.3 | |
import random #this imports the random function to python | |
words = 'rock paper scissors'.split() #this creates a list from the variable words for the computer to choose from. | |
names = 'Bill Alexis Thatcher Eric Jack Henry'.split() #this creates a list from the variable names for the computer to choose from | |
def getRPS(choice): #this defines a new function called getRPS with the parameter choice | |
choiceIndex = random.randint(0, len(choice) -1) #this picks a number at random from 0 to the number of words in the words list | |
return choice[choiceIndex] #this takes the random number from choiceIndex and places it in the square bracket so if choiceIndex were 0 it would return choice[0] which would become...rock, since rock is the first word in the list created in line 3 |