Computer Science
Consider the following code and predict the result of the following statements.
bieber = ['om', 'nom', 'nom']
counts = [1, 2, 3]
nums = counts
nums.append(4)
- counts is nums
- counts is add([1, 2], [3, 4])
Python
Python List Manipulation
12 Likes
Answer
- Output is True as both nums and counts refer to the same list.
- This will cause an error as add function is not defined in the above code.
Answered By
5 Likes
Related Questions
Complete the code to create a list of every integer between 0 and 100, inclusive, named nums1 using Python, sorted in increasing order.
Let nums2 and nums3 be two non-empty lists. Write a Python command that will append the last element of nums3 to the end of nums2.
What is the output of the following code?
numbers = list(range(0, 51, 4)) results = [] for number in numbers: if not number % 3: results.append(number) print(results)
Following code prints the given list in ascending order. Modify the code so that the elements are printed in the reverse order of the result produced by the given code.
numbers = list(range(0, 51, 4)) i = 0 while i < len(numbers): print(numbers[i] , end = " ") i += 3 # gives output as : 0 12 24 36 48