Question: import randomdef main ( ) : # Declare variables column = 0 loopCounter = 0 # Declare the deck list deck = [ 0 ]
import randomdef main: # Declare variables column loopCounter # Declare the deck list deck # Declare a row by column list play for in range # Opening message printWelcome Im not the latest development in AI but printIm a computer program that can perform a card trick." printLets begin!" print printBuilding the deck of cards..." # Call BuildDeck BuildDeckdeck printDone
seeDeck inputNow would you like to see the deck yn if seeDeck.lowery: PrintDeckdeck # Begin the main card trick loop for loopCounter in range: # Call Deal Dealdeck play column intinput
Which column is your card in or : # Call PickUp PickUpdeck play, column # Call SecretCard SecretCarddeck printThank you for playing the card trick!"def BuildDeckdeck: # Generate a shuffled deck of cards deck: random.samplerangedef PrintDeckdeck: for card in deck: PrintCardcard printdef Dealdeck play: # Deal the cards from the deck to the play list print print Column Column Column print for row in range: for col in range: playrowcol deckrow col PrintCardplayrowcol printdef PickUpdeck play, column: # Pick up cards from the play list by column and put them in deck order order.removecolumn order.insert column index for col in order: for row in range: deckindex playrowcol index def SecretCarddeck: print printFinding secret card..." for card in range: PrintCarddeckcard print printYour secret card is: end PrintCarddeck printdef PrintCardcard: # Convert card number to rank and suit ranks Ace "Jack", "Queen", "King" suits Clubs "Diamonds", "Hearts", "Spades" rank card suit card cardString franksrank of suitssuit printcardString endif namemain: main
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
