|
79 | 79 | }, |
80 | 80 | { |
81 | 81 | "cell_type": "code", |
82 | | - "execution_count": 8, |
| 82 | + "execution_count": 1, |
83 | 83 | "metadata": {}, |
84 | 84 | "outputs": [ |
85 | 85 | { |
|
96 | 96 | "source": [ |
97 | 97 | "thistuple = (\"apple\", \"banana\", \"cherry\")\n", |
98 | 98 | "print(thistuple[-1])\n", |
99 | | - "print(thistuple[-0])\n", |
| 99 | + "print(thistuple[0])\n", |
100 | 100 | "print(thistuple[-2])\n", |
101 | 101 | "print(thistuple[-3])" |
102 | 102 | ] |
|
107 | 107 | "metadata": {}, |
108 | 108 | "outputs": [], |
109 | 109 | "source": [ |
110 | | - "thistuple = (\"apple\", \"banana\", \"cherry\")" |
| 110 | + "tgyfdfxrdectrs = (\"apple\", \"banana\", \"cherry\")" |
111 | 111 | ] |
112 | 112 | }, |
113 | 113 | { |
114 | 114 | "cell_type": "code", |
115 | | - "execution_count": 10, |
| 115 | + "execution_count": 2, |
116 | 116 | "metadata": {}, |
117 | 117 | "outputs": [ |
118 | 118 | { |
119 | 119 | "name": "stdout", |
120 | 120 | "output_type": "stream", |
121 | 121 | "text": [ |
122 | | - "('cherry', 'orange', 'kiwi')\n" |
| 122 | + "('banana', 'cherry', 'orange', 'kiwi', 'melon')\n" |
123 | 123 | ] |
124 | 124 | } |
125 | 125 | ], |
126 | 126 | "source": [ |
127 | 127 | "thistuple = (\"apple\", \"banana\", \"cherry\", \"orange\", \"kiwi\", \"melon\", \"mango\")\n", |
128 | | - "print(thistuple[2:5])" |
| 128 | + "print(thistuple[1:6])" |
129 | 129 | ] |
130 | 130 | }, |
131 | 131 | { |
132 | 132 | "cell_type": "code", |
133 | | - "execution_count": 11, |
| 133 | + "execution_count": 7, |
134 | 134 | "metadata": {}, |
135 | 135 | "outputs": [ |
136 | 136 | { |
137 | 137 | "name": "stdout", |
138 | 138 | "output_type": "stream", |
139 | 139 | "text": [ |
140 | | - "('cherry', 'orange', 'kiwi')\n" |
| 140 | + "()\n" |
141 | 141 | ] |
142 | 142 | } |
143 | 143 | ], |
144 | 144 | "source": [ |
145 | 145 | "thistuple = (\"apple\", \"banana\", \"cherry\", \"orange\", \"kiwi\", \"melon\", \"mango\")\n", |
146 | | - "print(thistuple[2:5])" |
| 146 | + "print(thistuple[:-7])" |
147 | 147 | ] |
148 | 148 | }, |
149 | 149 | { |
150 | 150 | "cell_type": "code", |
151 | | - "execution_count": 13, |
| 151 | + "execution_count": 9, |
152 | 152 | "metadata": {}, |
153 | 153 | "outputs": [ |
154 | 154 | { |
155 | 155 | "name": "stdout", |
156 | 156 | "output_type": "stream", |
157 | 157 | "text": [ |
158 | | - "['apple', 'kiwi', 'cherry']\n", |
159 | | - "('apple', 'kiwi', 'cherry')\n" |
| 158 | + "['apple', 'kiwi', 'banana', 'cherry']\n", |
| 159 | + "('apple', 'kiwi', 'banana', 'cherry')\n" |
160 | 160 | ] |
161 | 161 | } |
162 | 162 | ], |
163 | 163 | "source": [ |
164 | 164 | "x = (\"apple\", \"banana\", \"cherry\")\n", |
165 | 165 | "y = list(x)\n", |
166 | | - "y[1] = \"kiwi\"\n", |
| 166 | + "\n", |
| 167 | + "y.insert(1,\"kiwi\")\n", |
167 | 168 | "x = tuple(y)\n", |
168 | 169 | "\n", |
169 | 170 | "print(y)\n", |
|
212 | 213 | }, |
213 | 214 | { |
214 | 215 | "cell_type": "code", |
215 | | - "execution_count": 16, |
| 216 | + "execution_count": 3, |
216 | 217 | "metadata": {}, |
217 | | - "outputs": [], |
| 218 | + "outputs": [ |
| 219 | + { |
| 220 | + "ename": "NameError", |
| 221 | + "evalue": "name 'thistuple' is not defined", |
| 222 | + "output_type": "error", |
| 223 | + "traceback": [ |
| 224 | + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
| 225 | + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", |
| 226 | + "\u001b[1;32m<ipython-input-3-7255dda8a7d6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mthistuple\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m\"apple\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"banana\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"cherry\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mdel\u001b[0m \u001b[0mthistuple\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mthistuple\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", |
| 227 | + "\u001b[1;31mNameError\u001b[0m: name 'thistuple' is not defined" |
| 228 | + ] |
| 229 | + } |
| 230 | + ], |
218 | 231 | "source": [ |
219 | 232 | "thistuple = (\"apple\", \"banana\", \"cherry\")\n", |
220 | | - "del thistuple" |
| 233 | + "del thistuple\n", |
| 234 | + "print(thistuple)" |
221 | 235 | ] |
222 | 236 | }, |
223 | 237 | { |
|
0 commit comments