1. What will the following python code display?
num = list(range(5))
print(num)
2.
Answer the following questions using the list below. You can
record your answers in the essay textbox.
data = [5,3,7]
A. Write code to replace the value in the 0 position with the
number 8.
B. Add the value 10 to the end of the list.
C. Insert the value 22 after position 1 in the list.
D. Remove the value at position 2.
E. Sort the values in the list.
SOLUTION-
1) num = list(range(5))
print(num)
Output-
[0,1,2,3,4]
It will print the array of size 5 contains number from 0-4
2) Code is given below-
data=[5,3,7]
(a) Replace the value in the 0 position with the number 8.
data[0]=8
(b) Add the value 10 to the end of the
list.
data.append(10)
(c) Insert the value 22 after position 1 in the
list.
data.insert(2, 22)
(d) Remove the value at position 2.
data.pop(2)
(e) Sort the values in the list.
data.sort()
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I
WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------
Get Answers For Free
Most questions answered within 1 hours.