Principle #2 - PRIMM and proper

Background

During week 3 of this course, when you studied Principle #2, you read about PRIMM. While very similar to the POGIL activities you completed in FOP in the fall, these have some of their own unique features and goals. In order to understand this, it helps to complete a full PRIMM activity.

Take 20-30 minutes to complete the following with a partner

 

Activity

PREDICT

The algorithm below shows a program that performs an arithmetic operation based on some conditions

Working with a partner, predict the outcome of this program if the user inputs the following sequence of numbers.

  • 20
  • 25
  • 30
  • -15
  • -20
  • 20
  • -999

 

RUN

Enter the program into THONNY or IDLE.

Working with your partner, use each number from the predict stage and check if your prediction(s) are correct.

 

INVESTIGATE

Discuss with your partner how the algorithm meets the requirements by identifying the following:

  1. How is the data input into the program?
  2. How does the program decide which action to perform based on the comparison(s)?
  3. What criteria allow the program to terminate?
  4. What criteria prevent division by 0?

 

MODIFY

The algorithm needs to be changed so that only numbers between 1 and 100 are valid inputs. Any number input outside this range should stop the algorithm and print the output. The algorithm should not allow division by zero.

Work with your partner to:

  1. Identify which parts of the algorithm needs to be changed.
  2. Identify the changes that needs to be made
  3. Re-write (paper/pencil) the algorithm with the change.
  4. Select 6 SETS of test data to check if your algorithm works. Create a table to record all your inputs, proceed, and outputs.

 

MAKE (Challenge)

If you feel excited, challenge yourself to translate your new algorithm version into a working program. You can use the INTERNET for any research on any aspect of the program you do not understand or need clarity.