PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Input the number of times you want to shuffle the deck and then check out the results!
#Note: if the text gets mixed up change this row LENGTH constant.
LENGTH = 11
#Written by Jordan Monk in Python with an iPhone 6s Plus: A playing card simulator in text mode. Please give me your feedback as I am fairly new to Python and SoloLearn. The card and deckOfCards classes can be used to write a card game. I'm sure there are many other ways to do this so please let me know what you think. Thanks.
import random
class card():
def __init__(self, suit, name):
self.suit = suit
self.suitChrImg = " " + suit[0]
self.name = name
if name == "10":
self.nameChrImg = name
else:
self.nameChrImg = name[0] + " "
#the following builds the text based image for each card dividing them into 4 lines of text stored in a list. I stored it this way so the cards could be easily placed next to each other. There are more concise ways to program this but I chose to do it this way for the sake of readability.
self.stringImg = ["","","",""]
self.stringImg[0] += " "
self.stringImg[0] += "_"
self.stringImg[0] += "_"
self.stringImg[0] += " "
self.stringImg[1] += "|"
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run