Git Product home page Git Product logo

cards's Introduction

PyCards

A python module to easily create and use a deck of cards.

#What it does#

This python module creates and easy way to implement a standard 52 deck of cards into your python program to use. You can use the python class files individually or you can just download and use the module provided by placing it in your program directory.

Eventually, I may add more to this module such as a hand of cards and more error detection.

#Usage#

If you are using the individual files in your project:

from card import Card # To import and use a playing card
from deck import Deck # To import and use a deck of cards

If you are using the PyCard module:

>>> from PyCard import * # To import and use the entire PyCard module

To create a standard 52 deck of cards unshuffled:

>>> deck = Deck() # creates and unshuffled deck of cards

To put all cards back in the deck and shuffle:

>>> deck.shuffle() # shuffles the deck of cards

To deal a single card from the deck:

>>> hand1.append(deck.dealCard()) # Deals a single card from the deck to a hand

>>> kitty.append(deck.dealCard()) # Deals a single card to a throwaway pile

To print out a card:

>>> print card # Prints the rank and suit of a single playing card

>>> # The following prints out a hand of cards
>>> output = "Cards in hand: "
>>> for card in hand:
>>>   output += str(card) + " "
>>> print output

To print out the entire deck:

>>> print deck # Prints out every card in the deck

#Demos#

The repository holds a demo, which is published on the github project page: Demo

cards's People

Contributors

chippers255 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.