Guidelines

νŠœν”ŒλΌλ¦¬ μ—°μ‚°ν•˜λŠ” 방법

νŠœν”Œμ€ λΆˆλ³€μ„±(immutable)으둜 인해 μ •μ˜λœ μ΄ν›„λ‘œ 값을 λ³€κ²½ν•  수 μžˆμ§€λ§Œ, 이미 μ •μ˜λœ νŠœν”ŒλΌλ¦¬λŠ” +, * μ—°μ‚°μž λ“±μœΌλ‘œ λ¦¬μŠ€νŠΈμ™€ 같이 μ—°μ‚°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.


νŠœν”Œ μ—°κ²°ν•˜κΈ°

+ μ—°μ‚°μžλ₯Ό μ‚¬μš©ν•˜λ©΄ 두 개의 νŠœν”Œμ„ μ—°κ²°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

νŠœν”Œ λ”ν•˜κΈ° μ˜ˆμ‹œ
tuple1 = (1, 2, 3) tuple2 = (4, 5, 6) # νŠœν”Œ λ”ν•˜κΈ° combined_tuple = tuple1 + tuple2 # (1, 2, 3, 4, 5, 6) 좜λ ₯ print("combined_tuple:", combined_tuple)

μœ„ μ˜ˆμ‹œλŠ” tuple1κ³Ό tuple2 νŠœν”Œμ„ + μ—°μ‚°μžλ‘œ μ—°κ²°ν•˜μ—¬ combined_tuple νŠœν”Œμ— μ €μž₯ν–ˆμŠ΅λ‹ˆλ‹€.


νŠœν”Œ λ°˜λ³΅ν•˜κΈ°

* μ—°μ‚°μžλ₯Ό μ‚¬μš©ν•˜λ©΄ νŠœν”Œμ˜ μš”μ†Œλ“€μ΄ μ§€μ •λœ 횟수만큼 λ°˜λ³΅λ©λ‹ˆλ‹€.

νŠœν”Œ κ³±ν•˜κΈ° μ˜ˆμ‹œ
my_tuple = (1, 2, 3) # νŠœν”Œμ„ 2번 반볡 repeated_tuple = my_tuple * 2 # (1, 2, 3, 1, 2, 3) 좜λ ₯ print("repeated_tuple:", repeated_tuple)

μœ„ μ˜ˆμ‹œλŠ” my_tuple νŠœν”Œμ˜ μš”μ†Œλ“€μ„ * μ—°μ‚°μžλ‘œ 2번 λ°˜λ³΅ν•˜μ—¬ repeated_tuple νŠœν”Œμ— μ €μž₯ν–ˆμŠ΅λ‹ˆλ‹€.


νŠœν”Œ 길이 κ΅¬ν•˜κΈ°

len() ν•¨μˆ˜λŠ” νŠœν”Œμ— ν¬ν•¨λœ μš”μ†Œμ˜ 개수λ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.

νŠœν”Œ 길이 κ΅¬ν•˜κΈ° μ˜ˆμ‹œ
my_tuple = (1, 2, 3) # νŠœν”Œμ˜ 길이 κ΅¬ν•˜κΈ° tuple_length = len(my_tuple) print(tuple_length) # 3 좜λ ₯

μœ„ μ˜ˆμ‹œλŠ” my_tuple νŠœν”Œμ˜ 길이λ₯Ό len() ν•¨μˆ˜λ‘œ κ΅¬ν•˜μ—¬ tuple_length λ³€μˆ˜μ— μ €μž₯ν–ˆμŠ΅λ‹ˆλ‹€.

Mission
0 / 1

νŠœν”Œ μ—°μ‚° (1, 2, 3) + (4, 5)의 결과둜 μ˜¬λ°”λ₯Έ 것은 λ¬΄μ—‡μΌκΉŒμš”?

(5, 7, 3)
(4, 5, 6, 1, 2, 3)
(1, 2, 3, 4, 5)
(1, 2, 3, 9)

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result