ννλΌλ¦¬ μ°μ°νλ λ°©λ²
ννμ λΆλ³μ±(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
λ³μμ μ μ₯νμ΅λλ€.
νν μ°μ° (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
Execution Result