Skip to content

Commit b0ef059

Browse files
committed
Tuple EX ADDED
1 parent 27aa020 commit b0ef059

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

Tuples.ipynb

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,100 @@
77
"### Tuples "
88
]
99
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 4,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"P = (1,2,3)"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 5,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"data": {
26+
"text/plain": [
27+
"(1, 2, 3)"
28+
]
29+
},
30+
"execution_count": 5,
31+
"metadata": {},
32+
"output_type": "execute_result"
33+
}
34+
],
35+
"source": [
36+
"P"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 6,
42+
"metadata": {},
43+
"outputs": [
44+
{
45+
"data": {
46+
"text/plain": [
47+
"1"
48+
]
49+
},
50+
"execution_count": 6,
51+
"metadata": {},
52+
"output_type": "execute_result"
53+
}
54+
],
55+
"source": [
56+
"P[0]"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 7,
62+
"metadata": {},
63+
"outputs": [
64+
{
65+
"ename": "TypeError",
66+
"evalue": "'tuple' object does not support item assignment",
67+
"output_type": "error",
68+
"traceback": [
69+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
70+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
71+
"\u001b[1;32m<ipython-input-7-432031e520b2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mP\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'NEW'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
72+
"\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
73+
]
74+
}
75+
],
76+
"source": [
77+
"P[0] = 'NEW'"
78+
]
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": 8,
83+
"metadata": {},
84+
"outputs": [
85+
{
86+
"name": "stdout",
87+
"output_type": "stream",
88+
"text": [
89+
"cherry\n",
90+
"apple\n",
91+
"banana\n",
92+
"apple\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"thistuple = (\"apple\", \"banana\", \"cherry\")\n",
98+
"print(thistuple[-1])\n",
99+
"print(thistuple[-0])\n",
100+
"print(thistuple[-2])\n",
101+
"print(thistuple[-3])"
102+
]
103+
},
10104
{
11105
"cell_type": "code",
12106
"execution_count": null,

0 commit comments

Comments
 (0)