summaryrefslogtreecommitdiff
path: root/C++_Programming_In_Easy_Steps/Chapter1.ipynb
blob: ba2c8125d30d7572233423a7830381f31a063c42 (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{
 "metadata": {
  "name": "",
  "signature": "sha256:accfa65c82343aeed5f184613989e8f303b6335bf19049dd322738d1012e1aff"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1 : Getting Started"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page No 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"Hello World!\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hello World!\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page No 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "letter = 'A'\n",
      "number = 100\n",
      "decimal = 7.5\n",
      "pi = 3.14159\n",
      "isTrue = \"false\"\n",
      "print \"char letter: \",letter\n",
      "print \"int number: \",number\n",
      "print \"float decimal: \",decimal\n",
      "print \"double pi: \",pi\n",
      "print \"bool isTrue: \",isTrue"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "char letter:  A\n",
        "int number:  100\n",
        "float decimal:  7.5\n",
        "double pi:  3.14159\n",
        "bool isTrue:  false\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3, Page No 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "nums = [1.5,2.75,3.25]\n",
      "name = ['m','i','k','e','\\0']\n",
      "coords = [(1,2,3),(4,5,6)]\n",
      "print \"nums[0]: \",nums[0]\n",
      "print \"nums[1]: \",nums[1]\n",
      "print \"nums[2]: \",nums[2]\n",
      "print \"name[0]: \",name[0]\n",
      "print \"Test stirng: \", \"\".join(name)\n",
      "print \"coords[0][2]: \",coords[0][2]\n",
      "print \"coords[1][2]: \",coords[1][2]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "nums[0]:  1.5\n",
        "nums[1]:  2.75\n",
        "nums[2]:  3.25\n",
        "name[0]:  m\n",
        "Test stirng:  mike\u0000\n",
        "coords[0][2]:  3\n",
        "coords[1][2]:  6\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page No 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# ipython does not support vector array"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5, Page No 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "PI = 3.1415926536\n",
      "print \"6\\\" circle circumference: \" ,(PI * 6)\n",
      "#ENUM IS NOT IN PYTHON SO DECLARED DIRECTLY\n",
      "RED = 1\n",
      "YELLOW = 2\n",
      "GREEN = 3\n",
      "BROWN = 4\n",
      "BLUE = 5\n",
      "PINK = 5\n",
      "BLACK = 6\n",
      "print \"I shot a red worth: \",RED\n",
      "print \"Then a blue worth: \",BLUE\n",
      "print \"Total scored: \",(RED+BLUE)\n",
      "#typedef and enum is not in python so declared directly\n",
      "neutral = \"NEGATIVE \"\n",
      "live = \"POSITIVE\"\n",
      "print \"Neutral wire: \", neutral\n",
      "print \"Live wire: \", live"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "6\" circle circumference:  18.8495559216\n",
        "I shot a red worth:  1\n",
        "Then a blue worth:  5\n",
        "Total scored:  6\n",
        "Neutral wire:  NEGATIVE \n",
        "Live wire:  POSITIVE\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}