diff options
Diffstat (limited to 'computer_concepts_and_c_programming/chapter6.ipynb')
-rwxr-xr-x | computer_concepts_and_c_programming/chapter6.ipynb | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/computer_concepts_and_c_programming/chapter6.ipynb b/computer_concepts_and_c_programming/chapter6.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/computer_concepts_and_c_programming/chapter6.ipynb @@ -0,0 +1,161 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "6:CONSTANTS,VARIABLES"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "6.3.1,page number:140"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "m=4\n",
+ "n=6\n",
+ "p=8\n",
+ "result = m+n\n",
+ "print \"m+n=\",result\n",
+ "result = int (m/n)\n",
+ "print \"m/n=\",result\n",
+ "result = m*p\n",
+ "print \"m*p=\",result"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "m+n= 10\n",
+ "m/n= 0\n",
+ "m*p= 32\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "6.3.2,page number:141"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "m = 4\n",
+ "n = 6\n",
+ "p = 8\n",
+ "result= round(m+n-p*m+p/n,0)\n",
+ "print \"m=\",m,\",n=\",n,\",p=\",p\n",
+ "print \"m + n - p * m + p / n = \",result"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "m= 4 ,n= 6 ,p= 8\n",
+ "m + n - p * m + p / n = -21.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "6.3.3,page number:142"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "m = 4\n",
+ "n = 6\n",
+ "print \" 6 mod 4 = \",n%m\n",
+ "print \"The modulus operator is : %\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 6 mod 4 = 2\n",
+ "The modulus operator is : %\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "6.3.4,page number:142"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "m = -4\n",
+ "n = 6\n",
+ "p = 8\n",
+ "print \"m=\",m,\" n=\",n,\" p=\",p\n",
+ "print \"gives\"\n",
+ "m=-m\n",
+ "n=-n\n",
+ "p=-p\n",
+ "print \"m=\",m,\" n=\",n,\" p=\",p"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "m= -4 n= 6 p= 8\n",
+ "gives\n",
+ "m= 4 n= -6 p= -8\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |