diff options
author | hardythe1 | 2015-04-07 15:58:05 +0530 |
---|---|---|
committer | hardythe1 | 2015-04-07 15:58:05 +0530 |
commit | 92cca121f959c6616e3da431c1e2d23c4fa5e886 (patch) | |
tree | 205e68d0ce598ac5caca7de839a2934d746cce86 /Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb | |
parent | b14c13fcc6bb6d01c468805d612acb353ec168ac (diff) | |
download | Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.gz Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.bz2 Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.zip |
added books
Diffstat (limited to 'Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb')
-rwxr-xr-x | Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb | 420 |
1 files changed, 420 insertions, 0 deletions
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb new file mode 100755 index 00000000..e40c1b43 --- /dev/null +++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb @@ -0,0 +1,420 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:5d85b398d61f498d1deba465b9747c5d15996be1754212b25012ca792b193a16" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 08 : Function Prototypes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Function with no arguments and no return values" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 1, Page No.: 5.55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program to addition of two numbers\n", + "\n", + "def add():\n", + " a,b=input(\"Enter two numbers.. \")\n", + " c=a+b\n", + " print \"Sum is ... %d\"%(c)\n", + " \n", + "add() \n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter two numbers.. 10,20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is ... 30\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 2, Page No.:5.56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program to print addition, subtraction and multiplication values\n", + "\n", + "def add():\n", + " a=10\n", + " b=5\n", + " print \"The Addition of given value: \",a+b\n", + " \n", + "def sub():\n", + " a=10\n", + " b=5\n", + " print \"The Subtraction of given value:\",a-b\n", + " \n", + "def mul():\n", + " a=10\n", + " b=5\n", + " print \"The Multiplication of given value:\",a*b\n", + " \n", + " \n", + "add()\n", + "sub()\n", + "mul()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Addition of given value: 15\n", + "The Subtraction of given value: 5\n", + "The Multiplication of given value: 50\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Function with arguments and no return values" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 1, page No. 5.57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Program for addition of two numbers\n", + "\n", + "def add(x,y):\n", + " z= x+y\n", + " print \"Sum is:\", z\n", + "\n", + "#Main Function\n", + "a, b = input(\"Enter two Values: \")\n", + " \n", + "add(a,b)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter two Values: 10,20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is: 30\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + " Example: 2, page no. 5.58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def date(x,y,z):\n", + " print \"Employee Joined date is:%d/%d/%d\" %(x,y,z)\n", + " \n", + "print \"Enter the employee joining date.\"\n", + "\n", + "dd,mm,yy=eval(raw_input(\"Enter date, month, year: \"))\n", + "\n", + "date(dd,mm,yy)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the employee joining date.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter date, month, year: 11,12,1981\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Employee Joined date is:11/12/1981\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Function with arguments and with return value" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 1, page no.5.59" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program for addition of two numbers\n", + "\n", + "def add(x,y):\n", + " z=0\n", + " z=x+y\n", + " return z\n", + "\n", + "#Main Function\n", + "a,b=input(\"Enter the a and b value:\")\n", + "c=add(a,b)\n", + "print \"Result is:\",c" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the a and b value:10,20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result is: 30\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 2, Page No.:5.60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program to send and receives the values from function\n", + "\n", + "def mul(m,n):\n", + " return (m*n)\n", + "\n", + "m=n=sum=0\n", + "m,n=input(\"Enter two values:\")\n", + "sum=mul(m,n)\n", + "\n", + "print \"Multiplication of the entered Values:\",sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter two values:30,4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Multiplication of the entered Values: 120\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Function with no arguments and with return value" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 1, PageNo.:5.61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program for addition of two numbers\n", + "\n", + "def add():\n", + " a=b=c=0\n", + " a,b=input(\"Enter the Values of a and b:\")\n", + " c=a+b\n", + " return(c)\n", + "\n", + "c=add()\n", + "print \"The Output of given Values:\",c\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Values of a and b:10,20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Output of given Values: 30\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example: 2, Page No. 5.62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Program to multiply three numbers using function\n", + "\n", + "\n", + "def mul():\n", + " a,b,c=input(\"Enter the three values for Multiplication: \")\n", + " i=a*b*c\n", + " return(i)\n", + "\n", + "s=mul()\n", + "print \"Multiplication of three numbers is= \",s\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the three values for Multiplication: 4,8,2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Multiplication of three numbers is= 64\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |