Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Python pls)Build a two dimensional array out of the following three lists. The

ID: 3889020 • Letter: #

Question

(Python pls)Build a two dimensional array out of the following three lists. The array will represent a deck of cards. The values in dCardValues correspond to the card names in dCardNames. Note that when you make an array all data types must be the same. Apply dSuits to dCardValues and dCardNames by assigning a suit to each set of 13 elements.

dCardNames = ['2','3','4','5','6','7','8','9','10','J','Q','K','A']

dCardValues = ['2','3','4','5','6','7','8','9','10','11','12','13','14']

dSuits = ["Clubs","Spades","Diamonds","Hearts"]

Once assigned your two dimensional array should resemble this :

2 Clubs 2
3 Clubs 3
4 Clubs 4
5 Clubs 5
6 Clubs 6
7 Clubs 7
8 Clubs 8
9 Clubs 9
10 Clubs 10
J Clubs 10
Q Clubs 10
K Clubs 10
A Clubs 11
2 Spades 2
3 Spades 3
4 Spades 4
5 Spades 5
6 Spades 6
7 Spades 7
8 Spades 8
9 Spades 9
10 Spades 10
J Spades 10
Q Spades 10
K Spades 10
A Spades 11
2 Diamonds 2
3 Diamonds 3
4 Diamonds 4
5 Diamonds 5
6 Diamonds 6
7 Diamonds 7
8 Diamonds 8
9 Diamonds 9
10 Diamonds 10
J Diamonds 10
Q Diamonds 10
K Diamonds 10
A Diamonds 11
2 Hearts 2
3 Hearts 3
4 Hearts 4
5 Hearts 5
6 Hearts 6
7 Hearts 7
8 Hearts 8
9 Hearts 9
10 Hearts 10
J Hearts 10
Q Hearts 10
K Hearts 10
A Hearts 11

Once you have this two dimensional array, you should shuffle it either by function or by code to produce a shuffled deck of cards. After that apply the three sorts (Selection, Insertion and Bubble) ,to the two dimensional array returning it to it original state as listed above. This assignment will require some problem solving ability.

Explanation / Answer

def three_dimension_add(A, B):
   C = []
   temp_1d = []
   temp_2d = []
   for i in range(len(A)):
       temp_2d = []
       for j in range(len(A[0])):
           temp_1d = []
           for k in range(len(A[0][0])):
               temp_1d.append(A[i][j][k] + B[i][j][k])
           temp_2d.append(temp_1d)
       C.append(temp_2d)
   return C
  
A = [[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]
B = [[[21, 22], [23, 24]], [[25, 26], [27, 28]], [[29, 30], [31, 32]]]
C = three_dimension_add(A, B)
print('A = ' + str(A))
print('B = ' + str(B))
print('C = ' + str(C))