반응형
[문제]
STDIN과 반복문을 연습하는 문제입니다. 정수 n이 입력되면, 0부터 순차적으로 n개의 정수가 num[]에 담깁니다.
이후 num[]에 담긴 숫자들의 제곱값이 순차적으로 출력돼야 합니다.
예시)
입력값 :
5
출력값:
0
1
4
9
16
[코드]
if __name__ == '__main__':
n = int(input())
num = []
for i in range (n):
num.append(i)
for i in range (n):
print(pow(i, 2))
* 문제 출처 (Prepare > Python > Introduction > Loops)
HackerRank
HackerRank is the market-leading technical assessment and remote interview solution for hiring developers. Learn how to hire technical talent from anywhere!
www.hackerrank.com
반응형
'코딩 공부방 👩💻👨💻 > 알고리즘' 카테고리의 다른 글
[Python] 해커랭크(HackerRank) : Print Function (0) | 2023.02.18 |
---|---|
[Python] 해커랭크(HackerRank) : Write a function (0) | 2023.02.17 |
[Python] 해커랭크(HackerRank) : Python: Division (0) | 2023.02.15 |
[Python] 해커랭크(HackerRank) : Arithmetic Operators (0) | 2023.02.14 |
[Python] 해커랭크(HackerRank) : Python If-Else (0) | 2023.02.13 |
댓글