#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 = [1, 2, 3, 4, 2]
c.remove(2)
print(c)

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


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

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

sum = 0
for i in [3, 6, 9]:
    sum = sum + i
    print(sum)

#4차시 반복문 range
#range(a,b) : a부터 b미만까지의 자연수를 가진 시퀀스
#숫자가 중요
for i in range(5,10):
    print(i)

#숫자보다 횟수가 중요
for i in range(5):
    print(i)

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

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


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

print(i)

#while : 반복 횟수를 모를 때 사용
#for : 반복 횟수를 알고 있을 때 사용

total = 0
num = 1
while True:
    if total + num >= 100:
        break
    total = total + num
    num = num + 1
print('총합', total, '횟수', num)

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



Embed on website

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