1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
"metadata": {
"name": "Chapter 21"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": "Chapter 21: C's dustier corners"
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": "Example 21.1, Page number: 401"
},
{
"cell_type": "code",
"collapsed": false,
"input": "# Example 21.1.py\n# To check whether the character input by the user is for 'add', 'delete' or 'quit'\n\n\n# Variable declaration\nimport sys\nline = 'a'\n\n# Calculation and result\nif (line == 'a') :\n print ('Add\\n')\nelif (line == 'd') :\n print ('Delete\\n')\nelif (line == 'q') :\n print ('Quit\\n')\n sys.exit(1) \nelse :\n print ('Error:Bad command %c\\n' % line)",
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "Add\n\n"
}
],
"prompt_number": 1
}
],
"metadata": {}
}
]
}
|