Search

반복문9_개념01_자리수

대분류
STEP04 일차반복문
소분류
반복문9_개념

영상

개념

''' [문제] 1 ~ 2000 사이의 랜덤숫자를 저장하고, 자리수가 얼마인지 출력하시오. [예시] 969 3자리 수 ''' ''' 969 // 10 = 96 1 96 // 10 = 9 2 9 // 10 = 0 3 ''' import random num = random.randint(1, 2000) print("num = ", num) temp = num count = 0 run = 1 while run == 1: temp = temp // 10 print(temp) count += 1 if temp == 0: run = 0 print(count)
Python
복사