Skip to content

fastai/cards_deck

Repository files navigation

Deck of Cards

This repo uses code based on Allen Downey’s ThinkPython2.

Install

After cloning this repository:

pip install -e .

Caution

This project is an example of how to create python packages with nbdev. It’s not a fully-fledged card dealing library!

How to use

Playing cards in python!

from cards_deck.deck import Deck
d = Deck()
print(f'Number of playing cards in the deck: {len(d)}')
Number of playing cards in the deck: 52
card = d.pop()
card, len(d)
(K♠️, 51)

See the docs for more info.

The draw_cards cli:

We included a handy cli you can use to draw cards as well!

!draw_cards -h
usage: draw_cards [-h] [--replace] [--outfile OUTFILE] n

Draw `n` cards optionally with replacement

positional arguments:
  n                  number of cards to draw

optional arguments:
  -h, --help         show this help message and exit
  --replace          whether or not draw with replacement (default: False)
  --outfile OUTFILE  output file, defaults to stdout
!draw_cards 10
5❤️
6❤️
10♠️
4♣️
A♣️
A❤️
9❤️
4❤️
K❤️
3♣️

About

A minimal example of nbdev based on Allen Downey's Think Python 2nd Ed

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 4

  •  
  •  
  •  
  •  

Languages