CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption –

Slides:



Advertisements
Similar presentations
Arko Barman COSC 6335 Data Mining University of Houston.
Advertisements

String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Computer Science 111 Fundamentals of Programming I Iteration with the for Loop.
Python Control of Flow.
Announcements Project 2 Available Tomorrow (we will send mail) Will be due 11:59PM October 9 th (Sunday) Week 6 ( I will be traveling this week) Review.
Introduction to Computational Linguistics Programming I.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
>>> # Fibonacci series:... # the sum of two elements defines the next... a, b = 0, 1 >>> while b < 10:... print b... a, b = b, a+b WHILE.
For loops in programming Assumes you have seen assignment statements and print statements.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
Exam 1 Review Instructor – Gokcen Cilingir Cpt S 111, Sections 6-7 (Sept 19, 2011) Washington State University.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
Introduction to Strings Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg 1.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
Python Mini-Course University of Oklahoma Department of Psychology Day 3 – Lesson 10 Iteration: Loops 05/02/09 Python Mini-Course: Day 3 - Lesson 10 1.
1 CS 177 Week 6 Recitation Slides Review for Midterm Exam.
Introduction to Computing Using Python Repetition: the for loop  Execution control structures  for loop – iterating over a sequence  range() function.
Introduction to Programming Python Lab 8: Loops 26 February PythonLab8 lecture slides.ppt Ping Brennan
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
Loops ( while and for ) CSE 1310 – Introduction to Computers and Programming Alexandra Stefan 1.
String and Lists Dr. José M. Reyes Álamo. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list.
More about Iteration Victor Norman CS104. Reading Quiz.
Introduction to python programming
Topic: Iterative Statements – Part 1 -> for loop
Introduction to Programming
For loops Genome 559: Introduction to Statistical and Computational Genomics Prof. William Stafford Noble.
Topic: Conditional Statements – Part 1
Topic: Python’s building blocks -> Variables, Values, and Types
CMPT 120 Topic: Python strings.
Introduction to Programming
Think What will be the output?
Repetition: the for loop
3rd prep. – 2nd Term MOE Book Questions.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction to Strings
Introduction to Strings
Creation, Traversal, Insertion and Removal
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
CMSC201 Computer Science I for Majors Lecture 12 – Tuples
Teaching London Computing
Chapter (3) - Looping Questions.
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Introduction to Programming
Introduction to Programming
CMSC201 Computer Science I for Majors Lecture 08 – For Loops
Training & Development
Introduction to Strings
CS1110 Today: collections.
class 4 definite loops range list end=" "
Introduction to Computer Science
Repetition: the for loop
Introduction to Strings
Introduction to Programming
Topic: Loops Loops Idea While Loop Introduction to ranges For Loop
Introduction to Programming
CMPT 120 Lecture 12 – Unit 2 – Cryptography and Encryption –
Topic: Iterative Statements – Part 2 -> for loop
Class code for pythonroom.com cchsp2cs
Introduction to Strings
Lecture 7 – Unit 1 – Chatbots Python – For loops + Robustness
CMPT 120 Lecture 9 – Unit 2 – Cryptography and Encryption –
CMPT 120 Lecture 13 – Unit 2 – Cryptography and Encryption –
LOOP Basics.
Lecture 37 – Practice Exercises 9
CMPT 120 Topic: Python strings.
Lecture 37 – Practice Exercises 9
Introduction to Python
Presentation transcript:

CMPT 120 Lecture 10 – Unit 2 – Cryptography and Encryption – The realm of secret codes Python – Range function

Last Lecture, we did … https://repl.it/repls/AssuredHarmfulBots

Let’s implement our program now! Problem Statement: Write a program that encrypts messages using a transposition algorithm called “odd&even” odd&even transposition algorithm: Create a cypher that is made of 2 strings String 1 contains the characters in odd positions String 2 contains the characters in even positions

Let’s decrypt our message! Problem Statement: Write a program that decrypts messages that have been encrypted using the transposition algorithm odd&even

Our first decryption algorithm In order to implement our first decryption algorithm, we need to know … String concatenation Arithmetic operator Indexing Slicing len( ) function range( ) function

Reading Review String Indexing: "Hello World!"[6] -> message = "slicing" message[ ] -> String Slicing: message[ : ] -> message[ : : ] -> "123456789"[2:8:3] ->

Reading Review range( ) function What will we see printed on the Python Interpreter shell window if : range(10) range(1, 11) range(0, 30, 5) range(0, 10, -3) range(0, -10, -1) range(0) To see the sequence produced by the function range( ) on the Python Interpreter shell window : list(range(...))

Review - Syntax of a for loop Can be a string <statement outside (before) the loop> for <iterating variable> in <sequence> : <first statement to be repeated> <second statement to be repeated> ... <last statement to be repeated> <statement outside (after) the loop> Can be a list Can be produced using range(…)

Review - Syntax of a for loop <statement outside (before) the loop> for <iterating variable> in <sequence> : <first statement to be repeated> <second statement to be repeated> ... <last statement to be repeated> <statement outside (after) the loop> Important – About Indentation Statements inside the loop (i.e., statements executed at each iteration of the loop) are the statements indented with respect to the for keyword Statements outside the loop (before and after the loop) are the statements that are not indented with respect to the for keyword – these statements are considered to be at the same level of indentation as the for loop

Review - range( ) function Very useful in for loop Syntax: range([start,] stop [,step])) Produces a list of integers How does it work? If theLength = 5 Then range(theLength) produces [0, 1, 2, 3, 4]

Next Lecture Let’s practice what we have learnt so far Practice Exam 2 -> paper-based