Computers and Technology

There are 36 possible combinations of two dice.
A simple pair of loops over range(6)+1 will enumerate all combinations.
The sum of the two dice is more interesting than the actual combination.
Create a dict of all combinations, using the sum of the two dice as the key.

Each value in the dict should be a list of tuples; each tuple has the value of two dice.
The general outline is something like the following:

d= {}
Loop with d1 from 1 to 6
Loop with d2 from 1 to 6
newTuple ← ( d1, d2 ) # create the tuple
oldList ← dictionary entry for sum d1+d2
newList ← oldList + newTuple
replace entry in dictionary with newList

Loop over all values in the dictionary
print the key and the length of the list

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, melissalopez12
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
image
Computers and Technology, 22.06.2019 15:00, 2alshawe201
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, crimhill
When is it appropriate to use an absolute reference
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, jalaholmes2027
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
Do you know the correct answer?
There are 36 possible combinations of two dice.
A simple pair of loops over range(6)+1 will e...

Questions in other subjects:

Konu
Biology, 25.08.2019 14:30