Here is a link to download the code for Flappy Bird that we finished today:
Download
Friday, July 31, 2015
Introduction to Python Packet
Here is the link to a pdf of our Introduction to Python Packet, which we used throughout the week.
Link
Link
Thursday, July 30, 2015
Deck class - 7/30
Here is the code for the Deck class and Card class that we wrote today during class:
import random
class Card:
def __init__(self, card_suit, card_number):
self.suit = card_suit
self.number = card_number
class Deck:
def __init__(self):
self.deck = []
for x in range(1, 14):
self.deck.append(Card("hearts", x))
self.deck.append(Card("diamonds", x))
self.deck.append(Card("spades", x))
self.deck.append(Card("clubs", x))
self.shuffle()
def draw_card(self):
x = self.deck.pop(0)
return x
def shuffle(self):
random.shuffle(self.deck)
myDeck = Deck()
for x in myDeck.deck:
print str(x.number) + " of " + x.suit
import random
class Card:
def __init__(self, card_suit, card_number):
self.suit = card_suit
self.number = card_number
class Deck:
def __init__(self):
self.deck = []
for x in range(1, 14):
self.deck.append(Card("hearts", x))
self.deck.append(Card("diamonds", x))
self.deck.append(Card("spades", x))
self.deck.append(Card("clubs", x))
self.shuffle()
def draw_card(self):
x = self.deck.pop(0)
return x
def shuffle(self):
random.shuffle(self.deck)
myDeck = Deck()
for x in myDeck.deck:
print str(x.number) + " of " + x.suit
Sunday, July 26, 2015
Instructions For Mac OS X
Mac installation should be fairly straightforward. Python 2.7 will comes pre-installed on Mac OS X machines. If you are running Mac OS X 10.6+ (Lion, Mountain Lion, or Yosemite), use this link. Otherwise use this link. Install the pygame package that is included in the package you downloaded and you should be good to go!
Subscribe to:
Posts (Atom)