We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hey, to understand this code, it'll input a number. Then, you uses a 'for' loop to go through numbers from 0 up to the number they entered. Inside the loop, it squares each number using the '**' operator and prints the result. So, each printed number is the square of the corresponding iteration number in the loop.
for i in range(0, n):
print(i**2)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Loops
You are viewing a single comment's thread. Return to all comments →
Hey, to understand this code, it'll input a number. Then, you uses a 'for' loop to go through numbers from 0 up to the number they entered. Inside the loop, it squares each number using the '**' operator and prints the result. So, each printed number is the square of the corresponding iteration number in the loop.
for i in range(0, n): print(i**2)