Ask Question
21 August, 20:16

Assume the list numbers1 has 100 elements, and numbers2 is an empty list. Write code that copies the values in numbers1 to numbers2.

+4
Answers (1)
  1. 21 August, 22:11
    0
    numbers1 = [5]*100

    numbers2 = numbers1[:]

    print (numbers2)

    Explanation:

    We have used the Python programming language to solve this problem. First we created a list to have 100 elements line 1, numbers1 = [5]*100, This statement creates a list that has 100 elements (the integer 5). In line two, we assign the elements in the the first list to the second list numbers2, notice the full colon in the statement numbers2 = numbers1[:], This allows the elements of the first list to be copied into the second list and on line 3, we printout the the second list.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume the list numbers1 has 100 elements, and numbers2 is an empty list. Write code that copies the values in numbers1 to numbers2. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers