diff options
author | hardythe1 | 2015-06-11 17:31:11 +0530 |
---|---|---|
committer | hardythe1 | 2015-06-11 17:31:11 +0530 |
commit | 79c59acc7af08ede23167b8455de4b716f77601f (patch) | |
tree | 2d6ff34b6f131d2671e4c6b798f210b3cb1d4ac7 /Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb | |
parent | df60071cf1d1c18822d34f943ab8f412a8946b69 (diff) | |
download | Python-Textbook-Companions-79c59acc7af08ede23167b8455de4b716f77601f.tar.gz Python-Textbook-Companions-79c59acc7af08ede23167b8455de4b716f77601f.tar.bz2 Python-Textbook-Companions-79c59acc7af08ede23167b8455de4b716f77601f.zip |
add books
Diffstat (limited to 'Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb')
-rwxr-xr-x | Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb | 404 |
1 files changed, 404 insertions, 0 deletions
diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb @@ -0,0 +1,404 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:92c507d5a01a7a0413aaf810859ecb2e4626113fce440f0c32977c3febad1c75"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "11:HANDLING OF CHARACTER STRINGS"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.2.1, page number:180"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "inform=['m','a','d','u','r','a','i']\n",
+ "print \"\".join(inform)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "madurai\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.3.1,page number:182"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "inform=\"Thiagaragar\"\n",
+ "numb=int(input(\"No. Of Char To Print \"))\n",
+ "print 'print format = %.0',numb,'s'\n",
+ "print inform[0:numb]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "No. Of Char To Print 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "print format = %.0 6 s\n",
+ "Thiaga\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.4.1,page number:183"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "inform=\"Thiagaragar\"\n",
+ "numb=int(input(\"No. Of Char To Print \"))\n",
+ "print 'print format = %.0',numb,'s'\n",
+ "print inform[0:numb]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "No. Of Char To Print 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "print format = %.0 6 s\n",
+ "Thiaga\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.5.1,page number:183"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "array1='Thiagarajar Engg'\n",
+ "array2=(array1 + '.')[:-1]\n",
+ "print \"array1 = \",array1\n",
+ "print \"array2 = \",array2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "array1 = Thiagarajar Engg\n",
+ "array2 = Thiagarajar Engg\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.6.1,page number:184"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "userInput = raw_input(\"Enter Int: \")\n",
+ "if userInput.isdigit():\n",
+ " print \"Number = \"+userInput\n",
+ "else:\n",
+ " print userInput,\"is not int type\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Int: 8\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number = 8\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.7.1,page number:186"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "first=\"Thiagrajar\"\n",
+ "second=first+\" Engg.\"\n",
+ "\n",
+ "print \"first = \",first\n",
+ "print \"second = \",second"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "first = Thiagrajar\n",
+ "second = Thiagrajar Engg.\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.8.1,page number:187"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "string1 = \"Hello\"\n",
+ "print \"len of str is\",len(string1)\n",
+ "string2 = \" There\"\n",
+ "print \"string1+string2 is\",string1+string2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " len of str is 5\n",
+ "string1+string2 is Hello There\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "11.12.1, page number:189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import array\n",
+ "i=20\n",
+ "size=0\n",
+ "str1 =[]\n",
+ "str2=[]\n",
+ "def readSize():\n",
+ " global size\n",
+ " size=int(input(\"Enter number of strings : \"))\n",
+ " if size<1 or size>i :\n",
+ " readSize()\n",
+ " return\n",
+ "def readArray():\n",
+ " global size\n",
+ " global str1\n",
+ " print \"Enter the Strings..\"\n",
+ " for k in range(0,size):\n",
+ " m=raw_input()\n",
+ " str1.append(m)\n",
+ " return\n",
+ "def displayArray1():\n",
+ " for index in range(0,size):\n",
+ " print str1[index]\n",
+ " return\n",
+ "def displayArray2():\n",
+ " for index in range(0,size):\n",
+ " print str2[index]\n",
+ " return\n",
+ "def sortedArray():\n",
+ " global str1\n",
+ " global str2\n",
+ " str2= sorted(str1)\n",
+ " return\n",
+ "\n",
+ "readSize()\n",
+ "readArray()\n",
+ "print \"The unsorted array is..\"\n",
+ "displayArray1()\n",
+ "sortedArray()\n",
+ "print \"The sorted array is..\"\n",
+ "displayArray2()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter number of strings : 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Strings..\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "computer\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "page\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "diskette\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "eprom\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "binary\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "random\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The unsorted array is..\n",
+ "computer\n",
+ "page\n",
+ "diskette\n",
+ "eprom\n",
+ "binary\n",
+ "random\n",
+ "The sorted array is..\n",
+ "binary\n",
+ "computer\n",
+ "diskette\n",
+ "eprom\n",
+ "page\n",
+ "random\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |