Q. How can you generate a list of squares of numbers from 0 to 4?

  • (A) [x**2 for x in range(5)]
  • (B) list(x**2 for x in range(5))
  • (C) Both option1 and option2
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (C) Both option1 and option2
Explanation: Both list comprehension and generator expression passed to list() will produce the list.
Explanation by: Mr. Dubey
Both list comprehension and generator expression passed to list() will produce the list.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
56
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
90%
Success Rate