From 92cca121f959c6616e3da431c1e2d23c4fa5e886 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Tue, 7 Apr 2015 15:58:05 +0530 Subject: added books --- .../Chapter2.ipynb | 239 +++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100755 C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb (limited to 'C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb') diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb new file mode 100755 index 00000000..2f3c44af --- /dev/null +++ b/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb @@ -0,0 +1,239 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:622f2c579033e8c66b476e16d61ce8bfa6745f6b87c5905b2064108fa5218b3c" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 PRIMARY DATA TYPES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1, Page No. 32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x=-4443\n", + "y=554.21\n", + "c='M'\n", + "\n", + "print \"The value of integer variable x is\" , x\n", + "print \"The value of float variable y is \" , y\n", + "print \"The value of character variable c is \" , c" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of integer variable x is -4443\n", + "The value of float variable y is 554.21\n", + "The value of character variable c is M\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2, Page No. 36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "x = 20\n", + "PI = 3.14\n", + "print \"Constant values are \",x ,\" and \", round(PI,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constant values are 20 and 3.14\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3, Page No. 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"\\t Adder Program, by Michael Vine\"\n", + "iOperand1=int(raw_input(\"Enter First Operand: \"))\n", + "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n", + "print \"The final result is \", iOperand1+iOperand2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t Adder Program, by Michael Vine\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter First Operand: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Second Operand: 7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The final result is 12\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4, Page No. 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"\\t Adder Program, by Michael Vine\"\n", + "iOperand1=int(raw_input(\"Enter First Operand: \"))\n", + "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n", + "iResult=iOperand1+iOperand2\n", + "print \"The result is \", iResult" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t Adder Program, by Michael Vine\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter First Operand: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Second Operand: 7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The result is 12\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5, Page No. 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "fRevenue=float(raw_input(\"Enter total revenue: \"))\n", + "fCost=float(raw_input(\"Enter total cost: \"))\n", + "print \"Your total profit is \", round(fRevenue-fCost,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter total revenue: 4000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter total cost: 750\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Your total profit is 3250.0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit