RI Y2 CEP Lesson 5 Slides 2020
Uploaded by dontsueme · 10 December 2024
Preview
Lesson 5Tuple . Print variations. Collatz Conjecture . Caesar Cypher . Coin Flip Simulation
Administrative•Practical Test changed to Lesson 7 ( T2W1)
Lesson Objectives•tuple•print variations•Discussion of problems:•Chinese zodiac•Collatz conjecture•Caesar Cipher•Coin Flip Simulation
Tuple à ( )•Immutable version of list•Methods for tuple:•index à returns the index of the first occurrence of parameter•count à returns the number of occurrence of parameter•Cannot append, pop, insert … etc (trying to mutate the array)•Good for keep a data that does not change:•Encryption key, grading system … etc
print variations •print( , sep = ‘ ’)•print( , end = ‘’)•print( ,sep = ‘’,end = ‘’)
Collatz Conjecture
Caesar CipherThe Caesar Shift Cipher is a type of substitution cipher where each letter in the original plaintext message is replaced by a letter some fixed number of positions down the alphabet. It is named after Julius Caesar, who used it in his private correspondence.The table below shows an example where the letters have been shifted to the right by 3.Note that the letters “wrap-around” at the end. abcdefghijklmnopqrstuvwxyzdefghijklmnopqrstuvwxyzabc
shift in one character Something is missing ! string.isalpha() returns True if is an alphabet, False otherwise
Cipher – 2•Write a function to implement the encryption using the Caesar cipher with a key•You are to use the shift function done in cipher – 1 •Write a function to decrypt the cipher text, using the brute force approach•Hint: you use the encryption to decrypt the code with different keys and output all possible original text
Content continues in the PDF.
Related notes
- Computing o level notes Notes/Practices · 2023
- BVSS Prelim P1 MSExam Papers · 2024
- BVSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 CPExam Papers · 2024
- CWSS Prelim P1 MSExam Papers · 2024
- computing notesNotes/Practices

