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