top of page
Image by Alexander Grey

List

Unit 2 Summary - part 1

Image by Nareeta Martin
Image by Annie Spratt
Image by Kenrick Mills

List coding

List 01.png

In Python, everything starts from 0.

​

  • Line 4 is used to replace 2.2 with 2.9

Image by Scott Webb
List today02.png
  • 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:

 

List today02 result.png
Image by Pawel Czerwinski
List today02b.png

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

Image by Krystal Ng
List today04.png

 

  • Rainbow.append("Ultra Violet") is to add one more element to the end of the list.

​​

Try this coding yourself

​

Image by Alexander Grey

2D Array & List

Candy Cotton
Comp S 062-063.png
List 05.png

 

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

​

List 06.png

 

  • 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.

​

Image by Rinck Content Studio
Visconsio Nekoland Logo.jpg
PT. Visconsio Kaya Jaya Masyhur

© 2020-2023 by Miana Kitty

bottom of page