Lecture 강의

Undergraduates 학부 Graduates 대학원 Lecture 역학 Lecture 설계 Lecture IT(IoT, AI) Lecture SAP2000 Lecture 아바쿠스 Lecture 파이썬 Lecture 엑셀 VBA Lecture 마이다스 Lecture 이탭스

[박주민][파이썬과 아두이노] 5. 반복문

작성자 : 박주민

(2024-04-04)

조회수 : 185

youtube:https://www.youtube.com/watch?v=iPY4MxtKAmY

예제 코딩: 반복문.py

 

[박주민][파이썬과 아두이노] 5. 반복문
제목: 문자열과 리스트
6. 반복문
7. while 
    7.1 while
    7.2 brake

8. for
    8.1 for
    8.2 range

Reference     

 

[문제 1]

시험 점수가 과목별 40점 이상이면 통과 미만일시 과락
a = [80, 75, 70, 60, 20, 95]

for b in a:
    if b >= 40:
        print('합격')
    else:
        print('과락')

[문제 2]

1부터 숫자 100까지 출력

a=1
b=101

for c in range(a, b):
    print(c)

a부터 b까지의 합
a=1
b=100
c=0

for d in range(a,b+1):
    c+=d

print(c)

 

[문제 3] 구구단