Save
COMPUTING
List and Arrays
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Alice
Visit profile
Cards (13)
What is the purpose of
variables
in
programming
?
To store one data value at a time
View source
Why would creating
separate
variables
for each age be confusing?
Because it would take up space and become
unmanageable
View source
What is a
list
in
programming
?
A
data structure
that allows storing multiple data values under one name
View source
How does an
array
differ from a regular list in
Python
?
An array is a type of list that requires all values to be of the same
data type
View source
How do you create an
array
in
Python
?
By surrounding all values with
square brackets
[]
View source
What is the syntax to create an
array
of
names
in
Python
?
names = ['Ethan', 'Mary', 'Bob', 'Alice']
View source
What is the syntax to create an
array
of
ages
in
Python
?
ages = [
16
,
9
,
22
,
8
]
View source
What does the
index
number of an array start from?
0
View source
How would you access the
third
name in the
names array
?
By using print(names[2])
View source
How would you access the second age in the
ages
array
?
By using
print
(
ages[1]
)
View source
What
method
is used to add a new value to the end of a list in
Python
?
The
append
method
View source
How would you add "
MC Chillerts
" to the
names
array?
By using names.
append
("MC Chillerts")
View source
What are the key characteristics of
lists
and
arrays
in
Python
?
Lists store multiple data values under one name.
Arrays are a type of list with the same data type for all values.
Arrays are created using
square brackets
[].
Indexing
starts from 0.
The
append method
adds values to the end of a list.
View source