본문 바로가기
프로그램/Python 1000제

Python 73제] 파이썬 EXPRESS p198 01번

by 건티 2022. 4. 29.
728x90

출처 : 반크_세계유산 석굴암

 

참고풀이]

print("1. while Loop로 프로그램 작성하기")
i=0
while i<50:
    i+=1
    if i%2==0:
        print(i,end=" ")
print('\n')

print("2. while Loop로 프로그램 작성하기")
i=0
while i<50:
    i+=2
    print(i,end=" ")
print('\n')

print("3. while Loop로 프로그램 작성하기")
i=0
while True:
    i+=1
    if i>50:
        break
    if i%2==0:
        print(i,end=" ")
print('\n')

print("4. for Loop로 프로그램 작성하기")
for i in range(1,51):
    if i%2==0:
        print(i,end=" ")
print('\n')

print("5. for Loop로 프로그램 작성하기")
for i in range(2,51,2):
    print(i,end=" ")
print('\n')

 

참고풀이 결과]

 

 

 

 

대한민국의 아름다운 영토, 독도

 

반응형

댓글