Lesson 09: Lists Topic: Introduction to Programming, Zybook Ch 8, P4E Ch 8. Slides on website.

Slides:



Advertisements
Similar presentations
ThinkPython Ch. 10 CS104 Students o CS104 n Prof. Norman.
Advertisements

Course A201: Introduction to Programming 10/28/2010.
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Chapter 6 Lists and Dictionaries CSC1310 Fall 2009.
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.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
Fall Week 4 CSCI-141 Scott C. Johnson.  Computers can process text as well as numbers ◦ Example: a news agency might want to find all the articles.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Python Repetition. We use repetition to prevent typing the same code out many times and to make our code more efficient. FOR is used when you know how.
Built-in Data Structures in Python An Introduction.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 8 Lists and Tuples.
Lists CS303E: Elements of Computers and Programming.
1 CSC 221: Introduction to Programming Fall 2011 Lists  lists as sequences  list operations +, *, len, indexing, slicing, for-in, in  example: dice.
GROUPING OBJECTS CITS1001. Lecture outline The ArrayList collection Process all items: the for-each loop 2.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
CS190/295 Programming in Python for Life Sciences: Lecture 6 Instructor: Xiaohui Xie University of California, Irvine.
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Python Programing: An Introduction to Computer Science
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.
String and Lists Dr. José M. Reyes Álamo.
Lesson 06: Functions Class Participation: Class Chat:
Lesson 03: Variables and Types
Exam #1 You will have exactly 30 Mins to complete the exam.
Data types: Complex types (List)
Lesson 08: Files Class Participation: Class Chat: Attendance Code 
Lesson 07: Strings Class Chat: Attendance: Participation
Lesson 10: Dictionaries Topic: Introduction to Programming, Zybook Ch 9, P4E Ch 9. Slides on website.
Python - Lists.
Lesson 04: Conditionals Topic: Introduction to Programming, Zybook Ch 3, P4E Ch 3. Slides on website.
Lesson 05: Iterations Class Chat: Attendance: Participation
From Think Python How to Think Like a Computer Scientist
Lesson 07: Strings Topic: Introduction to Programming, Zybook Ch 6, P4E Ch 6. Slides on website.
While Loops in Python.
Lesson 12: Data Analysis Topic: Data Analysis, Readings on website.
Lists Part 1 Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Lesson 13: Visualizations
Lesson 05: Iterations Topic: Introduction to Programming, Zybook Ch 4, P4E Ch 5. Slides on website.
Creation, Traversal, Insertion and Removal
Lesson 08: Files Topic: Introduction to Programming, Zybook Ch 7, P4E Ch 7. Slides on website.
CS190/295 Programming in Python for Life Sciences: Lecture 6
6. Lists Let's Learn Python and Pygame
Data Structures – 1D Lists
4. sequence data type Rocky K. C. Chang 16 September 2018
I210 review.
Patterns to KNOW.
IST256 : Applications Programming for Information Systems
Lesson 06: Functions Class Chat: Attendance: Participation
String and Lists Dr. José M. Reyes Álamo.
Lists in Python Creating lists.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Lesson 09: Lists Class Chat: Attendance: Participation
CMSC201 Computer Science I for Majors Lecture 09 – While Loops
Topics Sequences Introduction to Lists List Slicing
Lesson 08: Files Class Chat: Attendance: Participation
Lesson 10: Dictionaries Class Chat: Attendance: Participation
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
CHAPTER 4: Lists, Tuples and Dictionaries
Introduction to Programming with Python
Topics Sequences Introduction to Lists List Slicing
And now for something completely different . . .
CSE 231 Lab 8.
While Loops in Python.
Lesson 07: Strings Class Chat: Attendance: Participation
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Python Open source Many applications Python 3 jupyter notebook
IST256 : Applications Programming for Information Systems
Introduction to Computer Science
Presentation transcript:

Lesson 09: Lists Topic: Introduction to Programming, Zybook Ch 8, P4E Ch 8. Slides on website.

Agenda Lists as a mutable sequence of values. Indexing list values; slice notation. List functions and operations like add, remove, update, find Common patterns for list management. You’ve Read: Zybook Ch8 P4E Ch8

Connect Activity For x = [0,1,2,3,4,5] what is x[2:4] ? [2,3] [1,2,3] [1,2] [2,3,4,5]

Lists are Sequence Types Python lists are variables which hold a collection of values. They are actually sequences of values. Like strings, you can index lists and use slice notation. Unlike strings, lists are mutable which means they can be changed. In Python, type list is a sequence type.

Watch Me Code 1 List Enumeration and Aggregates Definite Loops Indexes / Slices List mutation Aggregations

Check Yourself: List Indexes What is the value of the expression on line 2? ['A','B+','A'] ['A','B+'] ['B+','A']

Built-In List Functions Like strings, Python lists have an assortment of built in functions for mutable sequence types: For your reference: https://docs.python.org/3/library/stdtypes.html? highlight=list#mutable-sequence-types

Watch Me Code 2 List Basics Empty Lists List Item Management Methods: append, remove, index

Check Yourself: List Function Matching Match the Definition… To its term. Add anywhere in the list Add to the end of the list Delete item from the list Get index of value in list index insert remove append delete

End-To-End Example: Bad Password Checker Read in list of bad passwords from file Main program loop checks password as "good" or "bad" password by checking if it exists in the file this repeats until user enters no password.

In Class Coding Lab: