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 nested loop example in Basthon. 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:
1. Run the program. How many # symbols are printed altogether? Could you work out the number instead of counting them?
2. Which variable controls the number of rows? Which variable controls the number of columns?
3. What would you change if you wanted to print three rows of ten # symbols?
4. What is the purpose of the row variable? Why is it needed?
5. Could you change the program to print a triangle - i.e. form a triangle number - instead of a rectangle?
6. How would you alter the program to work out the size of a triangle number?
7. What would you do if you wanted the point of the triangle at the bottom, rather than the top?
Make a copy of the nested loop example in Basthon 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.
ordinal = ("first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth") present = ("a partridge in a pear tree", "two turtle doves", "three French hens", "four colly birds", "five gold rings", "six geese a-laying", "seven swans a-swimming", "eight maids a-milking", "nine ladies dancing", "ten lords a-leaping", "eleven pipers piping", "twelve drummers drumming")