18.104.22.168 create nested lists
Python. Nested lists (2D arrays)
Lists can be nested at any level. We will consider only two-dimensional (2D) lists.
The 2D list is a data structure that can be represented in a square table.
Each element of the list is also represented by a list (nested list).
To refer to an element in a 2D list, you should at first determine the index of the list element (row) and then determine the index of the nested list element (column).
For example, to get the value 8 from a table, you need to write the name of the list lst2D, then specify the index of the list element lst2D, then specify the index of the element in the nested list lst2D.
Question. Determine the result of a code snippet: print(lst2D, lst2D, lst2D[-1][-3])
How to create 2D lists filled with zeros?
How to fill a 2D list with dimensions n*m from the keyboard?
If we want to input each value of an element in a new line:
If we want to input each row of elements in line:
If we want to input each row of integers on one line:
How to process each element of a matrix?
Iterating over elements. We can get value for each element
How to display all elements in a table?
1. Explain what means 2D list/array.
2. Describe the main idea to process elements of the 2D list.
Ex. 1 Determine the result of code snippets
Ex. 2 Fill the blanks
|Просмотров: 644 | ||
|Всего комментариев: 0|