Tutorial by Examples

So you've just created your first class in Python, a neat little class that encapsulates a playing card: class Card: def __init__(self, suit, pips): self.suit = suit self.pips = pips Elsewhere in your code, you create a few instances of this class: ace_of_spades = Card('S...
class Card: special_names = {1:'Ace', 11:'Jack', 12:'Queen', 13:'King'} def __init__(self, suit, pips): self.suit = suit self.pips = pips # Called when instance is converted to a string via str() # Examples: # print(card1) # print(str(card1) ...

Page 1 of 1