Binary Tree
Digital Literacy and Intro to Programming
Week 5
Logic, Lists, Functions, etc. (Python)
Using Lists in Python
Lists are one of Python’s built-in data types which can store multiple items
Using Lists in Python
List items are ordered, mutable, and allow duplicate values. Also, lists are indexed, so the first item has index 0, the second item has index 1, and in general, the nth item has index n - 1.
Using Lists in Python
Note: Since a list of n items has a maximum index of n - 1, we cannot access a list item at an index position greater than or equal to n. If we do so, we get a “list index out of range” error. It’s important to make sure you know how many elements are in your list. That way, you reduce the likelihood of buggy code such as in line 12.
Using Lists in Python
Another operation that you can do with list is printing multiple values of the list.
We start with some index to start at and an end index. Like before we can start by typing out a print statement like
Keep in mind that we start with 0. So typing 1:3 would make us start with our second term and we will end before the 3rd term.
Using Lists in Python
Using Functions In Python
Using Parameters with Functions
Nested Functions
Mini Activity
Using the following link, attempt to create a Caesar Cipher encoder and decoder: https://www.programiz.com/python-programming/online-compiler/
(Read more about Caesar Ciphers at this link): https://www.geeksforgeeks.org/caesar-cipher-in-cryptography/)
Try to use a few of the topics we have covered today, such as functions and lists.��
Mini Activity Directions: