Dice Pairs (1)

We have been throwing a pair of dice repeatedly, recording the outcome. Each die thrown shows a number between 1 and 6. Each time, we throw both dice and record their sum. We need the so-called “histogram”: for each outcome, how many times along the experiment we have obtained that outcome.

Write a program that reads the sequence of outcomes and prints out the histogram; your program should print only the nonzero entries. Follow precisely the format in the example; there should be no additional blank spaces or lines.

Additional suggestions: (a) in Python, propose first a version using a list as internal data structure; then, move on to a version using a dict; (b) once your program works, and fully outside the jutge, find out how to depict the histograms visually using @matplotlib@. You may try asking your instructor for an example of the desired figure.

Problem information

Author: José Luis Balcázar

Generation: 2026-01-25T13:33:15.710Z

© Jutge.org, 2006–2026.
https://jutge.org