'while'에 해당되는 글 1건

###while

while 조건식: 변수를 넣을경우 미리 선언해주어야 한다 조건식이 True 이면 명령문 실행
    i+=1 조건식의 조건을 바꿔줄 무언가 i를 조건식에 사용하였을경우 값을 변경하며 False 가될수 있도록 한다
while i < len(변수명)   변수의 크기만큼 돌린다
    break   while를 빠져나옴
    continue   다음while을 시작함

### while len 

scores = [100, 95, 88, 98]
toatal =0
cnt = len(scores)
i =0

while i < cnt:
	total += scores[i]
    i += 1 
    
print("총점: {0]}".format(total))

### break

answer = ""

while True:
	answer = input()
    if answer == "q":
    	break
    print("'{0}'를 입력하셨습니다.".format(answer))
    
#'q'를 입하셨습니다.

 

'+++++SW 일일 공부+++++ > SW Expert Aademy' 카테고리의 다른 글

Python 가위바위보  (0) 2020.01.07
Python 함수 개념  (0) 2020.01.06
Python for문  (0) 2020.01.05
Python 주석 달기  (0) 2020.01.04
Python If문  (0) 2020.01.04
블로그 이미지

Or71nH

,