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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
{
"metadata": {
"name": "",
"signature": "sha256:7c8e11b3dcc5781949652c0b5c450d78713cb6e6b69326955d0f763c48805147"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 2, An Introduction to Declarations, Assignments and Variables"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Program 2-1 , Page number: 20"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# An introduction to variable declarations \n",
"\n",
"number = 7 # no need of declaration of variable. Python is dynamically-typed language\n",
"print \"There are %d days in a week.\"%number"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"There are 7 days in a week.\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Program 2-2 , Page number: 21"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# A simple program with two declarations\n",
"\n",
"minutes = 60\n",
"hours = 24\n",
"\n",
"print \"There are %d minutes in an hour.\"%minutes\n",
"print \"And %d hours in a day.\"%hours"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"There are 60 minutes in an hour.\n",
"And 24 hours in a day.\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Program 2-4 , Page number: 22"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# prints values of two variables\n",
"\n",
"dozens = 17\n",
"units = dozens * 12\n",
"\n",
"print \"%d units is equivalent to %d dozen.\"%(units,dozens)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"204 units is equivalent to 17 dozen.\n"
]
}
],
"prompt_number": 3
}
],
"metadata": {}
}
]
}
|