Question: # CardTrick.py import random def main ( ) : # Declare variables column = 0 loopCounter = 0 # Declare the deck list deck =

# CardTrick.py
import random
def main():
# Declare variables
column =0
loopCounter =0
# Declare the deck list
deck =[0]*52
# Declare a 7 row by 3 column list
play =[[0,0,0]]*7
# Openning message
print("Welcome. I'm not the latest development in AI, but ")
print("I'm a computer program that can performa card trick.")
print("Let's begin!")
print()
print("Building the deck of cards...")
# Call BuildDeck()
print("Done!
")
seeDeck = input("Now would you like to see the deck (y/n)?")
# Call PrintDeck()
# Begin the main card trick loop
for loopCounter in range(3):
# Call Deal()
column = int(input("
Which column is your card in (0,1, or 2)?: "))
# Call PickUp()
# Call SecretCard()
SecretCard(deck)
print("Thank you for playing the card trick!")
def PrintCard(card):
rank =
suit =
if rank ==0:
cardString =" King of "
elif
if suit ==0:
cardString += "Clubs "
elif
print(cardString, end='')
def BuildDeck(deck):
# Define local variables
used =[0]*52
card =0
i =0
# Generate cards until the deck is full of integers
while i <52:
# Generate a random integer between 0 and 51
# Test to see if the value has already been used
# If not, add it to the deck
# End while loop
def PrintDeck(deck):
# Define local variables
card =0
# End for loop
def Deal(deck, play):
# Define local variables
card =0
# Deal the cards from the deck to the play list
print()
print(" Column 0 Column 1 Column 2")
print("=======================================================")
# End nested for loop structure
def PickUp(deck, play, column):
# Define local variables
card =0
row =0
# Identify the order of columns to pick up
# Now pick up cards from the play list by column and put them in deck
# End for loop structure
def SecretCard(deck):
# Define local variables
card =0
print()
print("Finding secret card...")
for card in range(0,10):
PrintCard(deck[card])
print()
print("Your secret card is: ", end='')
card +=1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!