Iteration


In the first week, you were introduced to state. This week, you were introduced to iteration, one of the more difficult programming constructs to grasp. To reinforce your understanding of iteration, this lab will look at one of the earliest and most widely known encryption techniques known as the Caesar Cipher.

Each letter in the plain text is substituted for a letter from the same alphabet. The new letter chosen depends on the shift number and the direction. The table below shows the results of a backwards shift of three.

image

If the letter in our plaintext is H, we shift three places to the left (backwards), passing G and F before reaching E. We replace the H in our plaintext with the character E.


Open Code Editor






Click here to go to the COMP16321 Blackboard page


Click anywhere to close this video

Contents



Introduction

Git, GitLab and Cloning your Existing Repository

Task 1 - Trace Tables

Task 2 - Encryption Program

Task 3 - Decryption Program

Task 4 - A Better Design

Task 5 - Encryption Program Version 2

Task 6 - Decryption Program Version 2

Conclusion


Green = Current Page

Click anywhere to close this overlay

Topics Covered in this Lab



1. Interpreting pseudocode.

2. Tracing through an algorithmic design

3. Converting pseudocode to Python.

4. Obtaining input from the user.

5. Variable (declaration, initialisation or assignment)

6. While loops

7. Basic functions (len())

8. The array operator and lists

9. Negating an evaluation

10. The ASCII table

11. Less common functions (ord and chr)



Click anywhere to close this overlay

Lab Key



Notes – #FF6F61

Videos – #34568B

Code Examples – #009B77

Downloads - #C3447A

Internal Link (University Resources) – #955251

External Link (Non-University Resources)– #EFC050

Other - #660099



Click anywhere to close this overlay