{ "metadata": { "name": "", "signature": "sha256:7c8e11b3dcc5781949652c0b5c450d78713cb6e6b69326955d0f763c48805147" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 2, An Introduction to Declarations, Assignments and Variables" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Program 2-1 , Page number: 20" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# An introduction to variable declarations \n", "\n", "number = 7 # no need of declaration of variable. Python is dynamically-typed language\n", "print \"There are %d days in a week.\"%number" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "There are 7 days in a week.\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Program 2-2 , Page number: 21" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# A simple program with two declarations\n", "\n", "minutes = 60\n", "hours = 24\n", "\n", "print \"There are %d minutes in an hour.\"%minutes\n", "print \"And %d hours in a day.\"%hours" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "There are 60 minutes in an hour.\n", "And 24 hours in a day.\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Program 2-4 , Page number: 22" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# prints values of two variables\n", "\n", "dozens = 17\n", "units = dozens * 12\n", "\n", "print \"%d units is equivalent to %d dozen.\"%(units,dozens)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "204 units is equivalent to 17 dozen.\n" ] } ], "prompt_number": 3 } ], "metadata": {} } ] }