Show More
@@ -1,6 +1,6 b'' | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 | "name": "Frontend-Kernel Model" | |
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -152,6 +152,21 b'' | |||
|
152 | 152 | "cell_type": "code", |
|
153 | 153 | "collapsed": false, |
|
154 | 154 | "input": [ |
|
155 | "# Python 3 compat\n", | |
|
156 | "try:\n", | |
|
157 | " raw_input\n", | |
|
158 | "except NameError:\n", | |
|
159 | " raw_input = input" | |
|
160 | ], | |
|
161 | "language": "python", | |
|
162 | "metadata": {}, | |
|
163 | "outputs": [], | |
|
164 | "prompt_number": 1 | |
|
165 | }, | |
|
166 | { | |
|
167 | "cell_type": "code", | |
|
168 | "collapsed": false, | |
|
169 | "input": [ | |
|
155 | 170 | "name = raw_input(\"What is your name? \")\n", |
|
156 | 171 | "name" |
|
157 | 172 | ], |
@@ -169,13 +184,49 b'' | |||
|
169 | 184 | { |
|
170 | 185 | "metadata": {}, |
|
171 | 186 | "output_type": "pyout", |
|
172 |
"prompt_number": |
|
|
187 | "prompt_number": 2, | |
|
173 | 188 | "text": [ |
|
174 |
" |
|
|
189 | "'Sir Robin'" | |
|
175 | 190 | ] |
|
176 | 191 | } |
|
177 | 192 | ], |
|
178 |
"prompt_number": |
|
|
193 | "prompt_number": 2 | |
|
194 | }, | |
|
195 | { | |
|
196 | "cell_type": "markdown", | |
|
197 | "metadata": {}, | |
|
198 | "source": [ | |
|
199 | "**Python 2-only**: the eval input works as well (`input` is just `eval(raw_input(prompt))`)" | |
|
200 | ] | |
|
201 | }, | |
|
202 | { | |
|
203 | "cell_type": "code", | |
|
204 | "collapsed": false, | |
|
205 | "input": [ | |
|
206 | "fingers = input(\"How many fingers? \")\n", | |
|
207 | "fingers, type(fingers)" | |
|
208 | ], | |
|
209 | "language": "python", | |
|
210 | "metadata": {}, | |
|
211 | "outputs": [ | |
|
212 | { | |
|
213 | "name": "stdout", | |
|
214 | "output_type": "stream", | |
|
215 | "stream": "stdout", | |
|
216 | "text": [ | |
|
217 | "How many fingers? 4\n" | |
|
218 | ] | |
|
219 | }, | |
|
220 | { | |
|
221 | "metadata": {}, | |
|
222 | "output_type": "pyout", | |
|
223 | "prompt_number": 3, | |
|
224 | "text": [ | |
|
225 | "(4, int)" | |
|
226 | ] | |
|
227 | } | |
|
228 | ], | |
|
229 | "prompt_number": 3 | |
|
179 | 230 | }, |
|
180 | 231 | { |
|
181 | 232 | "cell_type": "code", |
@@ -195,13 +246,13 b'' | |||
|
195 | 246 | "output_type": "pyerr", |
|
196 | 247 | "traceback": [ |
|
197 | 248 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", |
|
198 |
"\u001b[1;32m<ipython-input- |
|
|
199 |
"\u001b[1;32m<ipython-input- |
|
|
249 | "\u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", | |
|
250 | "\u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m in \u001b[0;36mdiv\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
|
200 | 251 | "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" |
|
201 | 252 | ] |
|
202 | 253 | } |
|
203 | 254 | ], |
|
204 |
"prompt_number": |
|
|
255 | "prompt_number": 4 | |
|
205 | 256 | }, |
|
206 | 257 | { |
|
207 | 258 | "cell_type": "code", |
@@ -216,7 +267,7 b'' | |||
|
216 | 267 | "output_type": "stream", |
|
217 | 268 | "stream": "stdout", |
|
218 | 269 | "text": [ |
|
219 |
"> \u001b[1;32m<ipython-input- |
|
|
270 | "> \u001b[1;32m<ipython-input-4-a5097cc0c0c5>\u001b[0m(2)\u001b[0;36mdiv\u001b[1;34m()\u001b[0m\n", | |
|
220 | 271 | "\u001b[1;32m 1 \u001b[1;33m\u001b[1;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
221 | 272 | "\u001b[0m\u001b[1;32m----> 2 \u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", |
|
222 | 273 | "\u001b[0m\u001b[1;32m 3 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n", |
@@ -262,7 +313,7 b'' | |||
|
262 | 313 | ] |
|
263 | 314 | } |
|
264 | 315 | ], |
|
265 |
"prompt_number": |
|
|
316 | "prompt_number": 5 | |
|
266 | 317 | } |
|
267 | 318 | ], |
|
268 | 319 | "metadata": {} |
General Comments 0
You need to be logged in to leave comments.
Login now