πŸ“Š Python
Q. What is the output of the following code?
Code:
x = [1, 2, 3]
print(x * 2)
  • (A) [1, 2, 3, 1, 2, 3]
  • (B) [2, 4, 6]
  • (C) Error
  • (D) [1, 2, 3, 2]
πŸ’¬ Discuss
βœ… Correct Answer: (A) [1, 2, 3, 1, 2, 3]

Explanation: Multiplying a list replicates its elements. So [1,2,3] * 2 creates [1,2,3,1,2,3].

Explanation by: Ankit Singh
Multiplying a list replicates its elements. So [1,2,3] * 2 creates [1,2,3,1,2,3].

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
46
Total Visits
πŸ“½οΈ
7 mo ago
Published
πŸŽ–οΈ
Ankit Singh
Publisher
πŸ“ˆ
80%
Success Rate