From Computer Science Wiki
|
|
Line 17: |
Line 17: |
| ==[[file:homework.png]] Homework == | | ==[[file:homework.png]] Homework == |
|
| |
|
| A common mechanic in computer games is to simulate a dice roll. [http://product-images.highwire.com/2370673/gray-opaque-rpg-dice.jpg Please click here to see an image of different types of dice]. Please write a function that rolls dice for you and RETURNS the result.
| | Please work [http://computersciencewiki.org/index.php/Functions_in_Python#Expert_level_difficulty this example] |
| | |
| for example: roll_dice(d6,3) <-- would roll a six sided die 3 times and return the result
| |
| for example: roll_dice(d12,1) <-- would roll a 12 sided dice 1 and return the result
| |
| for example: roll_dice(d20,4) <-- would roll a 20 sided die 4 times and return the result.
| |
| | |
| You should model a 4 sided, 6 sided, 10 sided, 12 sided, and 20 sided die.
| |
| | |
| As extra-credit, you might want to return the result of each roll and then the final total.
| |
| for example: roll_dice(d6,3) <-- might return 6 3 1 10
| |
| | |
| | |
| </td> | | </td> |
| </tr> | | </tr> |
Latest revision as of 10:25, 21 November 2016