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.

 

The image depicts a Python script for creating and displaying a standard deck of playing cards, including their suits and values. Below is a transcription of the code, along with an explanation:

```python
dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A']
dCardValues = ['2','3','4','5','6','7','8','9','10','10','10','10','11']
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:
    aCards[0][i] = dCardNames[i]
    aCards[0][i + 13] = dCardNames[i]
    aCards[0][i + 26] = dCardNames[i]
    aCards[0][i + 39] = dCardNames[i]

    aCards[1][i] = dSuits[0]
    aCards[1][i + 13] = dSuits[1]
    aCards[1][i + 26] = dSuits[2]
    aCards[1][i + 39] = dSuits[3]
    
    aCards[2][i] = dCardValues[i]
    aCards[2][i + 13] = dCardValues[i]
    aCards[2][i + 26] = dCardValues[i]
    aCards[2][i + 39] = dCardValues[i]

    i = i + 1

i = 0 
while i < 52:
    print(aCards[0][i], " ", aCards[1][i], " ", aCards[2][i])
    i = i + 1
```

### Explanation:

1. **Variable Initialization**:
   - `dCardNames`: A list of card names representing ranks from 2 to Ace.
   - `dCardValues`: A list representing numerical values for the cards. Note that face cards (J, Q, K) have a value of 10, and an Ace has a value of 11.
   - `dS
Transcribed Image Text:The image depicts a Python script for creating and displaying a standard deck of playing cards, including their suits and values. Below is a transcription of the code, along with an explanation: ```python dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'] dCardValues = ['2','3','4','5','6','7','8','9','10','10','10','10','11'] 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: aCards[0][i] = dCardNames[i] aCards[0][i + 13] = dCardNames[i] aCards[0][i + 26] = dCardNames[i] aCards[0][i + 39] = dCardNames[i] aCards[1][i] = dSuits[0] aCards[1][i + 13] = dSuits[1] aCards[1][i + 26] = dSuits[2] aCards[1][i + 39] = dSuits[3] aCards[2][i] = dCardValues[i] aCards[2][i + 13] = dCardValues[i] aCards[2][i + 26] = dCardValues[i] aCards[2][i + 39] = dCardValues[i] i = i + 1 i = 0 while i < 52: print(aCards[0][i], " ", aCards[1][i], " ", aCards[2][i]) i = i + 1 ``` ### Explanation: 1. **Variable Initialization**: - `dCardNames`: A list of card names representing ranks from 2 to Ace. - `dCardValues`: A list representing numerical values for the cards. Note that face cards (J, Q, K) have a value of 10, and an Ace has a value of 11. - `dS
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
  • SEE MORE 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