for문
-
Python Chapter05방뚝딱 학습노트 2023. 10. 17. 12:25
교재 : 멘토씨리즈 파이썬 비시퀀스와 for문 - 126P 예제1) 실행 할때마다 순서가 변경된다. 예제2) 예제3) 예제4) 예제5) 예제6) 기타 제어문 - 134p break문은 while문이나 for문과 같은 반복문을 강제로 종료하고자 할때 사용하는 제어문 입니다. 반복문 내에 break가 나타나면 곧바로 break문이 포함된 반복문은 종료됩니다. 0이 되었을 때 종료해준다. 예제) continue - 138p continue는 만나면 반복문의 조건식으로 이동합니다. continue 이용하는 경우 1. 반복에서 제외시킬 때 ex)1~100까지 더하는 데 3의 배수는 제외하고 더하기 2. 중복 체크 같은 단어나 숫자를 받으면 리스트에 추가하지 않고 조건식으로 돌아가기 예제) 예제) 예제)
-
Python Chapter04방뚝딱 학습노트 2023. 8. 11. 22:27
교재 : 멘토씨리즈 파이썬 while문의 중첩 while문의 내부에 또다른 while 문이 나타나는 것을 while문의 중첩이라고 한다.반복해서 처리해야하는 대상이 2개 이상이면 while문의 중첩이 필요하다. 예제1) 총 5일 동안 하루에 3시간씩 수업을 한다. 예제2) 구구단 2~9단까지 출력 예제3) 예제4) 1부터 100사이의 모든 정수 중에서 7의 배수만 출력하는 프로그램을 구현하세요 예제5) 컬렉션(39p) ‘모음’이라는 뜻으로 파이썬에서는 여러값을 묶어서 관리하는 자료형입니다. 리스트(list) 추가, 수정, 삭제가 언제나 가능 append - 첫번째 값을 지움, insert(인덱스, 값) pop(인덱스) - 인덱스를 쓰지 않으면 맨 뒤에 값을 지움 a =[1,2,3] 튜플(tupe) 저장된..