CP104 Lecture 7: 2D List
Last Two Questions two D lists
- 2d matrix
- Group data together with one name and use indexing to access element
- List triangular
- Nested for loops to print elements of two d lists
- Initialize list with empty list and append and put into two d list
- result=[]
- temp=[]
- result.append(temp)
- #Append empty lists in first two indexes.
- elements.append([])
Need to specify what empty list to put inside
Ways to fill two d lists
- results=[][
- For i in range (3):
- results.append([]) or temp=[]
- For j in range (3):
- Temp.append (0)
result.append(temp)
- Find highest number in 2d list
- Other list initialized two for loops
>> get average of rows and columns (separate)
Def get_av(handle_n):
rows=int(handle_in.readline())
cols= int(handle_in.readline())
std_2d=[]
For r in range(rows):
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents