
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
14 questions
OPERACIONES COMBINADAS
Presentation
•
11th Grade
15 questions
COSTA RICA
Presentation
•
11th Grade
16 questions
Counterargument Practice
Presentation
•
11th Grade
16 questions
MATERI STRUKTUR DATA
Presentation
•
11th Grade
13 questions
Análisis del módulo 9 de CISCO Hernández Suárez Bitia
Presentation
•
11th Grade
17 questions
Virus/Antivirus
Presentation
•
11th Grade
11 questions
Sensibilización ICFES 2021
Presentation
•
11th Grade
17 questions
Almacenamiento Básico - HDD y SSD
Presentation
•
11th Grade
Popular Resources on Wayground
5 questions
A Home on the Shore
Quiz
•
3rd Grade
28 questions
US History Regents Review
Quiz
•
11th Grade
6 questions
A Horse Tale
Quiz
•
3rd Grade
20 questions
Math Review
Quiz
•
3rd Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
20 questions
Dividing Fractions
Quiz
•
5th Grade
55 questions
A Long Walk to Water Final Review
Quiz
•
6th - 8th Grade
10 questions
Equation Word Problems
Quiz
•
7th Grade
Discover more resources for Computers
28 questions
US History Regents Review
Quiz
•
11th Grade
20 questions
Insurance
Quiz
•
9th - 12th Grade
10 questions
Juneteenth: History and Significance
Interactive video
•
7th - 12th Grade
10 questions
7.3-7.4 Quiz
Quiz
•
11th Grade
6 questions
Mayan Mathematics part 1
Presentation
•
9th - 12th Grade
40 questions
Flags of the World
Quiz
•
KG - Professional Dev...
10 questions
Unit 9 Quiz
Quiz
•
9th - 12th Grade
50 questions
US History Regents Practice Exam
Quiz
•
11th Grade