Skip to content

Latest commit

 

History

History
300 lines (222 loc) · 9.23 KB

File metadata and controls

300 lines (222 loc) · 9.23 KB

Python

for learning(s) core Python from 2.7 to 3.x (mostly 3.x)

Python 3.x intro to Data Science

Motivation to learn Python 3x from textbook

and to learn it well

```code block

""" code block 88.A """

#code block

Programming in Python

Python Fluency

import collections

Card = collections.namedtuple('Card', ['rank', 'suit'])

class FrenchDeck:
    ranks = [str(n) for n in range(2, 11)] + list('JQKA')
    suits = 'spades diamonds hearts clubs'.split()

    def __init__(self):
        self._cards = [Card(rank, suit) for suit in self.suits
        for rank in self.ranks]

    def __len__(self):
        return len(self.__cards)

    def __getitem__(self, position):
        return self.__cards[position]