File Edit Format Run Options Window Help dCardNames dCardValues ['2', '3', '4', '5', '6', = ['2', '3', '4', '5', '6' dSuits = ["Clubs", "Spades", "Diamonds", "Hearts"] # Build a two dimensional deck with Cards suits and values. aCards = [[¹' for i in range (52)] for j in range (3)] i = 0 n = 0 while i < 13: i = 0 while aCards [0] [i] aCards [0] [i+13] aCards [0] [i + 26] aCards [0] [i + 39] = dCardNames[i] i=i+1 aCards [1] [i] = dSuits [0] aCards [1] [i+13] aCards [1] [i+26] = dSuits [2] aCards [1] [i + 39] aCards [2] [i] aCards [2] [i+13] = = dSuits [3] dCardValues [i] dCardNames[i] dCardNames [i] dCardNames[i] dSuits [1] i < 52: print (aCards [0] [i], i = i + 1 '9', '10', 'J', 'Q','K','A'] '8', '9', '10', '10', '10', '10', '11'] " aCards [2] [i+26] =dCardValues[i] aCards [2] [i + 39] = dCardValues[i] dCardValues[i] " aCards [1] [i], " aCards [2] [i])

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In the attached Python code, use the array built to shuffle and deal two poker hands.  Change the corresponding values for all Jacks through Aces to 11, 12, 13, 14 respectively.  

Shuffle the deck, then deal two hands. Comment (explain) your code.

 

ShuffleCards-1.py
File Edit Format Run Options Window Help
dCardNames = [¹2¹, ¹3¹, ¹4¹, ¹5¹, ¹6¹, 7¹ 8¹ '9', '10', 'J', 'Q', 'K', 'A']
['2', '3', '4', '5', '6', '7', '8', '9', '10', '10', '10', '10', '11']
dSuits = ["Clubs", "Spades", "Diamonds", "Hearts"]
dCardValues
#Build a two dimensional deck with Cards suits and values.
for i in range (52)] for j in range (3)]
aCards = [[¹
i = 0
n = 0
while i < 13:
=
- C:\Users\Justin\Downloads\ShuffleCards-1.py (3.10.7)
aCards [0] [i] = dCardNames [i]
aCards [0] [1 + 13] dCardNames [i]
aCards [0] [i + 26]
aCards [0] [139]
i=i+1
i = 0
while i < 52:
=
=
=
aCards [1] [i] = dSuits [0]
aCards [1] [i+13] = dSuits [1]
aCards [1] [i + 26]
dSuits [2]
dSuits [3]
aCards [1] [i + 39]
aCards [2] [1]
dCardValues[i]
aCards [2] [i+13] = dCardValues[i]
aCards [2] [i + 26] = dCardValues [i]
aCards [2] [i + 39]
dCardValues[i]
=
=
=
dCardNames [i]
dCardNames [i]
print (aCards [0] [i],
i = i + 1
aCards [1] [i], ", aCards [2] [i])
X
Ln: 31 Col: 0
Transcribed Image Text:ShuffleCards-1.py File Edit Format Run Options Window Help dCardNames = [¹2¹, ¹3¹, ¹4¹, ¹5¹, ¹6¹, 7¹ 8¹ '9', '10', 'J', 'Q', 'K', 'A'] ['2', '3', '4', '5', '6', '7', '8', '9', '10', '10', '10', '10', '11'] dSuits = ["Clubs", "Spades", "Diamonds", "Hearts"] dCardValues #Build a two dimensional deck with Cards suits and values. for i in range (52)] for j in range (3)] aCards = [[¹ i = 0 n = 0 while i < 13: = - C:\Users\Justin\Downloads\ShuffleCards-1.py (3.10.7) aCards [0] [i] = dCardNames [i] aCards [0] [1 + 13] dCardNames [i] aCards [0] [i + 26] aCards [0] [139] i=i+1 i = 0 while i < 52: = = = aCards [1] [i] = dSuits [0] aCards [1] [i+13] = dSuits [1] aCards [1] [i + 26] dSuits [2] dSuits [3] aCards [1] [i + 39] aCards [2] [1] dCardValues[i] aCards [2] [i+13] = dCardValues[i] aCards [2] [i + 26] = dCardValues [i] aCards [2] [i + 39] dCardValues[i] = = = dCardNames [i] dCardNames [i] print (aCards [0] [i], i = i + 1 aCards [1] [i], ", aCards [2] [i]) X Ln: 31 Col: 0
Expert Solution
steps

Step by step

Solved in 8 steps with 6 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education