Question: Basic List practice Open the interpreter (black window) and do the following instructions: Create an empty list L1 . Print it. Create a list of
Basic List practice
Open the interpreter (black window) and do the following instructions:
Create an empty list L1. Print it.
Create a list of 5 numbers L2. Print it.
Create a string of 5 words and make a list L3 using the split() method. Print it.
Create a mixed content list of 5 items (numbers and strings) L4. Print it.
Make a list from the string Hello using the list() operator and call it L5. Print it.
Make a list L6 from the range(1, 9), use again the list() operator and note how many elements there are (use the len() operator). Print it.
Test if the number 5 is in the list L6. Then test if the number 9 is in the list L6.
Test if the number 0 is not in the list L6. Then test if the number 10 is not in the list L6.
Slice list L6 from 2 to 5 in a new list called L7. Ask the computer the length of L7 with the len() operator. Print it.
Make L8 which is the concatenation of the first element of L6 (position 0) and L7: you must use L8 = [L6[0]] + L7. Print it. Try L8 = L6[0] + L7. Why does it not work?
| Provide the reply here: |
|
|
Concatenate L6 with L8 in L9 and make the sum of all elements using the operator sum().
Find the max and the min of L9 using the operators max() and min().
Apply the split(/) method to the date of today to have the sub-strings of the day, month and year in a list L10.
Write L11 = L10. We know that this is not making a copy of L10. Modify the first element of L10 and check if the change interested L11 (print both L10 and L11). Check the id of both L10 and L11. You should have the same number.
Do a proper copy of L10 to L11 (any of the methods used in slide 2 of lecture 21 as in the picture below). Modify L10 and check that L11 is not changed (print both L10 and L11). Verify the id of both L10 and L11. You should have different numbers.

To get a duplicate copy of 1 ist1 into 1 ist2, you can use: list2 =[x for x in 1ist 1] list2 =[]+ list 1 1 ist2 =1 ist 1copy() list2 = 1ist(1ist 1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
