summaryrefslogtreecommitdiff
path: root/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-09-04 22:04:10 +0530
committerThomas Stephen Lee2015-09-04 22:04:10 +0530
commit41f1f72e9502f5c3de6ca16b303803dfcf1df594 (patch)
treef4bf726a3e3ce5d7d9ee3781cbacfe3116115a2c /C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
parent9c9779ba21b9bedde88e1e8216f9e3b4f8650b0e (diff)
downloadPython-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.gz
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.bz2
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.zip
add/remove/update books
Diffstat (limited to 'C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb')
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter5.ipynb475
1 files changed, 0 insertions, 475 deletions
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
deleted file mode 100755
index ac86dba8..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
+++ /dev/null
@@ -1,475 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:22dbf664bff583df60a7371a6f741be85c976f32fe9bef5f00f146ca5848d933"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 5 : Structured Programming"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.1, Page No 116"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "print \"Nothing happenning here\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Nothing happenning here\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.2, Page No 118"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(num1,num2):\n",
- " return num1+num2\n",
- "\n",
- "def subtractTwoNumber(num1,num2):\n",
- " return num1-num2\n",
- "\n",
- "print \"Nothing happenning here\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Nothing happenning here\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.3, Page No 119"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "\n",
- "iResult= addTwoNumbers(5,5)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.4, Page No 120"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "print \"The result is : \",addTwoNumbers(5,5)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The result is : 10\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.5, Page No 120"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "num1=int(raw_input(\"Enter the first number: \"))\n",
- "num2=int(raw_input(\"Enter the second number: \"))\n",
- "print \"The result is: \",addTwoNumbers(num1,num2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the first number: 57\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the second number: 43\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The result is: 100\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.6, Page No 121"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def printReportHeader():\n",
- " print \"\\n Column1 \\t Column2 \\t Column3 \\t Column4 \\n\"\n",
- " \n",
- "printReportHeader()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " Column1 \t Column2 \t Column3 \t Column4 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.7, Page No 122"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "num1=int(raw_input(\"Enter a number: \"))\n",
- "print \"You entered \",num1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number: 10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You entered 10\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.8, Page No 123"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def getSecondNumber():\n",
- " num1=int(raw_input(\"Enter Second number: \"))\n",
- " return num1\n",
- "\n",
- "num1=int(raw_input(\"Enter a number: \"))\n",
- "num2=getSecondNumber()\n",
- "print \"you entered \"+str(num1)+\" and \",str(num2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number: 28\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Second number: 35\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "you entered 28 and 35\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.9, Page No 124"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iLuckyNumber=int()\n",
- "def printLuckyNumber():\n",
- " print \"Your lucky number is: \",iLuckyNumber\n",
- "\n",
- "\n",
- "iLuckyNumber=int(raw_input(\"Enter your lucky number: \"))\n",
- "printLuckyNumber()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your lucky number: 10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your lucky number is: 10\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.10, Page No 126"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import os\n",
- "import time\n",
- "def sportsQuestion():\n",
- " print \"Sports Question\"\n",
- " print \"What University did NFL star Deon Sanders attend?\"\n",
- " print \"1 \\t University of Miami\"\n",
- " print \"2 \\t California State University\"\n",
- " print \"3 \\t Indiana University\"\n",
- " print \"4 \\t Florida State University\"\n",
- " iAnswer=int(raw_input(\"Enter your selection :\"))\n",
- " return iAnswer\n",
- "\n",
- "def geographyQuestion():\n",
- " print \"Geography Question\"\n",
- " print \"What is the state capitol of Florida?\"\n",
- " print \"1 \\t Pensecola\"\n",
- " print \"2 \\t Tallahassee\"\n",
- " print \"3 \\t Jacksonville\"\n",
- " print \"4 \\t Miami\"\n",
- " iAnswer=int(raw_input(\"Enter your selection :\"))\n",
- " return iAnswer\n",
- "def pause(inNum):\n",
- " iCurrentTime=0\n",
- " iElapsedTime=0\n",
- " \n",
- " iCurrentTime=int(round(time.time()*1000))\n",
- " \n",
- " while((iElapsedTime-iCurrentTime)<inNum):\n",
- " iElapsedTime=int(round(time.time()*1000))\n",
- "\n",
- "giResponse=0\n",
- "while(giResponse !=3):\n",
- " os.system('cls')\n",
- " print \"\\n\\tTHE TRIVIA GAME\\n\\n\"\n",
- " print \"1\\tSports\\n\"\n",
- " print \"2\\tGeography\\n\"\n",
- " print \"3\\tQuit\\n\"\n",
- " giResponse=int(raw_input(\"Enter your Selection: \"))\n",
- " \n",
- " if(giResponse==1):\n",
- " if(sportsQuestion()==4):\n",
- " print \"\\nCorrect\\n\"\n",
- " else:\n",
- " print \"\\nIncorrect\\n\"\n",
- " \n",
- " pause(2)\n",
- " break\n",
- " elif(giResponse==2):\n",
- " if(geographyQuestion()==2):\n",
- " print \"\\nCorrect\\n\"\n",
- " else:\n",
- " print \"\\nIncorrect\\n\"\n",
- " \n",
- " pause(2)\n",
- " break\n",
- " \n",
- " \n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\tTHE TRIVIA GAME\n",
- "\n",
- "\n",
- "1\tSports\n",
- "\n",
- "2\tGeography\n",
- "\n",
- "3\tQuit\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your Selection: 1\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sports Question\n",
- "What University did NFL star Deon Sanders attend?\n",
- "1 \t University of Miami\n",
- "2 \t California State University\n",
- "3 \t Indiana University\n",
- "4 \t Florida State University\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your selection :4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Correct\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file