Python Forum
Some exercises I need help with.
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some exercises I need help with.
#3
The second code sets up a dictionary of the sides of the die and the counts: {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0}. So ROLLED[5] is the number of times a five has been rolled. The loop on line 13 rolls the die ITERATIONS times (however many times you want it to) and records the results of each roll. The probability function just prints the results.

You can do this with a list as well as a dictionary. ROLLED = [0] * 7 would work just as well, although you would have to rewrite the probability function.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Some exercises I need help with. - by Larz60+ - Dec-02-2018, 04:01 PM
RE: Some exercises I need help with. - by ichabod801 - Dec-02-2018, 06:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mission Impossible : New to Python and 3 days to do theses exercises Kangaaxx 6 3,951 Aug-16-2018, 05:58 PM
Last Post: Kangaaxx
  3 Finance Python Exercises mmkthen 2 5,559 Oct-29-2017, 02:55 PM
Last Post: sparkz_alot
  One of my exercises is breaking my balls. Jei 14 14,192 Dec-03-2016, 03:35 PM
Last Post: Jei

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020