Hello guys, I need help! I am supposed to transform existing dice example to be a simulation for my school lecture assignment... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hello guys, I need help! I am supposed to transform existing dice example to be a simulation for my school lecture assignment...

In this simulation there is no user.A loop will iterate 1000 times and we’ wil use random module to produce two integer values between 1 & 6 for each dice at each iteration.We are supposedly store these pairs in a two dimensional data structure.This data structure will be choice of ours as list or dictionary. If we choose our lists inside the list will look like this ; [[31, 27, 23, 22, 28, 28], [33, 30, 30, 25, 45, 24], [22, 27, 35, 37, 28, 27], [31, 22, 29, 34, 34, 21], [24, 25, 19, 39, 19, 28], [27, 16, 27, 25, 34, 24]] If we prefer dictionary it is going to look something like this ; {1:{1: 35, 2: 31, 3: 37, 4: 23, 5: 21, 6: 29} 2:{1: 22, 2: 24, 3: 34, 4: 27, 5: 20, 6: 34}, 3:{1: 33, 2: 21, 3: 28, 4: 30, 5: 28, 6: 29}, 4:{1: 28, 2: 31, 3: 24, 4: 31, 5: 31, 6: 26}, 5:{1: 24, 2: 20, 3: 30, 4: 28, 5: 33, 6: 25}, 6:{1: 25, 2: 27, 3: 22, 4: 29, 5: 28, 6: 32}}

15th Dec 2018, 5:41 PM
Ezgi Sena Yılmaz
Ezgi Sena Yılmaz - avatar
3 Answers
+ 3
If the two example is added by you, then I am afraid that you have interpreted the question wrongly, Ezgi. The data to store is "these pairs", which corresponds to "two integer values between 1&6". Therefore the result should look like this [[1,5],[3,2],[5,3],... (1000 pairs)] As Diego suggested, we ruin your learning if we give you the answer directly, but I can provide you with some necessary modules you will need. 1. import random 2. use randint(1,6) so you can get 6 too. 3. Create an empty list before for loop 4. In each iteration, generate [ randomnumber, randomnumber] 5. There is a push() method to add new entry to an array. This should solve your problem, if not, let us know.
16th Dec 2018, 6:19 AM
Gordon
Gordon - avatar
+ 2
Hey there! We are always happy to help those who show their attempts.
15th Dec 2018, 7:28 PM
Diego
Diego - avatar
+ 1
Diego and Gordon thank you a lot for your cares, I will use your suggestions and see if i can manage to thanks again Gordon.
16th Dec 2018, 10:57 AM
Ezgi Sena Yılmaz
Ezgi Sena Yılmaz - avatar