Chapter 16 - Concept Summary¶
Chapter 16 included the following concepts from computing.
- Append - To append means to combine two strings with the characters from the second string following right after the characters in the first string. You can also append two lists which means that the items in the second list are added in order to the end of the first list. This is also called concatenation.
- For Each Loop - A for each loop loops executes the body of the loop one time for each element in a collection (a string or list).
- List - A list holds items in order. An example of a list is
[1, "hi", 3]
. Lists in Python can hold numbers and strings. - Index - The index is the position of the item in a list or string. In Python the first item is at index 0.
- String - A string is a collection of characters in order. In Python the characters are inside a pair of single or double quotes.
Summary of Python Keywords and Functions¶
- Len - The
len
(length) function returns the number of items in a collection (a string or a list). - Range - The
range
function returns a list of numbers. For example,range(3)
returns the list[0, 1, 2]
. The optional third value is the change amountrange(5, -1, -1)
returns the list[5, 4, 3, 2, 1, 0]
.