#1차시 리스트 점 표기점
#append() 리스트 맨 뒤에 추가
#리스트.append(추가할 원소)
a = [1, 2, 3]
a.append(4)
print(a)

#insert() 원하는 곳에 추가
#리스트.insert(추가할 위치,추가할 원소)
b = [1, 2, 4, 5]
b.insert(2, 'a')
print(b)

#remove() 원하는 값을 삭제
#리스트.remove(삭제할 원소)
c = [3, 1, 2, 3]
c.remove(3)
print(c)

#sort() 순서대로 정리 - 사전순(abc,가나다),오름차순123
#문자는 문자끼리, 숫자는 숫자끼리만 가능
#리스트.sort()
d = [3, 5, 8, 1, 2]
d.sort()
print(d)

#2차시 시퀀스
#시퀀스 자료형:순서가 있는 자료형 -문자열,리스트
'''
시퀀스 자료형 특징
1. 원소에 순서가 있다 - 인덱싱, 슬라이싱
2. 특정 원소를 조회할 수 있다 - in
    #기본형: 조회할 원소 in 시퀀스
3. 원소의 길이를 확인할 수 있다 - len(시퀀스)
4. 연결 연산을 할 수 있다 +
5. 반복 연산을 할 수 있다 *
'''
print('hi' * 3)
d = ['bye'] * 5
print(d)


#3차시 반복문 for
#기본형: for 변수 in 시퀀스:
#           <반복할 명령>
#시퀀스의 길이만큼 반복된다
for i in '가나다':
    print(i)

#range(시작,종료 미만) :연속된 숫자로 이루어진 시퀀스를 만들어 준다
#구간(숫자)가 중요
for i in range(5, 10):
    print(i)

#횟수가 중요
for i in range(5):
    print(i)

sum = 0
for i in range(1, 11):
    sum = sum + i
    print(sum)


#4차시 반복문 while
#while문 : 조건이 참True인 동안 명령을 계속 반복
'''
기본형
while 조건:
    반복할 명령
'''
i = 3
while i > 0:
    print(i)
    i = i - 1 

print('땡!')
print(i) #최종 i는 0이 된다


#5차시 반복문 break 
#break : 반복문을 강제로 멈추게 하는 명령어
i = 0
while True:
    print('+')
    if i >= 3:
        break
    i = i + 1
print(i)

#for : 몇 번 반복할지 미리 알고 있을 때
#while : 몇 번 반복할지 모를 때






Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: