CMPT 120 Lecture Notes - Lecture 26: Coding Conventions

23 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Two-dimensional list: a list that contains other lists as its elements. Common to think of two-dimensional lists as having rows and columns (table). Useful for working with multiple sets of data. To process data in a two-dimensional list use two indexes. Typically use nested loops to process. list = [[ joe , 301 , m ], [ kim , 302 , f ], [ li , 303 , m ], [ mi , 304 , f ]] for i in range(4): for j in range(3) Format: tuple_name = (item1, item2, ) country_tuple = ( canada", america", mexico") print(country_tuple) ("canada", "america", "mexico") Subscript indexing for retrieving elements: country_tuple[0] "canada" Methods such as index: country_tuple. index((cid:3243)america(cid:3244) ) 1. Built in functions such as len, min, max;slicing expressions, and in, +, and * operators. for c in country_tuple: print(c) for i in range(len(country_tuple)): print(country_tuple[i]

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