In: Computer Science
Your data science experiment now requires four additional data tasks. The first task is to use the list append method to add to the list variable named btcdec1 the BTC price of 14560. The second task is to create a new list with a variable named btcdec2 and append the btc prices of 15630, 12475, and 14972. The third task required you to use the list extend method to add the contents of the list in variable name btcdec2 into the variable name btcdec1. The fourth and final task requires you to use the list sort method in the list named btcdec1 to sort the items in the newly extended list, then use the print statement to output the content of list btcdec1 into the Python console.
PYTHON CODE:
# creating empty btcdec1 list
btcdec1 = []
# adding the 14560 to btcdec1 list
btcdec1.append(14560)
# creating empty btcdec2 list
btcdec2 = []
# appending the 15630,12475,14972 to the btcdec2 list
btcdec2.append(15630)
btcdec2.append(12475)
btcdec2.append(14972)
# adding the contents of btcdec2 to btcdec1
btcdec1.extend(btcdec2)
# sorting the btcdec1
btcdec1.sort()
# printing the btcdec1
print(btcdec1)
SCREENSHOT FOR CODING:
SCREENSHOT FOR OUTPUT: