EC Lecture Notes - Lecture 5: Tuple, Exclamation Mark, Lightning

9 views4 pages

Document Summary

Lists are one of 4 built-in data types used to store collections of data, the other 3 are tuple, set, and dictionary. We can create a list by using square brackets with commas separating items. In that example the words list contains three string items: hello, world and ! If you want to access a certain item in the list, you can do this by using its index in square brackets. For example: words = ["hello", "world", "!"] print(words[0]) print(words[1]) print(words[2]) We can do some pretty cool stuff with them in python. For example, we can use nested lists to represent 2d grids, such as matrices. This is useful because a matrix-like structure can allow you to store data in row-column format, like in ticketing programs, that need to store the seat numbers in a matrix, with their corresponding rows and numbers. The code above outputs the 3rd item of the 2nd row.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents