0

This is what i have so far:

n=int(input("Enter a number"))

for i in range (1,n+1,):

  if(i%2==0):

    print(i)

So for example, if the user enters 100, the program should print the following:

4
16
36
64
100
TankorSmash
  • 12,186
  • 6
  • 68
  • 106
python-help
  • 1
  • 1
  • 3

1 Answers1

0

The ** operator in python acts as a power operator. So, x-squared is basically x**2, and x**0.5 is square root of x.

n = int(input("Enter a number"))

for i in range(2, n**0.5+1, 2):
    print(i**2)
shad0w_wa1k3r
  • 12,955
  • 8
  • 67
  • 90