summaryrefslogtreecommitdiff
path: root/Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb
diff options
context:
space:
mode:
authorkinitrupti2017-05-12 18:53:46 +0530
committerkinitrupti2017-05-12 18:53:46 +0530
commitf270f72badd9c61d48f290c3396004802841b9df (patch)
treebc8ba99d85644c62716ce397fe60177095b303db /Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb
parent64d949698432e05f2a372d9edc859c5b9df1f438 (diff)
downloadPython-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.tar.gz
Python-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.tar.bz2
Python-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.zip
Removed duplicates
Diffstat (limited to 'Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb')
-rwxr-xr-xPractical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb258
1 files changed, 258 insertions, 0 deletions
diff --git a/Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb b/Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb
new file mode 100755
index 00000000..8602f989
--- /dev/null
+++ b/Practical_C_Programming_by_Steve_Oualline/Chapter_4_4.ipynb
@@ -0,0 +1,258 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:785237ffc865ddc47952e10309b1bb53ee1543217e833069c02c2afb50bff287"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 4: Basic declarations and expressions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.1, Page number: 71"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variable declaration\n",
+ "x = (1 + 2) * 4\n",
+ "\n",
+ "# Result\n",
+ "print ('1 plus 2 multiplied by 4 gives %d' % x)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1 plus 2 multiplied by 4 gives 12\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.2, Page number: 75"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variable declaration\n",
+ "term = 3 * 5\n",
+ "term_2 = 2 * term\n",
+ "term_3 = 3 * term\n",
+ "\n",
+ "# Result\n",
+ "print ('Twice %d is %d' % (term, term_2))\n",
+ "print ('Three times %d is %d' % (term, term_3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Twice 15 is 30\n",
+ "Three times 15 is 45\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.3, Page number: 77"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "# Variable declaration\n",
+ "term = 3 * 5\n",
+ "term_2 = 2 * term\n",
+ "term_3 = 3 * term\n",
+ "\n",
+ "# Result\n",
+ "print ('Twice %d is %d' % (term, term_2))\n",
+ "print ('Three times %d is %d' % (term, term_3))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Twice 15 is 30\n",
+ "Three times 15 is 45\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.4, Page number: 79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variable declaration\n",
+ "answer = 1/3\n",
+ "\n",
+ "# Result\n",
+ "print ('The value of 1/3 is %f' % answer)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of 1/3 is 0.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.5, Page number: 80"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "answer = 2 + 2\n",
+ "\n",
+ "# Result\n",
+ "print ('The answer is %d' % answer)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The answer is 4\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.6, Page number: 80"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "\n",
+ "# Variable declaration\n",
+ "result = 7.0/22.0\n",
+ "\n",
+ "# Result\n",
+ "print ('The result is %d' % result)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The result is 0\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Example 4.7, Page number: 82"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "# Variable declaration\n",
+ "char1 = 'A'\n",
+ "char2 = 'B'\n",
+ "char3 = 'C'\n",
+ "\n",
+ "# Result\n",
+ "print ('%c%c%c reversed is %c%c%c' % (char1, char2, char3, char3, char2, char1))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "ABC reversed is CBA\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file