CSC108H1 Lecture Notes - Lecture 6: Memory Address

12 views3 pages
School
Course
Professor
yifanyang and 39659 others unlocked
CSC108H1 Full Course Notes
21
CSC108H1 Full Course Notes
Verified Note
21 documents

Document Summary

Lists can contain items of any type, including other lists. >>> grades = [["assignment 1", 80], ["assignment 2", 90], To access a nested item, first select the sublist, and then treat the result as a regular list. For example, to access "assignment 1", we can first get the sublist and then use it as we would a regular list: Both sublist and grades[0] contain the memory address of the ["assignment 1", We can access the items inside the nested lists like this: The bodies of loops can contain any statements, including other loops. When this occurs, this is known as a nested loop. Here is a nested loop involving 2 for loops: for i in range(10, 13): for j in range(1, 5): print(i, j) Notice that when i is 10, the inner loop executes in its entirety, and only after j has ranged from. 1 through 4 is i assigned the value 11.

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