Module 4: Strings and Lists are iterables Flashcards
A _______ is a collection of items in some order.
sequence
A string is a ______ meaning it is an ordered collection of other values.
sequence
Access characters of a string one at a time using _______.
bracket operator
expression in [ ] brackets is _______ and starts at ______.
index, 0
value of an index must be _______.
integer
______ is a built in function that returns number of characters in a string.
len(stringname)
to get last digit of word from index use [ ______ ] or [ ______ }
- first: length = len(fruit)
last length-1 - [-1]
A _____ is a segment of a string
slice
select a slice using [ _______ ]
n:m
:m or n:
A _______ is a pattern that starts at the beginning, select each character in turn, do something to it, and continue until the end.
traversal
strings are _______ meaning you cannot change an existing string and cannot use [ ] on the left side of assignment.
immutable
A ______ is the pattern of computation of traversing a sequence and returning when we find what we are looking for.
search
A list is a sequence of _______. In a string values are _______, in a list they are _______.
values, characters, any/elements/items
empty list is given by ______
[ ]
variables can be ________ list values
assigned
syntax for accessing elements of a list is ______ as for accessing characters of a string
the same