{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Chapter 3: Operators and Expressions

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 3.13, Page number: 3.9

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import ctypes as ct\n", "\n", "print \"interger : \",ct.sizeof(ct.c_int())\n", "print \"float : \",ct.sizeof(ct.c_float())\n", "print \"double : \",ct.sizeof(ct.c_double())\n", "print \"character : \",ct.sizeof(ct.c_char())\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "interger : 4\n", "float : 4\n", "double : 8\n", "character : 1\n" ] } ], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 3.30, Page number: 3.19

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "print \"for the equation ax^2+bx+c \\n\"\n", "\n", "a=2\n", "b=6\n", "c=3\n", "\n", "root=(b*b-4*a*c)**0.5\n", "x1=(-b + root)/(2*a)\n", "x2=(-b - root)/(2*a)\n", "\n", "print \"x1=\",x1\n", "print \"x2=\",x2\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "for the equation ax^2+bx+c \n", "\n", "x1= -0.633974596216\n", "x2= -2.36602540378\n" ] } ], "prompt_number": 3 }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Example 3.31, Page number: 3.20

" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "\n", "lower=\"l\"\n", "upper=lower.upper()\n", "print upper\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "L\n" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }