Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 126: 4.24

Answer

code

Work Step by Step

# 4.24 (Game: pick a card ) Write a program that simulates picking a card from a deck of # 52 cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, # Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card. import random shape = random.randint(1, 4) if shape == 1: shape = "Clubs" elif shape == 2: shape = "Diamonds" elif shape == 3: shape = "Hearts" elif shape == 4: shape = "Spades" rank = random.randint(1, 13) if rank == 1: rank = "Ace" elif rank == 11: rank = "Jack" elif rank == 12: rank = "Queen" elif rank == 13: rank = "King" print("The card you picked is the", rank, "of", shape)
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.