
Python Lists
Presentation
•
Computers
•
11th Grade
•
Medium
Fabian Manning
Used 24+ times
FREE Resource
12 Slides • 7 Questions
2
Python List
Before introducing Python List, let us review
Python Variable
3
Python List: Variables
As in the case in math, Python uses variables to name unknown quantities
4
Python List: Variables
Mathematics | Python |
|---|---|
y = 2 | y = 2 |
y = boy | y = 'boy' |
x = girl | x = 'girl' |
In Python, the unknown quantities are called Data Types
Notice how the data type 'girl' and 'boy' are represented
5
Python: Variable vs List
Notice that each Variable is linked to one unknown?
That is y = 2, y = 'boy' or y = 'books'
In Python, lists are similar but, are used to store multiple items in a single variable.
Variable | List |
|---|---|
y = 2 | y = [2, 'boy', 'book'] |
y = 'boy' | |
y = 'book' | |
Notice:
List conveniently assign multiple items to a variable.
List is identified using [ ]
each item is separated using commas.
6
Python: List
You can view listings as chess with drawers.
Each item will be placed in one drawer.
Each drawer will be numbered, starting from 0. (this Python is called indexing.
0
1
2
3
4
7
Python: List
Example: The following is an example of a list...
y = [2, 'boy', 'book']
2 in slot 0
y =
boy in slot 1
book in slot 2
8
Multiple Choice
Is this the correct code for a list?
register = {"Sam", "Pheobe", Georgia", Richard"}
Yes
No
9
Multiple Choice
colours = [ ]
colours = ( )
colours = { }
colors = [ ]
10
Multiple Choice
What is used to separate elements in a list?
Bracket
Comma
Full Stop
Space
11
Multiple Choice
What brackets are used to create a list?
()
[]
12
Multiple Choice
What does the '#' allow you to do?
Repeat code
Comment on code
Print code
End code
13
Multiple Choice
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
14
Multiple Choice
This list contains items of what data type?
String
Boolean
Float
Integer
15
More About List
List items are...
ordered,
changeable, and
allow duplicate values.
16
More About List
List items are ordered,
This means that the items have a defined order, and that order will not change.
If you add new items to a list, the new items will be placed at the end of the list.
17
More About List
List items are ordered,
This means that each item occupies a specific position (having defined order), and that the order will not change.
If you add new items to a list, the new items will be placed at the end of the list.
18
More About List
List items are changeable,
This means that the items can be change by adding, and removing items after it has been created.
19
More About List
List items allow for duplicate values.
This means that lists can have items with the same value
thislist = ["apple", "banana", "cherry", "apple", "cherry"]
This is possible since each item in the list will occupy its own position (slot).
Show answer
Auto Play
Slide 1 / 19
SLIDE
Similar Resources on Wayground
12 questions
Computación 1BGU
Presentation
•
11th Grade
16 questions
MULTIMEDIA Y OFIMÁTICA 2022
Presentation
•
11th Grade
16 questions
El Poder de PowerPoint-Javier
Presentation
•
KG
9 questions
CIRCUITOS
Presentation
•
11th Grade
16 questions
IMPORTANCIA DE LAS ETIMOLOGÍAS
Presentation
•
11th Grade
12 questions
Declaration of Independence
Presentation
•
11th Grade
16 questions
comprensión lectora
Presentation
•
11th Grade
14 questions
Periféricos
Presentation
•
11th Grade
Popular Resources on Wayground
10 questions
HCS SCI 03 Summer School Review 4
Quiz
•
3rd Grade
11 questions
HSMS - Standard Response Protocol
Quiz
•
6th - 8th Grade
16 questions
1.1-1.2 Quiz Review
Quiz
•
9th - 12th Grade
12 questions
Exponent Expressions
Quiz
•
6th Grade
20 questions
Adding and Subtracting Integers
Quiz
•
6th - 7th Grade
11 questions
Northeast States
Quiz
•
3rd - 4th Grade
10 questions
Characterization
Quiz
•
3rd - 7th Grade
10 questions
Common Denominators
Quiz
•
5th Grade