본문으로 바로가기

 

 

Print Function

if __name__ == '__main__':
    n = int(input())
    for i in range(1, n+1):
        print(i, end="")

 

해설

range함수와 print함수의 파라미터(end)설정을 통한 프로그래밍이다.

 

range

https://bohemihan.tistory.com/entry/HackerRank-Python-Solution-Loops

 

HackerRank Python Solution / Loops

Loops if __name__ == '__main__': n = int(input()) for i in range(n): print(i*i) 해설 반복문과 숫자형연산자를 활용한 프로그래밍이다. for문 >>> a = "aBc" >>> for c in s: ... print(s) ... aBc aBc aBc..

bohemihan.tistory.com

 

print

https://bohemihan.tistory.com/entry/HackerRank-Python-Solution-Hello-World?category=986077

 

HackerRank Python Solution / "Hello World!"

Say "Hello, World!" With Python >>> print("Hello, World!") Hello, World! 해설 print함수를 이용하여 Hello, World!를 출력한다 print # print(value(s), sep= ‘ ‘, end = ‘\n’) >>> print("삼성") >..

bohemihan.tistory.com

# print(value(s), sep= ‘ ‘, end = ‘\n’)

# print함수의 파라미터 end의 기본값은 '줄바꿈(‘\n’)'이다 (end를 설정하지 않는 경우) 
>>> n = 3
>>> for i in range(1, n+1):
...    print(i)
1
2
3

>>> n = 3
>>> for i in range(1, n+1):
...     print(i, end='\n')
1
2
3

# print함수의 파라미터 end를 공백("")으로 설정하는 경우
>>> n = 3
>>> for i in range(1, n+1):
...        print(i, end="")
123