

List
Unit 2 Summary - part 1



List coding

In Python, everything starts from 0.
​
-
Line 4 is used to replace 2.2 with 2.9


-
Line 1: Use \ (back slash) if your command is too long, so you can continue onto the second line.
​
-
Line 3 will print all elements
​
-
Line 4 will print Red (the first list's element)
-
Line 5 will print the index number 0 (Red is the first element, and the first element in Python is 0.
-
Line 9 is to list down the rainbow colours.
This is the result of the coding:



Line 6: Use len to list down instead of typing 7.


-
Rainbow.append("Ultra Violet") is to add one more element to the end of the list.
​​
Try this coding yourself
​

2D Array & List



-
Grid[1] [0] = 99 is to replace row 1 & column 0's number with 99.
​

-
Line 1 - 3 is to show the Grid in different lines.
​
-
Line 7 - 11 is to show the numbers individually so you can copy them if you need to.
​

