"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"#Variable declaration\n",
"i = 3\n",
"j = 1.5\n",
"k = 'c'\n",
"\n",
"print \"Value of i = \", i \n",
"print \"Value of j = \", j \n",
"print \"Value of k = \", k \n",
"\n",
"#addresses of the variables\n",
"x = id(i)\n",
"y = id(j)\n",
"z = id(k)\n",
"\n",
"print \"Original address in x = \", x \n",
"print \"Original address in y = \", y \n",
"print \"Original address in z = \", z \n",
"\n",
"x += 2\n",
"y += 4\n",
"z += 1\n",
"\n",
"print \"New address in x = \", x \n",
"print \"New address in y = \", y \n",
"print \"New address in z = \", z \n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Value of i = 3\n",
"Value of j = 1.5\n",
"Value of k = c\n",
"Original address in x = 32529512\n",
"Original address in y = 105587440\n",
"Original address in z = 32744192\n",
"New address in x = 32529514\n",
"New address in y = 105587444\n",
"New address in z = 32744193\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"#Variable declaration\n",
"stud = [] #array\n",
"\n",
"#for i in range(0,4):\n",
" # stud.append((raw_input(\"Enter roll no and marks: \").split())) # storing data in the 2D array\n",
"\n",
"stud = [\"1 38\",\"2 78\",\"3 93\",\"4 48\"]\n",
"for i in range (0,4):\n",
" print \"Enter roll no and marks: \"\n",
" print stud[i]\n",
" \n",
"#Result\n",
"for i in range(0,4):\n",
" print stud[i][0],stud[i][1:] \n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Enter roll no and marks: \n",
"1 38\n",
"Enter roll no and marks: \n",
"2 78\n",
"Enter roll no and marks: \n",
"3 93\n",
"Enter roll no and marks: \n",
"4 48\n",
"1 38\n",
"2 78\n",
"3 93\n",
"4 48\n"
]
}
],
"prompt_number": 19
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"