R PROGRAMMING Lecture Notes - Array Data Structure, String Literal, 5,6,7,8

6 views5 pages

Document Summary

Python provides data structures for holding an ordered list of objects. A python list is an ordered, mutable array of objects. A list is constructed by specifying the objects, separated by commas, between square brackets, []. >>> list2 = [2, a, -0. 1, list1, true] [2, 4, -0. 1, [1, "two", 3. 14, 0], true] Note that a python list can contain references to any type of object: strings, the various types of numbers, built-in constants such as the boolean value true, and even other lists. It is not necessary to declare the size of a list in advance of using it. An empty list can be created with list0 = []. An item can be retrieved from the list by indexing it (remember python indexes start at 0): This last example retrieves the second (index: 1) item of the fourth (index: 3) item of list2.

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

Related Questions