In: Computer Science
write the PsuedoCode and the flow chart of the following:
1. draw a deck of cards from a standard deck of 52 cards until the queen of hearts is draw. how many cards did you draw?
Please find the below mentioned solutions:
SOURCE CODE:
*Please follow the comments to better understand the code.
**Please look at the Screenshot below and use this code to copy-paste.
***The code in the below screenshot is neatly indented for better understanding.
import random
import itertools
# 1. Prepare a deck of cards
types = ['Spade','Heart','Diamond','Club']
deck = []
for i in range(1,14):
for type in types:
deck.append(str(i)+'-'+type)
# 2. shuffle the cards
random.shuffle(deck)
print('The Shuffled Deck is: ',deck)
#3. Queen of hearts is : '12-Heart'
queen_of_heart = '12-Heart'
count = 0
# 4. Loop till queen_of_heart is obtained
while deck.pop(0)!=queen_of_heart:
count+=1
# 5. Print the count
print('It took - ',count,'cards to get Queen Of Heart..!!')
RUN-1
RUN-2