Skip to Content
Learn
Loops
While you're at it

Inside a while loop, you can do anything you could do elsewhere, including arithmetic operations.

Instructions

1.

Create a while loop that prints out all the numbers from 1 to 10 squared (1, 4, 9, 16, … , 100), each on their own line.

  • Fill in the blank space so that our while loop goes from 1 to 10 inclusive.
  • Inside the loop, print the value of num squared. The syntax for squaring a number is num ** 2.
  • Increment num.
Folder Icon

Take this course for free

Already have an account?