In this assignment we are going to use the PRIMM approach to help you to develop a new program by modfying an existing one. PRIMM stands for Predict, Run, Investigate, Model, Make and we looked at the first three stages in the lesson. If you missed the lesson, then you can watch the recording or look at the questions below in the Predict, Run, Investigate section.
If you attended the lesson then we have already discussed these questions.
Look at the this example program in replit.com. If you have your own replit.com account then you can Fork it to make your own copy, or you can copy and paste the code into another IDE such as IDLE.
Before you run the code:
Now investigate the program by asking yourself these questions:
Do you know how to add a number to a list? You can use the .append method, e.g. number.append(1).
Make a copy of the program in replit.com and make as many of these changes as you are comfortable with. As you attempt more tasks you will become more confident and will complete more of the steps in future tasks.
Test your program to ensure that it is easy to use and gives the correct answers.
If you found that quite straightforward, why not generalise it? See if you can modify your program so that it can cope with users entering different numbers of values rather than always asking for five. How could you do that? I can think of at least two ways to do it - you could ask how many numbers there are, or you could look out for a particularly value, e.g. 0, being entered and then stop.