πPython
Welcome to Python : νν μλ£ν
4:Bee
2023. 7. 8. 20:48
728x90
- λ¬Έμμ΄ μλ£ν : https://hi-code.tistory.com/110
- 리μ€νΈ μλ£ν : https://hi-code.tistory.com/111
- νν μλ£ν : https://hi-code.tistory.com/112
- λμ λ리 μλ£ν : https://hi-code.tistory.com/113
- μ§ν© μλ£ν : https://hi-code.tistory.com/114
| Title | Code | Console |
| νν μλ£ν | ||
| νν μμκ° μμ |
#ννμ μμκ°μ ν λ² μ ν΄μ§λ©΄ μ§μ°κ±°λ λ³κ²½ν μ μλ€. t1 = (1,2,'a','b')
del t1[0]
t1 = (1,2,'a','b')
t1[0] = 'c'
|
Traceback (most recent call last): File "...Quiz.py", line 2, in <module> del t1[0] TypeError: 'tuple' object doesn't support item deletion |
| νν μμκ° λ³κ²½ | Traceback (most recent call last): File "...Quiz.py", line 6, in <module> t1[0] = 'c' TypeError: 'tuple' object does not support item assignment |
|
| ννμ μμκ°μ ν λ² μ ν΄μ§λ©΄ μ§μ°κ±°λ λ³κ²½ν μ μλ€. | ||
| νν μΈλ±μ± |
t1 = (1, 2, 'a', 'b') print(t1[0])
|
1 |
| νν μ¬λΌμ΄μ± |
t1 = (1, 2, 'a', 'b') print(t1[1:])
|
(2, 'a', 'b') |
| νν λνκΈ° |
t1 = (1, 2, 'a', 'b') t2 = (3, 4)
t3 = t1 + t2
print(t3)
|
(1, 2, 'a', 'b', 3, 4) |
| νν κ³±νκΈ° |
t2 = (3, 4)
t3 = t2 * 3
print(t3)
|
(3, 4, 3, 4, 3, 4) |
| νν κΈΈμ΄ κ΅¬νκΈ° |
t1 = (1, 2, 'a', 'b') print(len(t1))
|
4 |
728x90