Skip to content

Commit 0671c1b

Browse files
Add files via upload
1 parent 3b76df2 commit 0671c1b

10 files changed

+2687
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"(1, 2)\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"a = (1,2)\n",
18+
"print(a)"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 2,
24+
"metadata": {
25+
"scrolled": true
26+
},
27+
"outputs": [
28+
{
29+
"name": "stdout",
30+
"output_type": "stream",
31+
"text": [
32+
"<class 'tuple'>\n"
33+
]
34+
}
35+
],
36+
"source": [
37+
"print(type(a))"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": 3,
43+
"metadata": {
44+
"scrolled": true
45+
},
46+
"outputs": [
47+
{
48+
"name": "stdout",
49+
"output_type": "stream",
50+
"text": [
51+
"1\n",
52+
"2\n",
53+
"(1, 2)\n",
54+
"<class 'tuple'>\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"b,c = 1,2\n",
60+
"\n",
61+
"print(b)\n",
62+
"print(c)\n",
63+
"\n",
64+
"e = 1,2\n",
65+
"\n",
66+
"print(e)\n",
67+
"print(type(e))"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": 6,
73+
"metadata": {
74+
"scrolled": true
75+
},
76+
"outputs": [
77+
{
78+
"data": {
79+
"text/plain": [
80+
"1"
81+
]
82+
},
83+
"execution_count": 6,
84+
"metadata": {},
85+
"output_type": "execute_result"
86+
}
87+
],
88+
"source": [
89+
"e = 1,2\n",
90+
"e[0]"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": 8,
96+
"metadata": {
97+
"scrolled": true
98+
},
99+
"outputs": [
100+
{
101+
"data": {
102+
"text/plain": [
103+
"2"
104+
]
105+
},
106+
"execution_count": 8,
107+
"metadata": {},
108+
"output_type": "execute_result"
109+
}
110+
],
111+
"source": [
112+
"e[1]"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": 9,
118+
"metadata": {
119+
"scrolled": true
120+
},
121+
"outputs": [
122+
{
123+
"ename": "IndexError",
124+
"evalue": "tuple index out of range",
125+
"output_type": "error",
126+
"traceback": [
127+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
128+
"\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
129+
"\u001b[1;32m<ipython-input-9-4505f42e6b2f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0me\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
130+
"\u001b[1;31mIndexError\u001b[0m: tuple index out of range"
131+
]
132+
}
133+
],
134+
"source": [
135+
"e[2]"
136+
]
137+
},
138+
{
139+
"cell_type": "code",
140+
"execution_count": 10,
141+
"metadata": {
142+
"scrolled": true
143+
},
144+
"outputs": [
145+
{
146+
"data": {
147+
"text/plain": [
148+
"2"
149+
]
150+
},
151+
"execution_count": 10,
152+
"metadata": {},
153+
"output_type": "execute_result"
154+
}
155+
],
156+
"source": [
157+
"e[-1]"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": 11,
163+
"metadata": {
164+
"scrolled": true
165+
},
166+
"outputs": [
167+
{
168+
"data": {
169+
"text/plain": [
170+
"1"
171+
]
172+
},
173+
"execution_count": 11,
174+
"metadata": {},
175+
"output_type": "execute_result"
176+
}
177+
],
178+
"source": [
179+
"e[-2]"
180+
]
181+
},
182+
{
183+
"cell_type": "code",
184+
"execution_count": 14,
185+
"metadata": {
186+
"scrolled": true
187+
},
188+
"outputs": [
189+
{
190+
"name": "stdout",
191+
"output_type": "stream",
192+
"text": [
193+
"(4, 5, 6)\n",
194+
"(1, 2, 3)\n"
195+
]
196+
}
197+
],
198+
"source": [
199+
"f =(1,2,3,4,5,6)\n",
200+
"\n",
201+
"print(f[3:])\n",
202+
"\n",
203+
"print(f[:3])"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": 15,
209+
"metadata": {
210+
"scrolled": true
211+
},
212+
"outputs": [
213+
{
214+
"ename": "TypeError",
215+
"evalue": "'tuple' object does not support item assignment",
216+
"output_type": "error",
217+
"traceback": [
218+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
219+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
220+
"\u001b[1;32m<ipython-input-15-fd5cf2518571>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m34\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
221+
"\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
222+
]
223+
}
224+
],
225+
"source": [
226+
" f[4]=34"
227+
]
228+
},
229+
{
230+
"cell_type": "code",
231+
"execution_count": 16,
232+
"metadata": {},
233+
"outputs": [],
234+
"source": [
235+
"del f"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": 17,
241+
"metadata": {},
242+
"outputs": [
243+
{
244+
"ename": "NameError",
245+
"evalue": "name 'f' is not defined",
246+
"output_type": "error",
247+
"traceback": [
248+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
249+
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
250+
"\u001b[1;32m<ipython-input-17-a9fcd54b25e7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mf\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
251+
"\u001b[1;31mNameError\u001b[0m: name 'f' is not defined"
252+
]
253+
}
254+
],
255+
"source": [
256+
"f"
257+
]
258+
}
259+
],
260+
"metadata": {
261+
"kernelspec": {
262+
"display_name": "Python 3",
263+
"language": "python",
264+
"name": "python3"
265+
},
266+
"language_info": {
267+
"codemirror_mode": {
268+
"name": "ipython",
269+
"version": 3
270+
},
271+
"file_extension": ".py",
272+
"mimetype": "text/x-python",
273+
"name": "python",
274+
"nbconvert_exporter": "python",
275+
"pygments_lexer": "ipython3",
276+
"version": "3.8.5"
277+
}
278+
},
279+
"nbformat": 4,
280+
"nbformat_minor": 4
281+
}

0 commit comments

Comments
 (0)