1. (7 points) Write a program named dice rolling.py that allows the user to simulate rolling any number of d-sided dice.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

1. (7 points) Write a program named dice rolling.py that allows the user to simulate rolling any number of d-sided dice.

Post by answerhappygod »

1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 1
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 1 (49.71 KiB) Viewed 28 times
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 2
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 2 (54.65 KiB) Viewed 28 times
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 3
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 3 (49.34 KiB) Viewed 28 times
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 4
1 7 Points Write A Program Named Dice Rolling Py That Allows The User To Simulate Rolling Any Number Of D Sided Dice 4 (57.66 KiB) Viewed 28 times
1. (7 points) Write a program named dice rolling.py that allows the user to simulate rolling any number of d-sided dice. The user should be able to repeatedly enter 1) how many dice they want to roll, and 2) how many sides are on the dice. Each roll should show the results from the individual dice as well as the sum. The program should continue until the user enters a zero or negative value (for either input) to exit. Example program run (underlined parts indicate what the user enters) Number of dice to roll (any non-positive value to exit): 2​ Number of sides per die (any non-positive value to exit): 20 Rolling 2 d20… Die 1:1 Die 2:15 Total: 16 Number of dice to roll (any non-positive value to exit): 5 Number of sides per die (any non-positive value to exit): 6​ Rolling 5 d6... Die 1:3 Die 2:5 Die 3:2 1 This program could be quite handy if you play D&⋅D ! 1
3. (20 points) In elass, we discrased an ecample of how to comprate the growth of anoncy over time, with regular annual contributions. Let's appecosch this problem frons another anglef given your carreat finatecial situation and a retirement goal yoer have in mind, how moch should gou confribufe cach yoar to achieve that goal? To maloe this mote realistic than our in-class exauple, we'll abso allow the contrilution each year to grow exer time. People can often contribute more iss they advance in their caroer and their earnines increwer. Write a prograsu named retirement.calculator-py that starts by getting the following noc infiuts: - Current age - Target retirement ager - Current tetiremert satwíngs, in USD - Target savings at retirement, in USD - Annual growth rate, as a percesitage ("quonth" is just a mose geberal term for the "interent" idea that we covered in class) - Amount to increase the annual contritation by each year, as a percentage. We'll assame that this percentage is consistent throughout the person's entire eareer. For example, a figure of 2% might mean that the perwon contrituates $1000 the first year, $1020 (2\% more than $1000) the second year, $1040.40 (2\% mote than \$1020) the third year, and so on. Inchade insut nakidation (using a loop) on all of these to essure that the values anst be naernegative (i.e., 0 or greater). Furthermoge, include inpet valolation on the target retirement age to ensure that it cannot be less than the user's curreat age, and the target retirement savings to enstre that it cannot be lose than the rect's current savings. Based of those iaputs, the prograan should compate the minimam possible contribation the user can mabe their first year to mere their goalk. Alwo slow a table with the projected growth Page 3 of 7 COMP 1900− Summer 2022 Lab 5 Dre Wed. July 13, by 2359 CDT from the user's current age until retirement, formatted like the examples below. Monetary announts should be rounded to tao decianal places. Hints: - Start by assuming the merr contributes 90 ther first year. This will maker every other year's contribution $0 too, since any perceutage of θ ts still 0 . But the tree might already have enough saved up to meet their goaks without eontributing agything extra, so this soenario should be codsidered. - If the user can't meet their goals with $0 comtributions, increasie the first-year contrilutionon to 80.01, run the simulatiot again, and se if they end up with enough at retirzacet. If not, increase the first-year contrilyation to $0.02, and so on. Keep repeating this process untal you find that the ending balance mets of eurevis the user's goal. - This prograza should iuvolve at least ebe nested loopl Depending on the inpuats, the program may take a cotusideralile amount of time to find the solution. Example program run (underlined parts indicate what the user enters) Your current age: −9 Age muet be non-negative, try again: 25 Target retirewent age: 20
Example program run (underlined parts indicate what the user enters) Your current age: 9−9​ Age nust be non-negative, try again: 25 Target retirenent age: 20 Retirenent age muat be at least 25 , try again: 40 Current savinga (in USD): 400000 Target savings at retirenent (in uSD) =9 Anount aust be at least $400000.00, try again: 750000 Annual grouth rate (in percent): 6.5 Anount to increase annual contrabution by each year (in percent) : 2 Save $0.00 this year and increase it by 2.0% each year until retirenent. Projected growth: - Page 4 of 7 Example program run (underlined parts indicate what the user enters) Your current age: 25 Target retirenent age: 60 Current balance (in USD): 0 Target balance at retirenent (in USD) : 1500000 Annual growth rate (in percent) : Z​ Anount to increase annual contribution by each year (in percent) : 2 Save $7992.29 this year and increase it by 2.0% each year until retirenent. Projected grouth: -anawa.......
Target retirenent age: 60 Current balance (in USD): Q Target balance at retirenent (in usD): 1500000 Annual grouth rate (in percent): 7​ Amount to increase annual contribution by each year (in percent) : 2 Save $7992.29 this year and increane it by 2.08 each year until retirenent. Projected grouth:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply