a=[1,2,3] a=a*2 .print (a)
Answers
Answered by
4
Answer:
(2,3)
Explanation:
Tuple slicing exists and a[1:-1] returns (2,3).
Answered by
0
The output of the given code is [1, 2, 3, 1, 2, 3]
- The given code segment is written in Python. 'a' is a variable defining the array, containing three elements.
- In Python, when we multiply the objects by any number, the contents in the object gets increased by that many times.
- For example, if we wrote print("Hello" * 5) in Python, the word 'Hello' will be printed 5 times.
- Same thing happens here in the given code segment, when the variable 'a' is multiplied by 2, the elements in the variable 'a', gets doubled.
- So, each element is doubled, and appended to the original array. Creating an array of 6 elements in the order, [1,2,3,1,2,3].
Hence, the output of the given code is [1, 2, 3, 1, 2, 3]
#SPJ3
Similar questions