summaryrefslogtreecommitdiff
path: root/Programming_With_C/chapter3.ipynb
diff options
context:
space:
mode:
authorJovina Dsouza2014-07-07 16:34:28 +0530
committerJovina Dsouza2014-07-07 16:34:28 +0530
commitfffcc90da91b66ee607066d410b57f34024bd1de (patch)
tree7b8011d61013305e0bf7794a275706abd1fdb0d3 /Programming_With_C/chapter3.ipynb
parent299711403e92ffa94a643fbd960c6f879639302c (diff)
downloadPython-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.tar.gz
Python-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.tar.bz2
Python-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.zip
adding book
Diffstat (limited to 'Programming_With_C/chapter3.ipynb')
-rwxr-xr-xProgramming_With_C/chapter3.ipynb132
1 files changed, 132 insertions, 0 deletions
diff --git a/Programming_With_C/chapter3.ipynb b/Programming_With_C/chapter3.ipynb
new file mode 100755
index 00000000..fbf10f10
--- /dev/null
+++ b/Programming_With_C/chapter3.ipynb
@@ -0,0 +1,132 @@
+{
+ "metadata": {
+ "name": ""
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h1>Chapter 3: Operators and Expressions<h1>"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "<h3>Example 3.13, Page number: 3.9 <h3>"
+ ]
+ },
+ {
+ "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": [
+ "<h3>Example 3.30, Page number: 3.19<h3>"
+ ]
+ },
+ {
+ "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": [
+ "<h3>Example 3.31, Page number: 3.20<h3>"
+ ]
+ },
+ {
+ "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": {}
+ }
+ ]
+} \ No newline at end of file