Card Deck Class with Python

Card Deck Class using Python




This surprisingly short code will output the entire deck of playing cards with value and suite.

*Featured Code Submitted and Created by 

VENOM666


Python


# Card deck class implementation
# by: VENOM666

class Card:
 
    # List comprehension for card ranks (numbers) then add another list for high ranks
    rank = [i for i in range(2,11)] + ["King", "Queen", "Jack", "Ace"]
    suite = ["Hearts", "Diamonds", "Spades", "Clubs"]
    deck = []

    def __init__(self):
        self.deck = [str(i) + " of " + s for i in self.rank for s in self.suite]

    def deal(self):
        for cards in self.deck:
            print(cards)


c = Card()
c.deal()


Click here to run this Code



Share with Friends






More Free Code Examples:



Vigenere Cipher


Python Code to Convert Years to Days




Try these Fun Games by Bobbie:


Travel Blast Game New York


Travel Blast Paris


Battlestarship Game





Take a look at these Groovy Codes:


Hacker Terminal


Html Svg Starburst


Javascript Particles Fishes



Read the Latest Breaking Programming and Tech News, Great Articles and Tips:


Codenewz Programming and Tech News




Comments

Popular posts from this blog

Multi-tap Keypad Text Entry

Crypto Mining