INFO1110 Lecture 4: 4 – Loops and lists

72 views4 pages

Document Summary

An array is a contiguous block of memory containing multiple values of the same type. A multi-element array is comma-separated objects of the same type within square brackets. Lists are objects that contain an array of objects containing memory addresses. So the length of each item is the length of addressable memory. They also contain metadata about the list, such as the length of the list. List size is not fixed, i. e. mutable: any type of object can be included, elements can be inserted or removed in any position, a subset of the list can be created from the list, very different memory structure. In python, there are only lists, no arrays. Accessing the last element of the array x[-1] x[len(x) - 1] # using a while loop: index = 0 while index < len(my_list): if my_list[index] == search_item: found = true break.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents