summaryrefslogtreecommitdiff
path: root/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
diff options
context:
space:
mode:
authorhardythe12015-04-07 15:58:05 +0530
committerhardythe12015-04-07 15:58:05 +0530
commit92cca121f959c6616e3da431c1e2d23c4fa5e886 (patch)
tree205e68d0ce598ac5caca7de839a2934d746cce86 /C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
parentb14c13fcc6bb6d01c468805d612acb353ec168ac (diff)
downloadPython-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.gz
Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.bz2
Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.zip
added books
Diffstat (limited to 'C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb')
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter2.ipynb239
1 files changed, 239 insertions, 0 deletions
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
new file mode 100755
index 00000000..2f3c44af
--- /dev/null
+++ b/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
@@ -0,0 +1,239 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:622f2c579033e8c66b476e16d61ce8bfa6745f6b87c5905b2064108fa5218b3c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 2 PRIMARY DATA TYPES"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1, Page No. 32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "x=-4443\n",
+ "y=554.21\n",
+ "c='M'\n",
+ "\n",
+ "print \"The value of integer variable x is\" , x\n",
+ "print \"The value of float variable y is \" , y\n",
+ "print \"The value of character variable c is \" , c"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of integer variable x is -4443\n",
+ "The value of float variable y is 554.21\n",
+ "The value of character variable c is M\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2, Page No. 36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "x = 20\n",
+ "PI = 3.14\n",
+ "print \"Constant values are \",x ,\" and \", round(PI,2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Constant values are 20 and 3.14\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3, Page No. 42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"\\t Adder Program, by Michael Vine\"\n",
+ "iOperand1=int(raw_input(\"Enter First Operand: \"))\n",
+ "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n",
+ "print \"The final result is \", iOperand1+iOperand2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\t Adder Program, by Michael Vine\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter First Operand: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Second Operand: 7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The final result is 12\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4, Page No. 44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"\\t Adder Program, by Michael Vine\"\n",
+ "iOperand1=int(raw_input(\"Enter First Operand: \"))\n",
+ "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n",
+ "iResult=iOperand1+iOperand2\n",
+ "print \"The result is \", iResult"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\t Adder Program, by Michael Vine\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter First Operand: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Second Operand: 7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The result is 12\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.5, Page No. 46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "fRevenue=float(raw_input(\"Enter total revenue: \"))\n",
+ "fCost=float(raw_input(\"Enter total cost: \"))\n",
+ "print \"Your total profit is \", round(fRevenue-fCost,3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter total revenue: 4000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter total cost: 750\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Your total profit is 3250.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file