Multiple Variables can be initialized with a
Multiple Variables can be initialized with differing values in a single statement. a,b,c = 1,2,3
A Python list is a variable that can store multiple items of data that are indexed starting at zero. E.g. : nums=[0,1,2,3,4,5].
Lists can have multiple dimensions as well:
[0] [1] [2]
|--------------------------------|
| | [0]
| |
| | [1]
|___________________| [2]
Example 1:
Example: quarter =['January','February','March']
to output January: quarter[0] or print("The first month is ", quarter[0])
Example 2:
coords = [[1,2,3],[4,5,6]]
print("Top left is ",coords[0][0])
print("Bottom right is",coords[1][2])
common value in a single statement. a=b=c = 10.Multiple Variables can be initialized with differing values in a single statement. a,b,c = 1,2,3
A Python list is a variable that can store multiple items of data that are indexed starting at zero. E.g. : nums=[0,1,2,3,4,5].
Lists can have multiple dimensions as well:
[0] [1] [2]
|--------------------------------|
| | [0]
| |
| | [1]
|___________________| [2]
Example 1:
Example: quarter =['January','February','March']
to output January: quarter[0] or print("The first month is ", quarter[0])
Example 2:
coords = [[1,2,3],[4,5,6]]
print("Top left is ",coords[0][0])
print("Bottom right is",coords[1][2])