Comprehensions and functional programming · 6 / 15 Exercise Easy

Squares with a comprehension

Objective

Create a Python program that generates the squares of the first numbers with a list comprehension.

Instructions

  • Read an integer n.
  • Build with a list comprehension the list of the squares of the numbers from 1 to n.
  • Show the list on a single line, with the values separated by a space.
Input
5
Output
1 4 9 16 25

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise