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
loopCounter
# Declare the deck list
deck
# Declare a row by column list
play
# Openning message
printWelcome Im not the latest development in AI but
printIm a computer program that can performa card trick."
printLets begin!"
print
printBuilding the deck of cards..."
# Call BuildDeck
printDone
seeDeck inputNow would you like to see the deck yn
# Call PrintDeck
# Begin the main card trick loop
for loopCounter in range:
# Call Deal
column intinput
Which column is your card in or :
# Call PickUp
# Call SecretCard
SecretCarddeck
printThank you for playing the card trick!"
def PrintCardcard:
rank
suit
if rank :
cardString King of
elif
if suit :
cardString "Clubs
elif
printcardString end
def BuildDeckdeck:
# Define local variables
used
card
i
# Generate cards until the deck is full of integers
while i :
# Generate a random integer between and
# Test to see if the value has already been used
# If not, add it to the deck
# End while loop
def PrintDeckdeck:
# Define local variables
card
# End for loop
def Dealdeck play:
# Define local variables
card
# Deal the cards from the deck to the play list
print
print Column Column Column
print
# End nested for loop structure
def PickUpdeck play, column:
# Define local variables
card
row
# 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 SecretCarddeck:
# Define local variables
card
print
printFinding secret card..."
for card in range:
PrintCarddeckcard
print
printYour secret card is: end
card
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
