summaryrefslogtreecommitdiff
path: root/Mastering_C/chapter15.ipynb
blob: cf449021ba069bb590b01c1acb70499120600b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{
 "metadata": {
  "name": "",
  "signature": "sha256:64bc6ed635ee782424e2a9c6d347d0d839901e22bcfed6521e3f281977a7711d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "C Library Functions\n"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.1 page no : 655"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"ratsdrowninwordstar is a palindrom\"\n",
      "print \"length of \\\"ratsdrowninwordstar is a palindrom\\\" is\",\n",
      "Len = len(\"ratsdrowninwordstar\")\n",
      "print \"%d\"%Len"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratsdrowninwordstar is a palindrom\n",
        "length of \"ratsdrowninwordstar is a palindrom\" is 19\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.2 Pageno : 656"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "Num = 123.54\n",
      "fNum = 0.0\n",
      "cNum = 0.0\n",
      "fNum = math.floor(Num)\n",
      "cNum = math.ceil(Num)\n",
      "print \"original number  %.2lf\"%Num\n",
      "print \"number rounded down  %.lf\"%fNum\n",
      "print \"number rounded up  %.lf\"%cNum"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "original number  123.54\n",
        "number rounded down  123\n",
        "number rounded up  124\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}