Download presentation
Presentation is loading. Please wait.
Published byArnoldo Costanzo Modified over 5 years ago
1
CMPT 120 Lecture 12 – Unit 2 – Cryptography and Encryption –
The realm of secret codes Python – Functions
2
Today, we shall … Go over the Practice Exam 2
Have a quick word about the Weekly Exercises Complete our Encrypt and Decrypt program (transposition algorithm) Have an activity Use functions in a new version of our Encrypt and Decrypt program
3
Practice Exam 2 Part 1 – Theory and Understanding
If each multiple choice question is worth 1 mark, what is your score (out of 8) for Part 1? Part 2 – Coding How did Part 2 go for you? Did you understand the problem to solve? Was it difficult to come up with an algorithm? Was it challenging to writing the program on paper? If so, why?
4
Let’s go over Question 10 Problem Statement:
Write a Milk Survey Bot that asks the user whether s/he has tried almond, coconut, cow, goat, hemp, oat, rice, and/or soy milk. Your Milk Survey Bot must then print the number of different kinds of milk the user has tried. Here is a sample run:
5
Remember - Steps we perform when we program (develop software)
Design solution (algorithm) Problem statement Implement program Test
6
Question 10 (cont’d) BONUS Part 1:
Write your Python code such that it does not include the actual number 8 in its last print statement print(“Wow! You … (out of 8).”) Instead, your program figures this number by calling a function. This number 8 here!
7
Question 10 (cont’d) BONUS Part 2: After your Milk Survey Bot has printed the number of different kinds of milk the user has tried, it then prints the names of the milks the user has tried. Hint: This printing must be done after (outside) the loop. Here is a sample run with the BONUS part:
8
https://repl.it/repls/FoolhardySameMeasurements
Last Lecture, we did …
9
How did we solve the decrypt problem?
10
Implementing the solution
11
Activity -
12
Let’s now move on to … Functions
Let’s see if we can use functions in a new version of our Encrypt and Decrypt program
13
By the way, what is a Python statement?
Next Lecture We shall look at another way of repeating Python statements in our programs while loop By the way, what is a Python statement?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.