Python: Robert’s Notes – LISTS

source = [‘a’, ‘b’, 0, 1, 2, 3, 4, 5]
target=source ## creates reference to source
target=source[1:5] ## start with the ‘b’ and go to the 5th char (2)
 [mem:char]
target=source[1:-2] ## start with the ‘b’ and go back two spaces from end
target=source[3] ## copies the number 4 into source
target=source[:] ## copies everything – separate instance

my_list = [1, 2, 3, 4, 5]
slice_one = my_list[2: ]
slice_three = my_list[2: ]
print(slice_one) # outputs: [3, 4, 5]
print(slice_two) # outputs: [1, 2]
print(slice_three) # outputs: [4, 5]
 
squares = [x ** 2 for x in range(10)] # X squared
twos = [2 ** i for i in range(8)] # 2 squared, cubed, etc
odds = [x for x in squares if x % 2 != 0 ] # odd numbered squares
 
BUILDS A CHESSBOARD with 64 empty squares

board = [[EMPTY for i in range(8)] for j in range(8)]
TEMPERATURE EVERY HOUR FOR EVERY DAY

temps = [[0.0 for h in range(24)] for d in range(31)]