COMP 1039
Problem Solving and Programming
Programming Assignment 1 (202002) Petals Around The Rose
Prepared by Joanne Zucco
SAIBT Modifications Andreas Jordan/Jane Emmett
July 2020
PSP Programming Assignment 1 – 202002
Page 1 of 23
INTRODUCTION
This document describes the first assignment for Problem Solving and Programming.
The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course by applying your knowledge and skills to the implementation of a game/puzzle called Petals Around The Rose and a simple encryption technique.
This assignment is an individual task that will require an individual submission. You will be required to submit your work via Moodle before the start of your second class (in week 8). You will also be required to present your work to your practical supervisor during your practical session held in week 8 of the studyperiod.
Important:
You must attend the practical session that you have been attending all study period in order to have your assignment marked.
This document is a kind of specification of the required end product that will be generated by implementing the assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts. Please make sure you seek clarification if you are not clear on any aspect of this assignment.
ASSIGNMENT OVERVIEW
There are two parts to this assignment:
Petals Around The Rose
You are required to write a Python program that allows a user to play a game called Petals Around The Rose. The program allows the user to repeatedly guess the answer to the puzzle until the user chooses to stop guessing/play- ing. Once the user chooses to stop guessing, the program will report the user’s and game play statistics to the screen.
You may like to play a web version of the game: http://www.borrett.id.au/computing/petals-j.htm.
PSP Programming Assignment 1 – 202002
Page 2 of 23
ASSIGNMENT 1 SPECIFICATION – PETALS AROUND THE ROSE
You are required to write a Python program called YourSaibtId_petals.py that allows a user to play a game called Petals Around The Rose.
Petals Around The Rose
You are required to write a Python program that allows a player to play a game of Petals Around The Rose. The program allows the user to repeatedly guess the answer to the puzzle until the user chooses to stop guessing/playing. Once the user chooses to stop guessing, the program will report the game statistics to the screen. You may also like to read Bill Gates and Petals Around The Rose: http://www.borrett.id.au/computing/petals-bg.htm. We will be adhering to the following ’Petals Around The Rose’ rules and game play for theassignment.
Petals Around The Rose Game Play and Rules:
The name of the game is Petals Around The Rose and the name of the game is important. The computer will roll five dice and ask the user to guess the score for the roll. The score will always be an even number (including zero). The user’s mission is to work out how the computer calculates the score in order to become a Potentate of the Rose.
• To begin a menu is displayed giving the user options
Welcome to ‘Petals Around The Rose’
*** Menu ***
1. Instructions
1. Play
2. Solution
3. Quit
Enter an option (1, 2, 3 or 4):
• If the user selects 1. the following instructions are displayed to the screen again followed by the menu
Petals Around The Rose
———————-
The name of the game is ‘Petals Around The Rose’. The name of the game is important. The computer will roll five dice and ask you to guess the score for the roll. The score will always be zero or an even number. Your mission, should you choose to accept it, is to work out how the computer calculates the score. If you succeed in working out the secret and guess correctly four times in a row, you become a Potentate of the Rose.
• If the user enters ‘4’, the following message is displayed to the screen only: Have a nice day… Remember to smell the roses.
• If the user enters ‘2’, game play begins as described on the next page
• If the user enters ‘3’, game play begins as described on the next page
It will display the solution as described in Stage 2
PSP Programming Assignment 1 – 202002
Page 3 of 23
Game Play
– The program asks the user to enter their name and displays a welcome message as below
Please enter your name: Bob
Ok Bob, let’s see if you can solve the puzzle.
– The dice face values are then displayed to the screen and the user is asked to guess the score for the roll, for example:
Die1 Die2 Die3 Die4 Die5
[4] [3] [2] [5] [6]
*** * **** **** ** * *****
Please enter your guess for the roll:
Note: The numbers in the above output will change depending on the dice values rolled.
– If the user guesses correctly, the following message is displayed: Well done! You guessed it!
– If the user does not guess correctly one of two possible messages is displayed to the screen. If the user enters an incorrect non-even number, the following message is displayed to the screen, for example:
No sorry, it’s 0 not 9. The score is always even.
If the user enters an incorrect even number, the following message is displayed to the screen, for example:
No sorry, it’s 0 not 6.
Note: The numbers in the above output will change depending on what the user has entered and the score value for the roll.
– The user is then asked whether they would like to play again with the following prompt. Game play contin- ues while the user enters ’y’ at the prompt:
Roll dice again (y|n)?
– If the user has four (4) incorrect guesses in a row the following message is displayed to the screen (once only and then the count resets back to zero):
Here is a clue: The name of the game is… Petals Around The Rose.
– If the user has four (4) correct guesses in a row, the following message is displayed to the screen (once only and then the count resets back to zero):
Congratulations! You have worked out the puzzle!
Shhh. It’s a secret.
– Game play continues until the user chooses to quit, i.e. enters ‘n’ at the following prompt: Roll dice again (y|n)?
– The solution or formula for Petals Around The Rose can be found here: https://en.wikipedia.org/wiki/Petals_Around_the_Rose.
The key to working out the answer is given by the name of the puzzle, where the “rose” is the centre dot that appears only on the 3 and 5 faces of a die, while the “petals” are the dots which surround the centre dot. Therefore, the result can be calculated by counting 2 for each 3 face and 4 for each 5 face. In the example provided above, there is one 5 face and one 3 face, so the result is four plus two, resulting in a total of six.
PSP Programming Assignment 1 – 202002
Page 4 of 23
– If the user selects ‘n’, the game summary is displayed to the screen with the users name followed by the menu, for example:
Game Summary
============
Bob played 2 games:
|–> Number of correct guesses: 1
|–> Number of incorrect guesses: 1
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4):
Note: The numbers in the above output will change depending on the results of the user’s games. The above should not be displayed if the user has not played any games.
! You do not have to write the code that displays the die face values to the screen, a module containing a function that does that for you has been provided. The dice.py file is a module that contains a function called display_dice that displays the face values of the dice to the screen for you.
� You are required to use this as part of this assignment, however, please do not modify the dice.py file.
PSP Programming Assignment 1 – 202002
Page 5 of 23
PRACTICAL REQUIREMENTS
It is recommended that you develop this part of the assignment in the suggested stages.
It is expected that your solution WILL include the use of:
• Your solution in a file called YourSaibtId_petals.py.
– Don’t forget you need to change the YourSaibtId to your actual SAIBT ID.
• Thesupplieddice.pymodule(containingthedisplay_dicefunction).
– This is provided for you – please DO NOT modify this file.
• Appropriate and well constructed while and/or for loops (as necessary).
• Appropriate if, if-else, if-elif-else statements (as necessary).
• The use of the random.randint(1,6) function in order to simulate the roll of a six sided die.
• One function (refer to stage 8 for description) called display_details().
• Output that strictly adheres to the assignment specifications. If you are not sure about these details, you should check with the ‘Sample Output – Part I’ provided at the end of this document.
• Good programming practice:
– Consistent commenting, layout and indentation. You are to provide comments to describe: your details, program description, all variable definitions, and every significant section of code.
– Meaningful variable names. Your solutions MUST NOT use:
• break or continue statements in your solution.
• quit() or exit() functions statements in your solution.
• break or return statements (or any other techniques) as a way to break out of loops.
! Doing so will result in a significant mark deduction.
PLEASE NOTE: You are reminded that you should ensure that all input and output conform to the specifica- tions listed here; if you are not sure about these details you should check with the sample output provided at the end of this document or post a message to the discussion forum in order to seek clarification.
Please ensure that you use Python 3.5.2 or a later version (i.e. the latest version) in order to complete your assign- ments. Your programs MUST run using Python 3.5.2 (or latest version).
It is strongly recommended that you develop this part of the assignment in the suggested stages.
Many problems in later stages are due to errors in early stages. Make sure you have finished and thoroughly tested each stage before continuing.
PSP Programming Assignment 1 – 202002
Page 6 of 23
Stage 1 – Interactive Menu
Implement the interactive mode (prompt for and read menu commands).
Step 1: Download the following two files from the course website (Assessment tab) and ensure that both files are in
the same directory:
• yourSaibtId_petals.py
• dice.py
Step 2: For the file yourSaibtId_petals.py, replace the yourSaibtIdwith your actual SAIBT ID.
• For example if your SAIBT ID was 345678, the new filename will be 345678_petals.py. Step 3: Set up a loop to obtain and process commands.
Step 4: Test your program
! Make sure the program runs correctly. Once you have that working, save a copy of your program e.g.
yourSaibtId_petalsSt1.py so you can go back to this point if needed.
Note: When developing software, you should always have fixed points in your development where you know your software is bug free and runs correctly.
Sample Output 1–1:
Welcome to ‘Petals Around The Rose’
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 1 In command 1 – instructions
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 2
In command 2 – play
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 3
In command 3 – solution
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 4
In command 4 – quit
Page 7 o
PSP Programming Assignment 1 – 202002
f 23
Stage 2 – Add basic commands
Step 1: If the user selects option 1 display the instructions as below:
Petals Around The Rose
———————-
The name of the game is ‘Petals Around The Rose’. The name of the game is important. The computer will roll five dice and ask you to guess the score for the roll. The score will always be zero or an even number. Your mission, should you choose to accept it, is to work out how the computer calculates the score. If you succeed in working out the secret and guess correctly four times in a row, you become a Potentate of the Rose.
Step 2: If the user selects option 2 the program displays a welcome message as below. (We will finish the rest of the game in future Stages)
Ok, let’s see if you can solve the puzzle.
Step 3: If the user selects option 3 your program should complete the options as below:
• Ask the user to enter a word
• Ask the user to enter how many times the last letter appears in the word
• Count the number of times the last letter appears in the word (using a loop – not count)
• If the user guesses correctly the user should display the solution as below
• Otherwise it should display the message as below and return to the menu
Sample Output 2–1:
You want the solution – ok here is an easier puzzle for you then.
Enter a word: zebra
How many times does a appear in zebra: 1
Correct:
The game is called petals around the rose.
You need to count any dots around the centre dot on
each die.
You want the solution – ok here is an easier puzzle for you then.
Enter a word: zebra
How many times does a appear in zebra: 2
Incorrect!
Step 4: If the user selects option 4 display the instructions as below Have a nice day… Remember to smell the roses.
Test to ensure that this is working correctly and create a copy before moving onto stage 3.
PSP Programming Assignment 1 – 202002
Page 8 of 23
Stage 3 – Getting Started on the game \ Your program will use some functions in dice.py to help display the dice values in a more user friendly way.
You DO NOT need to edit dice.py
Step 1: Ensure dice.py and YourSaibtId_petals.py are in the same folder and add the following code at the top of YourSaibtId_petals.py
Step 2: To ensure that this is working correctly enter the following in your YourSaibtId_petals.py file when the user enters option 3
dice.display_dice(2,3,4,5,6)
Step 4: Run the YourSaibtId_petals.py file. If this is working correctly, you should now see the following output
when the user enters 3 in the Python shell when you run your program:
Sample Output 1–1
Ok, let’s see if you can solve the puzzle.
Die1 Die2 Die3 Die4 Die5 [2] [3] [4] [5] [6]
* * ****** ****
****
** **
! Make sure the program runs correctly. Once you have that working, save a copy of your program e.g. yourSaibtId_petalsSt3.py so you can go back to this point if needed.
Note: When developing software, you should always have fixed points in your development where you know your software is bug free and runs correctly.
PSP Programming Assignment 1 – 202002
Page 9 of 23
Stage 4 – Simulate Rolling Five Dice
Step 1: Add code to simulate the rolling of five dice.
• Use the random.randint(1,6) function to simulate the roll of a die.
Step 2: Modify your code to now display the randomly generated dice roll to the screen.
• For example, if your variables (that store the randomly generated die rolls) are called die1, die2, die3, die4, and die5, you would then modify the code from stage one so that the randomly generated values are passed to the function instead, like so:
# Place code to randomly generate the roll of five dice here… :dice.display_dice(die1, die2, die3, die4, die5)
• So let’s say your variables had the following random numbers generated:
die1 = 3 die2 = 6 die3 = 4 die4 = 6 die5 = 1 . . . calling the display_dice function would result in the output shown below:
Sample Output 2–1
Die1 Die2 Die3 Die4 Die5 [3] [6] [4] [6] [1]
* ****** ******
*******
PSP Programming Assignment 1 – 202002
Page 10 of 23
Stage 5 – Prompting User to Guess The Number ofPetals
! To complete this stage, you will need to first understand how the game works. Otherwise you will not be able to work out what is a correct answer. If you are not sure read the assignment specification
Step 1: Add code to prompt for and read the user’s guess (i.e. the score guess for the roll)
Step 2: Based on the user’s input, display an appropriate message to the screen as follows: • If the user guesses correctly, the following message is displaye
• If the user enters an incorrect non-even number, the following message is displayed to the screen, for example:
• If the user enters an incorrect even number, the following message is displayed to the screen, for example:
Note that the numbers in the above output examples will change depending on what the user has entered and the score value for the roll.
Sample Output 3–1
Please enter your guess for the roll:
Sample Output 3–2
Well done! You guessed it!
Sample Output 3–3
No sorry, it’s 0 not 9. The score is always even.
Sample Output 3–4
No sorry, it’s 0 not 6.
Sample Output 3–5
Note: This will look different given we are generating random values here
Die1 Die2 Die3 Die4 Die5 [5] [4] [6] [2] [4]
******* ** ***
******* **
Please enter your guess for the roll: 4
Well done! You guessed it!
PSP Programming Assignment 1 – 202002
Page 11 of 23
Display the user’s guess, the actual score and appropriate message to the screen as seen below:
Sample Output 3–6 Note: This will look different given we are generating random values here
Die1 Die2 Die3 Die4 Die5 [3] [6] [3] [4] [1]
****** *****
******
Please enter your guess for the roll: 7
No sorry, it’s 4 not 7. The score is always even.
Sample Output 3–7 Note: This will look different given we are generating random values here
Die1 Die2 Die3 Die4 Die5 [4] [5] [5] [2] [6]
******* ** **** ****** ***
Please enter your guess for the roll: 4
No sorry, it’s 8 not 4.
PSP Programming Assignment 1 – 202002
Page 12 of 23
Stage 6 – Allowing Multiple Games
Now. . . it’s time to allow the player to play more than one game.
Ask the user to enter their name and display the welcome message as below” Add a loop that loops until the user either enters ‘n’ (to quit thegame).
� Think about where this code should go – what needs to be repeated, etc.
Sample Output 4–1
Note: This will look different given we are generating random values here
Please enter your name: Bob
Ok Bob, let’s see if you can solve the puzzle.
Die1 Die2 Die3 Die4 Die5 [3] [2] [4] [1] [5]
** * ** * *** ******
Please enter your guess for the roll: 6
Well done! You guessed it!
Roll dice again [y|n]? y
Die1 Die2 Die3 Die4 Die5 [6] [2] [4] [3] [3]
*** *** * **** *******
Please enter your guess for the roll: 3
No sorry, it’s 4 not 3. The score is always even.
Roll dice again [y|n]? y
Die1 Die2 Die3 Die4 Die5 [2] [4] [6] [6] [6]
* ******** ****** *********
Please enter your guess for the roll: 8
No sorry, it’s 4 not 8.
Roll dice again [y|n]? n
PSP Programming Assignment 1 – 202002
Page 13 of 23
Stage 7 – Capturing Game Statistics
Add code to keep track of:
• How many games were played
• The number of correct guesses
• The number of incorrect guesses
Display this to the screen as seen in sample output 5–1 below:
Sample Output 5–1
Note: This will look different given we are generating random values here
Game Summary
============
You played 5 games:
|–> Number of correct guesses: 0
|–> Number of incorrect guesses: 5
Stage 8 – Capturing Number of Correct/Incorrect Games In-A-Row
Add code to keep track of
• How many correct and incorrect guesses are recorded in a row; and • Display the appropriate messages to the screen when:
– If four correct guesses in a row are achieved: Congratulations! You have worked out the puzzle!
Shhh. It’s a secret.
– If four incorrect guesses in a row are achieved:
Here’s a clue. The name of the game is… Petals Around The Rose.
� This is a good time to remind you to use descriptive variable names. So nothing dodgy like single-letter variables! Also remember that variables start with a lower case letter. A good guide to choosing a name is to think about what value(s) the variable will hold. For example, if you need a variable to capture input from a user and the only options for the user are ‘y’ or ‘n’, a suitable variable name could be the word choice.
PSP Programming Assignment 1 – 202002
Page 14 of 23
Stage 9 – Validating User Input
Add code to validate the following user input only: • Enter an option from menu
• Roll dice again [y|n]?
Sample Output 7–1
Enter an option (1, 2, 3 or 4): w
Please enter either (1, 2, 3 or 4): x
Please enter either (1, 2, 3 or 4): 4
Sample Output 7–2
Roll dice again [y|n]? z
Please enter either ‘y’ or ‘n’.
Roll dice again [y|n]? y
PSP Programming Assignment 1 – 202002
Page 15 of 23
Stage 10 – Displaying your Details
Modify your code to include and make use of the function called display_details(). Step 1: Write a function called display_details which will display your details to the screen.
The function:
• Accepts no parameters
• Does not return any values.
How to define a function in Python
The general syntax for defining a function is:
def functionName(parameters):
function_body_suite
• Keyword def introduces a function definition.
• The functionName follows the same rules as variable names.
• The parameters are identifier names that will be used as the names within the function for the objects passed to the function.
• Parameters are optional, if there is more than one, they are written as a sequence of comma-separated identifiers.
– Parameters are the information being supplied to a function. – Parameters are local to the function.
• The function_body_suite is a sequence of Python statements. Must be indented.
Step 2: Call the function from the appropriate place in your program. Your function should produce the following output (with your details).
� Remember that defining the function does not execute (that is call) the function: – you will need to call the function from the appropriate place in your program. – Your function should produce the following output (with your details).
Sample Output 8–1
Note: This will look different given we are generating random values here
File : wayby001_petals.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
PSP Programming Assignment 1 – 202002
Page 16 of 23
Final Check – Comparing Your Output To Sample Output. . . and Fixing YOUR Output If Required
Finally, check the sample output (see section titled SAMPLE OUTPUT — PART I towards the end of this document) and if necessary, modify your code so that:
• The output produced by your program EXACTLY adheres to the sample output provided. • Your program behaves as described in these specs and the sample output provided.
Optional Extension
Note: these tasks can be completed to ‘win back’ lost marks. You can not earn more than 100% for the assignment
1. Incorporate more functions into your code that take in parameters and return values to help organise it. (3 marks)
2. Write your own version of dice.py to display the dice values in an interesting way (2 marks)
PSP Programming Assignment 1 – 202002
Page 17 of 23
SUBMISSION DETAILS
You are required to do the following in order to submit your work and have it marked:
• You are required to submit an electronic copy of your program via learnonline before the start of your second class (in week 8).
• You are also required to demonstrate your assignment to your practical supervisor during your week 8 practical class for marking. The supervisor will mark your work using the marking criteria included in this document. You MUST attend the practical session that you have been attending all study period in order to have your assignment marked.
Assignments submitted to learnonline, but not demonstrated during your allocated practical session, will NOT be marked. Likewise, assignments that have been demonstrated during the practical session, but have not been sub- mitted via learnonline, will NOT be marked. Assignments are submitted to learnonline in order to check for plagiarism.
If you are an external student, you are only required to submit an electronic copy of your program via learnon- line before Friday 16 September (week 8), 11:30pm (external students only). External students are not required to demonstrate in person.
All students (internal and external) must follow the submission instructions below:
• Ensure that your files are named correctly (as per instructions outlined in this document).
• Ensure that the following files are included in your submission:
– YourSaibtId_petals.py
– YourSaibtId_encryption.py
• For example:
– bonjy007_petals.py
– bonjy007_encryptor.py
• All files that you submit must include the following comments.
# File: fileName.py
# Author: your name
# Email Id: your email id
# Description: Assignment 1 – place assignment description here… # This is my own work as defined by the University’s
# Academic Misconduct policy.
#
• Assignments that do not contain these details may not be marked.
• You must have submitted your program before the online due date and demonstrate your work to your marker. You will also be required to demonstrate that you have correctly submitted your work to learnonline. Work that has not been correctly submitted to learnonline will not be marked.
• It is expected that students will make copies of all assignments and be able to provide these if required.
PSP Programming Assignment 1 – 202002 Page 18 of 23
EXTENSIONS AND LATE SUBMISSIONS
There will be no extensions/late submissions for this course without one of the following exceptions:
1. A medical certificate is provided that has the timing and duration of the illness and an opinion on how much the student’s ability to perform has been compromised by the illness. Please note if this information is not provided the medical certificate WILL NOT BE ACCEPTED. Late assessment items will not be accepted unless a medical certificate is presented to the Course Coordinator. The certificate must be produced as soon as possible and must cover the dates during which the assessment was to be attempted. In the case where you have a valid medical certificate, the due date will be extended by the number of days stated on the certificate up to five working days.
2. A Learning and Teaching Unit councillor contacts the Course Coordinator on your behalf requesting an ex- tension. Normally you would use this if you have events outside your control adversely affecting your course work.
3. Unexpected work commitments. In this case, you will need to attach a letter from your work supervisor with your application stating the impact on your ability to complete your assessment.
4. Military obligations with proof.
Applications for extensions must be lodged via learnonline before the due date of the assignment.
Note: Equipment failure, loss of data, ‘Heavy work commitments’ or late starting of the course are not suffi- cient grounds for an extension.
ACADEMIC MISCONDUCT
Students are reminded that they should be aware of the academic misconduct guidelines available from the University of South Australia website.
Deliberate academic misconduct such as plagiarism is subject to penalties. Information about Academic integrity can be found in Section 9 of the Assessment policies and procedures manual at: http://www.unisa.edu.au/policies/manual/
PSP Programming Assignment 1 – 202002 Page 19 of 23
MARKING CRITERIA
Section
Marks Obtained
Max Marks
Menu:
• Use of displayDetails function and welcome message /1
• Display menu with loop /2
• Correct prompt /1
• Validation of prompt /1
5
Choice 1
• Displays Instructions in correct format / 2
2
Choice 2
or incorrect dice display /1
or incorrect guess prompt /1
or incorrect odd score message /1
or incorrect even score message /1
or incorrect outcome message(win/lose) /1 or incorrect prompt (guess again y/n) /1
or incorrect validation on prompt /1
• No
• No
• No
• No
• No
• No
• No
• No or incorrect 4 in a row message /2
(4 correct, 4 incorrect)
• No or incorrect game summary layout /1 • No or incorrect game summary values /2
12
Choice 3
• Displays correct prompt /1
• Correct count of character /2
• Displays correct output based on value entered /2
5
Choice 4
• Displays correct goodbye message /1
1
Poor style (to lose marks)
• No or incorrect use of randint -2 • No or incorrect import -2
• No or incorrect while loop -2
• No or incorrect if statements -2 • No/poor comments -2
• Poor variable names -2
• Use of break/return/exit to leave loops -2
–
Extension: (to win back marks)
Additional use of functions / 3 Own dice.py file /2
+
5
TOTAL
/25
PSP Programming Assignment 1 – 202002 Page 20 of 23
SAMPLE OUTPUT
Sample Output
File : wayby001_petals.c
Author : Batman
SAIBT ID : 33333
Email ID : wayby001
This is my own work as defined by SAIBT’s Academic Misconduct Policy.
Welcome to ‘Petals Around The Rose’
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 1
Petals Around The Rose ———————-
The name of the game is ‘Petals Around The Rose’. The name of the game is important. The computer will roll five dice and ask you to guess the score for the roll. The score will always be zero or an even number. Your mission, should you choose to accept it, is to work out how the computer calculates the score. If you succeed in working out the secret and guess correctly four times in a row, you become a Potentate of the Rose.
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 3
You want the solution – ok here is an easier puzzle for you then. Enter a word: horse
How many times does e appear in horse: 0
Incorrect!
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 3
You want the solution – ok here is an easier puzzle for you then.
PSP Programming Assignment 1 – 202002 Page 21 of 23
Enter a word: glasses
How many times does s appear in glasses: 3
Correct:
The game is called petals around the rose.
You need to count any dots around the centre dot on each die.
S*** Menu ***
1. Instructions 2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 3
ample Output 2
Ok, let’s see if you can solve the puzzle.
Die1 Die2 Die3 Die4 Die5
[1] [1] [3] [3] [4]
* * ** ** ** ****
Please enter your guess for the roll: 4
Well done! You guessed it!
Roll dice again [y|n]? y
Die1 Die2 Die3 Die4 Die5 [5] [5] [6] [3] [1]
******* ******
****** * Please enter your guess for the roll: 3
No sorry, it’s 10 not 3. The score is always even.
Roll dice again [y|n]? y
Die1 Die2 Die3 Die4 Die5 [3] [6] [1] [2] [6]
****** ****** ******
Please enter your guess for the roll: 6
No sorry, it’s 2 not 6.
PSP Programming Assignment 1 – 202002 Page 22 of 23
Roll dice again [y|n]? x
Please enter either ‘y’ or ‘n’.
Roll dice again [y|n]? n
Game Summary
============
You played 3 games:
|–> Number of correct guesses: 1
|–> Number of incorrect guesses: 2
*** Menu ***
1. Instructions
2. Play
3. Solution
4. Quit
Enter an option (1, 2, 3 or 4): 5
Please enter either (1, 2, 3 or 4): 4
Have a nice day… Remember to smell the roses.
PSP Programming Assignment 1 – 202002 Page 23 of 23