#리스트 list [] 여러 개의 값을 묶어서 저장하는 자료형
list1 = [1, 2.3, 'a', [6, 7], 5, "가"]
print(list1)
#리스트 인덱싱 : 리스트[인덱스 번호]
print(list1[0]) #인덱스 번호는 0번부터 시작
print(list1[-3])
print(list1[-3][0]) #중첩 인덱싱
#리스트 슬라이싱 : 리스트[시작 인덱스:종료 인덱스]
# 리스트[start:end:step]
#종료 인덱스는 항상 미만
list2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(list2[3:7])
print(list2[1:9:2])
print(list2[:5]) #처음부터
print(list2[5:]) #끝까지
print(list2[::])
print(list2[5:1:-1])
print(list2[-1:-8:-3])
#리스트 원소 바꾸기
#리스트[인덱스] = 값
list1[2] = 'apple'
print(list1)
#리스트 메서드
print(sum(list2))
print(len(list1))
#리스트.append(추가할 원소) : 리스트 맨 뒤에 추가
a = [1, 2, 3]
a.append('b')
print(a)
#리스트.insert(추가할 위치, 추가할 원소) : 원하는 위치에 추가
a.insert(2, 'i')
print(a)
#리스트.remove(삭제할 원소)
b = [3, 1, 2, 3, 2]
b.remove(3)
print(b)
#리스트.sort() : 순서대로 정렬
c = [3, 1, 5, 8, 2, 9, 6, 1, 3, 7]
c.sort() #오름차순
print(c)
d = ['다', 'a', 'c', '가', '나', 'b']
d.sort() #사전순
print(d)
print('----문제----')
scores = [75, 100, 82, 90, 68, 88]
#1. 오름차순 정렬
scores.sort()
print(scores)
#2. 최고 점수와 최저 점수 출력
high = scores[-1]
low = scores[0]
print(max(scores))
print(min(scores))
#3. 최고 점수와 최저 점수 제거
scores.remove(high)
scores.remove(max(scores))
print(scores)
#4. 남은 점수의 평균 계산
average = sum(scores) / len(scores)
print('평균 :', average)
To embed this project on your website, copy the following code and paste it into your website's HTML: