{ "metadata": { "name": "Chapter III" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": "Chapter 3: Compiling and running your first program" }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.1, Page number: 11" }, { "cell_type": "code", "collapsed": false, "input": "#3.1.py\n#first Python Program\n\n#Print Statement\nprint(\"Programming is Fun.\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Programming is Fun.\n" } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.2, Page number: 14" }, { "cell_type": "code", "collapsed": false, "input": "#3.2.py\n#Writing Your First C Program(Version2)\n\n#Print statement\nprint(\"Programming is Fun.\")\nprint(\"And Programming in Python is even more fun\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Programming is Fun.\nAnd Programming in Python is even more fun\n" } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.3, Page number: 14" }, { "cell_type": "code", "collapsed": false, "input": "#3.3.py\n#Displaying multiple Lines of output\n\n#Print statements using escape sequence\nprint(\"Testing...\\n..1\\n...2\\n....3\\n\")", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "Testing...\n..1\n...2\n....3\n\n" } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.4, Page number: 15" }, { "cell_type": "code", "collapsed": false, "input": "#3.4.py\n#Displaying Variables\n \nsum=50+25\nprint(\"The sum of 50 & 25 is: {0} \".format(sum))", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "The sum of 50 & 25 is: 75 \n" } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.5, Page number: 16" }, { "cell_type": "code", "collapsed": false, "input": "#3.5.py\n#Displayig multiple values\n\n#Variable declaration\nvalue1=50\nvalue2=25\n\n#Calculation\nsum=value1+value2\n\n#Result\nprint(\"The sum of {0} & {1} is: {2}\".format(value1,value2,sum))", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "The sum of 50 & 25 is: 75\n" } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": "Program 3.6, Page number: 17" }, { "cell_type": "code", "collapsed": false, "input": "#3.6.py\n#Using Comment in a program\n\n#'#(Hash/Pound)' is used to display a comment in python\n#This is a comment\n\n#Variable declarations\nvalue1=50\nvalue2=25\n\n#Calculation\nsum=value1+value2\n\n#Result\nprint(\"The sum of {0} & {1} is {2}\".format(value1,value2,sum))", "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": "The sum of 50 & 25 is 75\n" } ], "prompt_number": 6 } ], "metadata": {} } ] }