본문 바로가기

Programming/Python

[ Python note ] 정수 1개 입력받아 나누어 출력

### 1 ###

소스코드

1
2
3
4
5
6
7
8
= str(input())    # a에 문자열로 정수를 입력받음
= len(a)          # a의 길이를 출력함
= ""              # 뒤에 들어갈 "0" 변수임
 
while 0 < b:
    b = b - 1
    print(a[b]+d)
    d = d + "0"
cs

출력 : 1234를 입력

1
2
3
4
5
1234
4
30
200
1000
cs

 

### 2 ###

소스코드

1
2
3
4
5
6
7
8
9
= str(input())
= len(a)
= 0
 
while b != 0:
    d = "0" * int(b-1)
    print("["+a[c]+d+"]")
    c = c + 1
    b = b - 1
cs

출력 : 1234를 입력

1
2
3
4
5
1234
[1000]
[200]
[30]
[4]
cs

'Programming > Python' 카테고리의 다른 글

[ Python M ] colletions의 Counter  (0) 2020.11.01
[ Python M ] 문자열 변환 : maketrans  (2) 2020.11.01
[ Python note ] socket  (0) 2020.09.30
[ Python ] selenium 설치 및 환경설정  (0) 2020.09.25
[ Python ] opencv-python, pyautogui  (0) 2020.08.21