Y9 Programming Page → Step 1. Reading Code → Step 2. Tracing Code → Step 3. Debugging Code → Step 4. Writing Code → Step 5. Assessment
Now it's time to write some code for other humans to use.
Open this MATH QUIZ DOCUMENT
And Join in with this video that walks you through a complete task.
The important thing is that you are writing code for humans now.
It needs to be readable with good variable names and code comments.
It need to be logical with good code structure and a pseudocode plan.
And you have to do formal test tables to show it has been tested.
If you want a full screen version of the Python editor widget below, CLICK HERE
Firstly: Open the GUESSING GAME DOCUMENT
This is NOT the same task as the one above (but it's VERY similar).
Your job is to put into practice all that you have learned over the last few lessons to try to write a complete Python program from a brief. That includes, Planning, Debugging and Testing. Good luck programmer.
You are required to write a guessing game using Python.
The goal is for the user to be asked to guess a secret number and loop until the user gets it right. The game should inform you if the number is higher or lower than the number you guessed or if it is the correct number.
Specifications
Must be a number guessing game
The computer must store a secret number between 1 and 10
Your program must ask the user to guess what that number is.
Must tell the user if they are correct, too high or too low.
The game will keep asking until the user guesses the correct number.
In YOUR document write your pseudocode plan for a program that meets these specification now.
Using the editor below, copy and paste your pseudocode into it and start writing, debugging and testing your code.
For a fullscreen version of the editor CLICK HERE
Don't forget to copy and paste it into your document once you have it working.
Now it is time to test your code. In your document, run your code against all of the given tests.
Hint: if you didn’t call your variables “secret_number” and “guess”, change the table heading before you begin.
Use the results of the tests to refine your pseudocode and your Python program if required.
Now it's time to go crazy and show off what you can do. Choose a refinement and write a new pseudocode plan in your document for your refined program. Refinements could be things like:
Randomly generate the secret number at the beginning
Keep track of number of guesses and give them a score at the end
Allow only 5 guesses for each number
Some random ‘appropriate insults’ for the incorrect guess
Changing the range of the random number that is generated (eg 1-100 or 15-74)
Personalise by using the players name throughout
Politely handle invalid inputs (eg a letter instead of a number)
At the end, show a certain message linked to the number of guesses i.e. A+, A, B, C
Jump back into the code editor above and write, debug and test your new program.
Don't forget to copy/paste the finished program into your document when you are done.
Now it is time to test your code.
This time, YOU need to write the tests and run your code against them. Use this testing to help you further debug and refine your plan and your final Python code.
Write all the tests down in your "version 2 Testing" section and run each one. Don't forget to test for:
Expected inputs (values that your program expects to get)
Boundary inputs (values on the edges of what you expect)
Invalid inputs (values that your program doesn't expect, like letters when they expect a number)
Complete the checklist at the end of the document and, if you are happy with it, hand it in to your teacher.