Loops Python Hackerrank solution

Admin

Loops Python Hackerrank solution

 

Task
The provided code stub reads and integer, n from STDIN. For all non-negative integers i < n print i2.

Example

n = 3

The list of non-negative integers that are less than n = 3  is [ 0,1,2 ]. Print the square of each number on a separate line.

0
1
4

Input Format

The first and only line contains the integer, n.

Constraints

1 ≤ n ≤ 20

Output Format

Print n lines, one corresponding to each i.

Sample Input 0

5

Sample Output 0

0
1
4
9
16

Solution

n = int(input())

for i in range(n):
    print i ** 2

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.