Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Do you really want to delete this prezi?
Neither you, nor the coeditors you shared it with will be able to recover it again.
Make your likes visible on Facebook?
Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.
Exam Question - Dice Game
Transcript of Exam Question - Dice Game
The idea is that you write something that is close to the actual code you would use, but without worrying about the more technical / language specific features.
In this example, the flow-chart helps us to quickly create some pseudocode. call dice subroutine
if dice = dice = dice 
score = sum of dice values
if two are the same
score = (sum of 2 that are the same) - other value
score = 0
print dice rolls
loop 3 times, using i as counter:
dice[i] = random number (1-6) This is a very simple program. We are going to improve it a lot. First job:
Instead of using dice1, dice2 and dice3,use a list:
dice, dice, dice.
Change the roll subroutine and the display section so they use loops to set up and display the list.
Test that this is working. Now, write a function to calculate the score for that round of the game.
Test that it produces the correct result. To adapt our program to help us with this question, it would be helpful to be able to directly enter trial dice-rolls and get the score.
Can you create a menu which gives this as an option?
Check the simple menu program we did last term for tips. The questions also asks us what rolls would produce negative scores.
Can you write a function that would do this for us? https://www.dropbox.com/s/gtg2n68ji2uoxg2/dice1.sb Now, read through your code carefully.
Are there parts that basically do the same thing?
Can you create a subroutine to do these?
Remember to test your program is working after you've changed something.