From 8e4f9ec414f553746330423a974684bbac2163a8 Mon Sep 17 00:00:00 2001 From: kinitrupti Date: Thu, 15 Oct 2015 17:40:30 +0530 Subject: solved errors --- Schaum's_Outline/ch1.ipynb | 448 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 448 insertions(+) create mode 100755 Schaum's_Outline/ch1.ipynb (limited to 'Schaum's_Outline/ch1.ipynb') diff --git a/Schaum's_Outline/ch1.ipynb b/Schaum's_Outline/ch1.ipynb new file mode 100755 index 00000000..175e4501 --- /dev/null +++ b/Schaum's_Outline/ch1.ipynb @@ -0,0 +1,448 @@ +{ + "metadata": { + "name": "ch1" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1: Elementary C++ Programming" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1, page no. 2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Hello, World!\\n\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello, World!\n", + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2, page no. 3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Hello, World!\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello, World!\n", + "\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3, page no. 4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Hel\" + \"lo, Wo\" + \"rld!\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello, World!\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4, page no. 5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Hello, W\" + 'o' + \"rld\" + '!' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello, World!\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5, page no. 5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"The Millennium ends Dec %d %d \" %(31,2000)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Millennium ends Dec 31 2000 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6, page no. 5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "m = 44 # assigns the value 44 to the variable m\n", + "print \"m = %d \" % m,\n", + "n = m + 33 # assigns the value 77 to the variable n\n", + "print \"and n = %d \" % n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m = 44 and n = 77 \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, page no. 6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "n=44\n", + "print \"n = %d\" % n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "n = 44\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8, page no. 7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Python does not have semicolons so wont give any errors.\n", + "n=44\n", + "print \"n = %d\" % n " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "n = 44\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9, page no. 7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "m = 0 #In python we do not have declaration of variables, we just initialize it and use it.\n", + "n=44\n", + "print \"m = %d and n = %d\" %(m,n)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m = 0 and n = 44\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.10, page no. 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "BEEP = '\\b'\n", + "MAXINT = 2147483647\n", + "N = MAXINT/2\n", + "KM_PER_MI = 1.60934\n", + "PI = 3.14159265358979323846" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.11, page no. 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter two integers: \"\n", + "m = int(raw_input())\n", + "n = int(raw_input())\n", + "print \"m = %d , n = %d \" %(m,n)\n", + "\n", + "print \"Enter three decimal numbers: \"\n", + "x = float(raw_input())\n", + "y = float(raw_input())\n", + "z = float(raw_input())\n", + "\n", + "print \"x = %f , y = %f , z = %f\" %(x,y,z)\n", + "\n", + "print \"Enter four characters: \";\n", + "c1 = raw_input()\n", + "c2 = raw_input()\n", + "c3 = raw_input()\n", + "c4 = raw_input()\n", + "print \"c1 = \" + c1 + \", c2 = \" + c2 + \", c3 = \" + c3 + \", c4 = \" + c4 " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter two integers: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "22\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "44\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m = 22 , n = 44 \n", + "Enter three decimal numbers: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2.2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4.4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6.6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x = 2.200000 , y = 4.400000 , z = 6.600000\n", + "Enter four characters: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "A\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "B\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "D\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c1 = A, c2 = B, c3 = C, c4 = D\n" + ] + } + ], + "prompt_number": 11 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit