#시퀀스 자료형 : 순서가 있는 자료형 - 문자열, 리스트, 튜플
'''
시퀀스 자료형 특징
1. 원소에 순서가 있다
2. 어떤 원소를 찾을 수 있다
3. 원소의 길이를 확인할 수 있다
4. 연결 연산을 할 수 있다
5. 반복 연산을 할 수 있다
'''
#1. 원소에 순서가 있다 - 인덱싱, 슬라이싱
t1 = 'hello'
print(t1[4])
print(t1[-3])
print(t1[1:3])

#2. 어떤 원소를 찾을 수 있다 - in
#찾고 싶은 거 in 시퀀스
class2 = ['김담미', '강다인', '황수경']
print('김담미' in class2)

print('ie' in 'time')

print('----문제----')
#좋아하는 과일을 3개 이상 입력해서 리스트에 저장하세요.
fruits = ['melon', 'apple', 'watermelon', 'raspberry']
#두 번째로 입력한 과일을 인덱스를 이용해서 출력하세요.
print(fruits[1])
#'사과' 가 fruits 리스트 안에 있는지 확인하세요.
print('apple' in fruits)

#3. 원소의 길이를 확인할 수 있다 - len(시퀀스)
print(len(fruits))
print(len(class2))
print(len('. apple가'))
print(len('afdgukaeswhyf o8vurqij ㄴ오래머람며샻'))

#4. 연결 연산을 할 수 있다 +
print('안녕' + '하세요' + '2')
print(['a', 'b'] + [1, 2])

#5. 반복 연산을 할 수 있다 *
print('hi' * 3)
print(['bye'] * 5)
print(class2 * 2)

print('----문제----')
# fruits라는 리스트에 ['orange', 'grape']를 연결(+) 하여 fruits를 업데이트
fruits = fruits + ['orange', 'grape']
print(fruits)

# 총 과일 개수 출력
print(len(fruits))

# "Thank you! "라는 문장을 3번 반복해서 출력
print('Thank you! ' * 3)

Embed on website

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