From 79c59acc7af08ede23167b8455de4b716f77601f Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Thu, 11 Jun 2015 17:31:11 +0530 Subject: add books --- .../chapter10.ipynb | 711 ++++++++++++++++++ .../chapter10_1.ipynb | 711 ++++++++++++++++++ .../chapter10_10.ipynb | 711 ++++++++++++++++++ .../chapter10_11.ipynb | 711 ++++++++++++++++++ .../chapter10_12.ipynb | 711 ++++++++++++++++++ .../chapter10_13.ipynb | 711 ++++++++++++++++++ .../chapter10_14.ipynb | 711 ++++++++++++++++++ .../chapter10_15.ipynb | 711 ++++++++++++++++++ .../chapter10_2.ipynb | 711 ++++++++++++++++++ .../chapter10_3.ipynb | 711 ++++++++++++++++++ .../chapter10_4.ipynb | 711 ++++++++++++++++++ .../chapter10_5.ipynb | 711 ++++++++++++++++++ .../chapter10_6.ipynb | 711 ++++++++++++++++++ .../chapter10_7.ipynb | 711 ++++++++++++++++++ .../chapter10_8.ipynb | 711 ++++++++++++++++++ .../chapter10_9.ipynb | 711 ++++++++++++++++++ .../chapter11.ipynb | 404 ++++++++++ .../chapter11_1.ipynb | 404 ++++++++++ .../chapter11_10.ipynb | 404 ++++++++++ .../chapter11_11.ipynb | 404 ++++++++++ .../chapter11_12.ipynb | 404 ++++++++++ .../chapter11_13.ipynb | 404 ++++++++++ .../chapter11_14.ipynb | 404 ++++++++++ .../chapter11_15.ipynb | 404 ++++++++++ .../chapter11_2.ipynb | 404 ++++++++++ .../chapter11_3.ipynb | 404 ++++++++++ .../chapter11_4.ipynb | 404 ++++++++++ .../chapter11_5.ipynb | 404 ++++++++++ .../chapter11_6.ipynb | 404 ++++++++++ .../chapter11_7.ipynb | 404 ++++++++++ .../chapter11_8.ipynb | 404 ++++++++++ .../chapter11_9.ipynb | 404 ++++++++++ .../chapter12.ipynb | 436 +++++++++++ .../chapter12_1.ipynb | 436 +++++++++++ .../chapter12_10.ipynb | 436 +++++++++++ .../chapter12_11.ipynb | 436 +++++++++++ .../chapter12_12.ipynb | 436 +++++++++++ .../chapter12_13.ipynb | 436 +++++++++++ .../chapter12_14.ipynb | 436 +++++++++++ .../chapter12_15.ipynb | 436 +++++++++++ .../chapter12_2.ipynb | 436 +++++++++++ .../chapter12_3.ipynb | 436 +++++++++++ .../chapter12_4.ipynb | 436 +++++++++++ .../chapter12_5.ipynb | 436 +++++++++++ .../chapter12_6.ipynb | 436 +++++++++++ .../chapter12_7.ipynb | 436 +++++++++++ .../chapter12_8.ipynb | 436 +++++++++++ .../chapter12_9.ipynb | 436 +++++++++++ .../chapter13.ipynb | 125 ++++ .../chapter13_1.ipynb | 125 ++++ .../chapter13_10.ipynb | 125 ++++ .../chapter13_11.ipynb | 125 ++++ .../chapter13_12.ipynb | 125 ++++ .../chapter13_13.ipynb | 125 ++++ .../chapter13_14.ipynb | 125 ++++ .../chapter13_15.ipynb | 125 ++++ .../chapter13_2.ipynb | 125 ++++ .../chapter13_3.ipynb | 125 ++++ .../chapter13_4.ipynb | 125 ++++ .../chapter13_5.ipynb | 125 ++++ .../chapter13_6.ipynb | 125 ++++ .../chapter13_7.ipynb | 125 ++++ .../chapter13_8.ipynb | 125 ++++ .../chapter13_9.ipynb | 125 ++++ .../chapter15.ipynb | 384 ++++++++++ .../chapter15_1.ipynb | 384 ++++++++++ .../chapter15_10.ipynb | 384 ++++++++++ .../chapter15_11.ipynb | 384 ++++++++++ .../chapter15_12.ipynb | 384 ++++++++++ .../chapter15_13.ipynb | 384 ++++++++++ .../chapter15_14.ipynb | 384 ++++++++++ .../chapter15_15.ipynb | 384 ++++++++++ .../chapter15_2.ipynb | 384 ++++++++++ .../chapter15_3.ipynb | 384 ++++++++++ .../chapter15_4.ipynb | 384 ++++++++++ .../chapter15_5.ipynb | 384 ++++++++++ .../chapter15_6.ipynb | 384 ++++++++++ .../chapter15_7.ipynb | 384 ++++++++++ .../chapter15_8.ipynb | 384 ++++++++++ .../chapter15_9.ipynb | 384 ++++++++++ .../chapter5.ipynb | 50 ++ .../chapter5_1.ipynb | 50 ++ .../chapter5_10.ipynb | 50 ++ .../chapter5_11.ipynb | 50 ++ .../chapter5_12.ipynb | 50 ++ .../chapter5_13.ipynb | 50 ++ .../chapter5_14.ipynb | 50 ++ .../chapter5_15.ipynb | 50 ++ .../chapter5_2.ipynb | 50 ++ .../chapter5_3.ipynb | 50 ++ .../chapter5_4.ipynb | 50 ++ .../chapter5_5.ipynb | 50 ++ .../chapter5_6.ipynb | 50 ++ .../chapter5_7.ipynb | 50 ++ .../chapter5_8.ipynb | 50 ++ .../chapter5_9.ipynb | 50 ++ .../chapter6.ipynb | 161 ++++ .../chapter6_1.ipynb | 161 ++++ .../chapter6_10.ipynb | 161 ++++ .../chapter6_11.ipynb | 161 ++++ .../chapter6_12.ipynb | 161 ++++ .../chapter6_13.ipynb | 161 ++++ .../chapter6_14.ipynb | 161 ++++ .../chapter6_15.ipynb | 161 ++++ .../chapter6_2.ipynb | 161 ++++ .../chapter6_3.ipynb | 161 ++++ .../chapter6_4.ipynb | 161 ++++ .../chapter6_5.ipynb | 161 ++++ .../chapter6_6.ipynb | 161 ++++ .../chapter6_7.ipynb | 161 ++++ .../chapter6_8.ipynb | 161 ++++ .../chapter6_9.ipynb | 161 ++++ .../chapter7.ipynb | 114 +++ .../chapter7_1.ipynb | 114 +++ .../chapter7_10.ipynb | 114 +++ .../chapter7_11.ipynb | 114 +++ .../chapter7_12.ipynb | 114 +++ .../chapter7_13.ipynb | 114 +++ .../chapter7_14.ipynb | 114 +++ .../chapter7_15.ipynb | 114 +++ .../chapter7_2.ipynb | 114 +++ .../chapter7_3.ipynb | 114 +++ .../chapter7_4.ipynb | 114 +++ .../chapter7_5.ipynb | 114 +++ .../chapter7_6.ipynb | 114 +++ .../chapter7_7.ipynb | 114 +++ .../chapter7_8.ipynb | 114 +++ .../chapter7_9.ipynb | 114 +++ .../chapter8.ipynb | 139 ++++ .../chapter8_1.ipynb | 139 ++++ .../chapter8_10.ipynb | 139 ++++ .../chapter8_11.ipynb | 139 ++++ .../chapter8_12.ipynb | 139 ++++ .../chapter8_13.ipynb | 139 ++++ .../chapter8_14.ipynb | 139 ++++ .../chapter8_15.ipynb | 139 ++++ .../chapter8_2.ipynb | 139 ++++ .../chapter8_3.ipynb | 139 ++++ .../chapter8_4.ipynb | 139 ++++ .../chapter8_5.ipynb | 139 ++++ .../chapter8_6.ipynb | 139 ++++ .../chapter8_7.ipynb | 139 ++++ .../chapter8_8.ipynb | 139 ++++ .../chapter8_9.ipynb | 139 ++++ .../chapter9.ipynb | 832 +++++++++++++++++++++ .../chapter9_1.ipynb | 832 +++++++++++++++++++++ .../chapter9_10.ipynb | 832 +++++++++++++++++++++ .../chapter9_11.ipynb | 832 +++++++++++++++++++++ .../chapter9_12.ipynb | 832 +++++++++++++++++++++ .../chapter9_13.ipynb | 832 +++++++++++++++++++++ .../chapter9_14.ipynb | 832 +++++++++++++++++++++ .../chapter9_15.ipynb | 832 +++++++++++++++++++++ .../chapter9_2.ipynb | 832 +++++++++++++++++++++ .../chapter9_3.ipynb | 832 +++++++++++++++++++++ .../chapter9_4.ipynb | 832 +++++++++++++++++++++ .../chapter9_5.ipynb | 832 +++++++++++++++++++++ .../chapter9_6.ipynb | 832 +++++++++++++++++++++ .../chapter9_7.ipynb | 832 +++++++++++++++++++++ .../chapter9_8.ipynb | 832 +++++++++++++++++++++ .../chapter9_9.ipynb | 832 +++++++++++++++++++++ 160 files changed, 53696 insertions(+) create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_1.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_10.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_11.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_12.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_13.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_14.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_15.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_2.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_3.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_4.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_5.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_6.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_7.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_8.ipynb create mode 100755 Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_9.ipynb (limited to 'Computer_Concepts_and_C_Programming_by_R.Rajaram') diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_1.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_1.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_10.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_10.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_11.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_11.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_12.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_12.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_13.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_13.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_14.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_14.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_15.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_15.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_2.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_2.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_3.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_3.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_4.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_4.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_5.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_5.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_6.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_6.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_7.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_7.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_8.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_8.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_9.ipynb new file mode 100755 index 00000000..db2cb5a6 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter10_9.ipynb @@ -0,0 +1,711 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:a2d2127f6a5ebfde55eb11899a94f93b6aeee78155a32ab8e434ae8b263ad3b3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "10 : ARRAYS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.2.1,page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "value = [6]\n", + "\n", + "for index in range(0,6):\n", + " print \"Enter Integer\"\n", + " value.append(int(input()))\n", + "for index in range(0,7):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 6\n", + "Integer = 12\n", + "Integer = 6\n", + "Integer = 7\n", + "Integer = 13\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.1, page number:170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=[6,4,3,2,1]\n", + "for index in xrange(5):\n", + " print \"Integer = \",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 6\n", + "Integer = 4\n", + "Integer = 3\n", + "Integer = 2\n", + "Integer = 1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.3.2, page number:171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE_CONST():\n", + " return 123\n", + "def TRAILER_CONST():\n", + " return -7777\n", + "value=array.array('i',[])\n", + "print \"Enter upto\",MAX_SIZE_CONST(),\"using\",TRAILER_CONST(),\"as trailer :\"\n", + "print \"\"\n", + "m=0\n", + "for index in range(0,int(MAX_SIZE_CONST())):\n", + " item=int(input())\n", + " if(item == int(TRAILER_CONST())):\n", + " break\n", + " else:\n", + " value.append(item)\n", + " m+=1\n", + "for index in range(0,m):\n", + " print \"Integer =\",value[index]" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter upto 123 using -7777 as trailer :\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-7777\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integer = 1\n", + "Integer = 2\n", + "Integer = 3\n", + "Integer = 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.4.1, page number:172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "k=0\n", + "sum=0.0\n", + "def MAX_STUD():\n", + " return 20\n", + "def ENDINP():\n", + " return -9999\n", + "mark=array.array('i',(0 for i in range(0,MAX_STUD())))\n", + "print \"enter upto\",MAX_STUD(),\"marks:\"\n", + "readin=int(input())\n", + "for index in range(0,MAX_STUD()):\n", + " if(readin != ENDINP()):\n", + " mark[index]=readin\n", + " readin=int(input())\n", + " k+=1\n", + "for index in xrange(0,k):\n", + " sum=sum+mark[index]\n", + "print \"Average Mark = \",sum/k\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter upto 20 marks:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "34\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "66\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "78\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "88\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-9999\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average Mark = 51.125\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.5.1, page number:174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 10\n", + "#str=array.array('i',(0 for i in range(0,MAX_SIZE()+1)))\n", + "print \"Enter the 10 letter word.\"\n", + "str=raw_input()\n", + "r=[]\n", + "for letter in str:\n", + " r.append(letter)\n", + "r.reverse()\n", + "print \"word = \",str\n", + "print \"\".join(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the 10 letter word.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "word = madurai\n", + "iarudam\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "10.6.1, page number:175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "def MAX_SIZE():\n", + " return 20\n", + "size=0\n", + "variable =array.array('i',[])\n", + "while True:\n", + " print \"Array-size : ?\"\n", + " size=int(input())\n", + " if size>1 and size4 :\n", + " running=False\n", + " return city\n", + "def read_year():\n", + " running=True\n", + " while running:\n", + " print \"Which year?\"\n", + " year=int(input())\n", + " if year>1950 or year<2000 :\n", + " running=False\n", + " return year\n", + "def pop(x,y):\n", + " global pox\n", + " return pox[x-1][(y-1950)/10]\n", + "\n", + "def output_city():\n", + " if city == 1:\n", + " return \"Madurai\"\n", + " elif city == 2:\n", + " return \"Madras\"\n", + " elif city == 3:\n", + " return \"Bombay\"\n", + " elif city == 4:\n", + " return \"Calcutta\"\n", + " \n", + "runnable=True\n", + "city=read_city()\n", + "while runnable :\n", + " year=read_year()\n", + " print \"Population in \",year,\"of\",output_city(),\"is\",pop(city,year),\"Lakhs\"\n", + " city =read_city()\n", + " if city == 0:\n", + " runnable=False" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Which year?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Population in 1990 of Bombay is 30 Lakhs\n", + "Which city?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_1.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_1.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_10.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_10.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_11.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_11.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_12.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_12.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_13.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_13.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_14.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_14.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_15.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_15.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_2.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_2.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_3.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_3.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_4.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_4.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_5.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_5.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_6.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_6.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_7.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_7.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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_8.ipynb new file mode 100755 index 00000000..a7a687c2 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter11_8.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 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 diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_1.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_1.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_10.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_10.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_11.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_11.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_12.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_12.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_13.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_13.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_14.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_14.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_15.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_15.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_2.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_2.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_3.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_3.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_4.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_4.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_5.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_5.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_6.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_6.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_7.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_7.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_8.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_8.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_9.ipynb new file mode 100755 index 00000000..f5e720e1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter12_9.ipynb @@ -0,0 +1,436 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fddb630ff591f8acea671441a1ef2200894f84585416ff0fca0f361802a87050" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "12:USER DEFINED FUNCTIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.4.1, page number:194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",leng*width" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16.8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "43.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 734.16\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.1, page number:195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def change_index():\n", + " index=5\n", + "index=3\n", + "print \"index = \",index\n", + "change_index()\n", + "print \"index = \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "index = 3\n", + "index = 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.5.2, page number:196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def get_a_value():\n", + " return float(input())\n", + "def calc_area():\n", + " global leng,width\n", + " return leng*width\n", + "print \"Enter the Length..\"\n", + "leng=get_a_value()\n", + "print \"Enter the Width..\"\n", + "width=get_a_value()\n", + "print \"Area = \",calc_area()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Length..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the Width..\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.6.1, page number:197" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def print_value(k):\n", + " print k\n", + "numb=5\n", + "print \"Value of Expression : \",\n", + "print_value(numb*3+2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of Expression : 17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.7.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def TOL():\n", + " return 0.0001\n", + "def sqrt(n):\n", + " if n>0.0:\n", + " guess=0.0\n", + " guess=n/2.0\n", + " while True:\n", + " if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):\n", + " temp=guess+n/guess\n", + " guess=temp/2.0\n", + " else:\n", + " break\n", + " return guess\n", + " else:\n", + " return -1.0\n", + " \n", + "numb=float(input(\"Enter number..\"))\n", + "print \"Square Root of\",numb,\"is\",sqrt(numb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter number..17.1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Square Root of 17.1 is 4.13521500873\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.8.1, page number:198" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "year=0\n", + "def leap(n):\n", + " return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)\n", + "year=int(input(\"Enter Year..\"))\n", + "if leap(year):\n", + " print year,\"is leap year\"\n", + "else:\n", + " print year,\"is not leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year..1984\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1984 is leap year\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.1, page number:199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def input_value():\n", + " return input()\n", + "def area(l,w):\n", + " return l*w\n", + "print \"Length = \"\n", + "length=input_value();\n", + "print \"Width = \"\n", + "width=input_value();\n", + "print \"Area = \",area(length,width)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Length = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "12.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width = \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "23.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area = 296.25\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "12.9.2, page number:200" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "value=1\n", + "def power(n,e):\n", + " global value\n", + " if(e<0):\n", + " return 0\n", + " for index in range(0,e):\n", + " if(index < e):\n", + " value*=n\n", + " index+=1\n", + " return value\n", + " \n", + "number=int(input(\"Enter Integer...\"))\n", + "exponent=int(input(\"Enter Exponent...\"))\n", + "while True:\n", + " if (exponent<0):\n", + " exponent=input(\"Enter a Non-Negative Integer :\")\n", + " else:\n", + " break\n", + "print number,\"raised to \",exponent,\" = \",power(number,exponent)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer...4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Exponent...2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4 raised to 2 = 16\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_1.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_1.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_10.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_10.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_11.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_11.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_12.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_12.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_13.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_13.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_14.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_14.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_15.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_15.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_2.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_2.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_3.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_3.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_4.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_4.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_5.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_5.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_6.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_6.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_7.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_7.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_8.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_8.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_9.ipynb new file mode 100755 index 00000000..0c43b667 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter13_9.ipynb @@ -0,0 +1,125 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1ba129031b3dd7ed7efce1207bad751b6003f133c0f192eb72df391881da05bb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "13:STRUCTURE AND UNIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.2.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \" \")\n", + "real = MyStruct(\" \",\"320.17\")\n", + "integer=integer._replace(fees=real.fees)\n", + "real=real._replace(regno=integer.regno)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",integer.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.3.1, page number:203" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "\n", + "student = MyStruct(\"1234\", \"320.17\")\n", + "\n", + "print \"Reg.no : \",student.regno,\",Reg.no : \",student.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg.no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "13.4.1, page number:204" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from collections import namedtuple\n", + "MyStruct = namedtuple(\"MyStruct\", \"regno fees\")\n", + "\n", + "integer = MyStruct(\"1234\", \"320.17\")\n", + "real = MyStruct(\"\",\"\")\n", + "real=real._replace(regno=integer.regno,fees=integer.fees)\n", + "\n", + "print \"Reg_no : \",real.regno,\",Reg.no : \",real.fees" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reg_no : 1234 ,Reg.no : 320.17\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_1.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_1.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_10.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_10.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_11.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_11.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_12.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_12.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_13.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_13.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_14.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_14.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_15.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_15.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_2.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_2.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_3.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_3.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_4.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_4.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_5.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_5.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_6.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_6.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_7.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_7.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_8.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_8.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_9.ipynb new file mode 100755 index 00000000..39ea0685 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter15_9.ipynb @@ -0,0 +1,384 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1653abf733b2f9f179249fa6301d56a0dc1802cab84a3f5e0ff6ee96488fe3f6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "15:FILES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.4.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c[-1] == '.':\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming language is modern and advanced;\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming language is modern and advanced;\n", + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "it enables addressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "it enables addressing bits and bytes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.9.1, Page number:224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def EOF():\n", + " return -1\n", + "while True:\n", + " print \"Enter Text\"\n", + " c = raw_input()\n", + " print 'Text entered is:'\n", + " print c\n", + " if c != EOF():\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "madurai is a great city ,meenakshi temple is in the heart,millions of pilgrims visit the temple every year.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.10.1,page numebr:231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Key in Text:\"\n", + "f = open('myfile','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text is:\"\n", + "f = open('myfile','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Key in Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text is:\n", + "Madurai city is famous for its historical mounaments and archives,every visitor must see these places.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.12.1,page numebr:233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def file_output(x):\n", + " f=open(x,\"r\")\n", + " print f.read()\n", + "original = open('stud_rec','w')\n", + "copy = open('image','a')\n", + "\n", + "original.write(\"Tirupparankundram\\n\")\n", + "copy.write(\"Tirupparankundram\\n\")\n", + "\n", + "original.close()\n", + "copy.close()\n", + "\n", + "print \"After adding input,stud_rec has: \"\n", + "file_output(\"stud_rec\")\n", + "print \"After append,image contains:\"\n", + "file_output(\"image\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After adding input,stud_rec has: \n", + "Tirupparankundram\n", + "\n", + "After append,image contains:\n", + "Tirupparankundram\n", + "Tirupparankundram\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.14.1,page number:237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type in the Text:\"\n", + "f = open('madurai','w')\n", + "c=str(raw_input())\n", + "f.write(c)\n", + "print \"The text read as:\"\n", + "f = open('madurai','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type in the Text:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The text read as:\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.16.1,page number:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import sys\n", + "import fileinput\n", + "import string\n", + "\n", + "print \"Madurai Contains :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()\n", + "\n", + "s = open(\"madurai_1\").read()\n", + "s = s.replace('temple', 'shrine')\n", + "f = open(\"madurai_1\", 'w')\n", + "f.write(s)\n", + "f.close()\n", + "\n", + "print \"Modified File now reads :\"\n", + "f = open('madurai_1','r')\n", + "print f.read()\n", + "f.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Madurai Contains :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi temple has no age\n", + "\n", + "Modified File now reads :\n", + "Madurai is an ancient city,ruled by pandyas,Tirumalai nayakar was the last prominent ruler who left many monuments; but meenakshi shrine has no age\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "15.18.1,page number:241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import re\n", + "print \"Enter a stream of characters with integers embedded\"\n", + "c=raw_input()\n", + "print \"Integr is : \",re.sub(\"[^0-9]\", \"\", c)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a stream of characters with integers embedded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "ab+&473.tce\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Integr is : 473\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_1.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_1.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_10.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_10.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_11.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_11.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_12.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_12.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_13.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_13.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_14.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_14.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_15.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_15.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_2.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_2.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_3.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_3.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_4.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_4.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_5.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_5.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_6.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_6.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_7.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_7.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_8.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_8.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_9.ipynb new file mode 100755 index 00000000..3371a2b1 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter5_9.ipynb @@ -0,0 +1,50 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:fc199f6967bdaa418c011f64a9259bafc6cecf83675a6e55fed36bd7ff1a9671" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "5:C PROGRAMMING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "5.3,page number:124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Welcome to C programming.\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to C programming.\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_1.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_1.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_10.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_10.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_11.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_11.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_12.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_12.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_13.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_13.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_14.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_14.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_15.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_15.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_2.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_2.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_3.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_3.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_4.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_4.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_5.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_5.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_6.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_6.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_7.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_7.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_8.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_8.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_9.ipynb new file mode 100755 index 00000000..4c020690 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter6_9.ipynb @@ -0,0 +1,161 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d59a62b2c6bacca8aa43f556c3c49e598b6b0b52b3cecb75f5587ebd7d9f66" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "6:CONSTANTS,VARIABLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.1,page number:140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m=4\n", + "n=6\n", + "p=8\n", + "result = m+n\n", + "print \"m+n=\",result\n", + "result = int (m/n)\n", + "print \"m/n=\",result\n", + "result = m*p\n", + "print \"m*p=\",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m+n= 10\n", + "m/n= 0\n", + "m*p= 32\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.2,page number:141" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "p = 8\n", + "result= round(m+n-p*m+p/n,0)\n", + "print \"m=\",m,\",n=\",n,\",p=\",p\n", + "print \"m + n - p * m + p / n = \",result" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= 4 ,n= 6 ,p= 8\n", + "m + n - p * m + p / n = -21.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.3,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 4\n", + "n = 6\n", + "print \" 6 mod 4 = \",n%m\n", + "print \"The modulus operator is : %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 6 mod 4 = 2\n", + "The modulus operator is : %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "6.3.4,page number:142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = -4\n", + "n = 6\n", + "p = 8\n", + "print \"m=\",m,\" n=\",n,\" p=\",p\n", + "print \"gives\"\n", + "m=-m\n", + "n=-n\n", + "p=-p\n", + "print \"m=\",m,\" n=\",n,\" p=\",p" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "m= -4 n= 6 p= 8\n", + "gives\n", + "m= 4 n= -6 p= -8\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_1.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_1.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_10.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_10.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_11.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_11.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_12.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_12.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_13.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_13.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_14.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_14.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_15.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_15.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_2.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_2.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_3.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_3.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_4.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_4.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_5.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_5.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_6.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_6.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_7.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_7.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_8.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_8.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_9.ipynb new file mode 100755 index 00000000..e3d4fa14 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter7_9.ipynb @@ -0,0 +1,114 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:748883adf9987fa80917596c14388a91ad8fe34d417a5435c22239cebb03b99e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "7.OPERATORS AND EXPRESSION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.1,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number = 19+9\n", + "print \"The month of Februry has\",number,\"days\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The month of Februry has 28 days\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.4.2,page number:145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "number=15\n", + "total=number*4\n", + "print total,\"is 4 times greater than\",number,\"number.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60 is 4 times greater than 15 number.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "7.8.1,page number:150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "m = 2\n", + "n = 12.34\n", + "result=m*n\n", + "print m,\"*\",n,\"=\",result\n", + "print result,\"in scientific notation is\",\"{:.2E}\".format(result)\n", + "print m,\"*\",n,\"=\",round(result)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2 * 12.34 = 24.68\n", + "24.68 in scientific notation is 2.47E+01\n", + "2 * 12.34 = 25.0\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_1.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_1.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_10.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_10.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_11.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_11.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_12.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_12.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_13.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_13.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_14.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_14.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_15.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_15.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_2.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_2.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_3.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_3.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_4.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_4.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_5.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_5.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_6.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_6.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_7.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_7.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_8.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_8.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_9.ipynb new file mode 100755 index 00000000..02731f67 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter8_9.ipynb @@ -0,0 +1,139 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9ca261b12dda6340bfb56a529d7d5db69661ff51a7fd92655edb700a9cae8e3b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "8.MANAGING INPUT AND OUTPUT OPERATORS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.1.1,page number:152" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"tce\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "tce\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.2.1,page number:153" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Text :\"\n", + "str=raw_input()\n", + "print \"Text entered is:\\n\",str" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Text :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text entered is:\n", + "C programming Language is modern and advanced;it enables adressing bits and bytes.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "8.3.1,page number:155" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter an Integer :\"\n", + "number=int(input())\n", + "print \"The Square Of \",number,\"is\",number*number" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter an Integer :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Square Of 6 is 36\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_1.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_1.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_1.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_10.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_10.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_10.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_11.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_11.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_11.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_12.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_12.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_12.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_13.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_13.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_13.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_14.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_14.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_14.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_15.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_15.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_15.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_2.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_2.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_2.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_3.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_3.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_3.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_4.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_4.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_4.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_5.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_5.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_5.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_6.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_6.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_6.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_7.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_7.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_7.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_8.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_8.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_8.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_9.ipynb b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_9.ipynb new file mode 100755 index 00000000..c59dc853 --- /dev/null +++ b/Computer_Concepts_and_C_Programming_by_R.Rajaram/chapter9_9.ipynb @@ -0,0 +1,832 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cf6bdce268b89df5f08741df390466a4ba8e95dbdba72ee30279eb61d19897af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "9 : DECISION MAKING,BREAKING BRANCHING AND LOOPING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.1.1,page number:156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Type an Integer\"\n", + "numb=int(input())\n", + "if numb<=5:\n", + " print \"Good Choice!\"\n", + "print \"Thank You!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Type an Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Good Choice!\n", + "Thank You!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.2.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter year : \"\n", + "year= int(input())\n", + "if year%4 == 0 and year%100 != 0 or year%400 == 0:\n", + " print year,\"is a leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter year : \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.1,page number:157" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Year :\"\n", + "year=int(input())\n", + "if year%4 == 0 :\n", + " if year % 100 != 0:\n", + " print year,\"is leap year\"\n", + " else:\n", + " if year%400 == 0:\n", + " print year,\" is leap year\"\n", + "else:\n", + " print year,\"is not a leap year\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Year :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1990 is not a leap year\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.3.2,page number:158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter the number\"\n", + "numb =int(input())\n", + "if numb<=100:\n", + " if numb>=30:\n", + " print numb,\"lies between 30-100\"\n", + " else:\n", + " print numb,\"is outside 30-100\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "40\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "40 lies between 30-100\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.4.1,page number : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter choice of city(1-4)\"\n", + "city = int(input())\n", + "if city == 1:\n", + " print \"Madurai\"\n", + "elif city == 2:\n", + " print \"Chennai\"\n", + "elif city == 3:\n", + " print \"Mumbai\"\n", + "elif city == 4:\n", + " print \"Calcutta\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter choice of city(1-4)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mumbai\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.5.1,page number:159" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "numb=int(input(\"Enter the number\"))\n", + "if numb == 0:\n", + " print \"prints case0\"\n", + "elif numb == 1:\n", + " print \"prints case1\"\n", + "elif numb == 2:\n", + " print \"prints case2\" \n", + "else:\n", + " print" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the number2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "prints case2\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.6.1,page number : 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import array\n", + "i =20\n", + "variable =array.array('i',[])\n", + "size = 0\n", + "\n", + "def get_array_size():\n", + " print \"Array-size :\"\n", + " global size\n", + " size=int(input())\n", + " if size<1 or size>i :\n", + " get_array_size()\n", + " \n", + "def input_fetch():\n", + " global size\n", + " global variabless\n", + " for k in range(0,size):\n", + " m=int(input())\n", + " variable.append(m)\n", + " return\n", + "\n", + "def sort_list():\n", + " global variable\n", + " variable= array.array('i',sorted(variable))\n", + " \n", + " return\n", + " \n", + "def output():\n", + " for k in range(0,size):\n", + " print variable[k],\n", + " return\n", + "\n", + "def even(number):\n", + " if number/2 == 0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "get_array_size()\n", + "input_fetch()\n", + "sort_list()\n", + "print \"The sorted list is :\"\n", + "output()\n", + "print \"\\nMedian : \",\n", + "\n", + "median=round((variable[(size/2)-1]+variable[size/2])/2,3) if even(size) else float(variable[size/2])\n", + "print median" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Array-size :\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "13\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The sorted list is :\n", + "-4 0 5 6 6 7 8 13 17 25 \n", + "Median : 7.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.8.1,page number:163" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "index = 1\n", + "while index<12:\n", + " print \"This is line \",index\n", + " index+=1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line 1\n", + "This is line 2\n", + "This is line 3\n", + "This is line 4\n", + "This is line 5\n", + "This is line 6\n", + "This is line 7\n", + "This is line 8\n", + "This is line 9\n", + "This is line 10\n", + "This is line 11\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.1,page number:164" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer\"\n", + "total_sum=0\n", + "numb=int(input())\n", + "while numb>0:\n", + " digit=numb %10\n", + " total_sum+=digit\n", + " numb/=10\n", + "print \"Sum is \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1776\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum is 21\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.9.2,page number:165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Enter Integer:\"\n", + "numb=int(input())\n", + "print numb,\"is reversed as \",\n", + "while numb>0:\n", + " digit=numb%10\n", + " print digit,\n", + " numb/=10\n", + "print \"\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Integer:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1234 is reversed as 4 3 2 1 \n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.1,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for index in range(1,11):\n", + " print \" line \",index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " line 1\n", + " line 2\n", + " line 3\n", + " line 4\n", + " line 5\n", + " line 6\n", + " line 7\n", + " line 8\n", + " line 9\n", + " line 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.2,page number:166" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Result\"\n", + "print \"Index Index Squared\"\n", + "print \"_____ _____________\"\n", + "for index in range(1,11):\n", + " print index,\" \",index*index" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Result\n", + "Index Index Squared\n", + "_____ _____________\n", + "1 1\n", + "2 4\n", + "3 9\n", + "4 16\n", + "5 25\n", + "6 36\n", + "7 49\n", + "8 64\n", + "9 81\n", + "10 100\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.10.3,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "total_sum=0\n", + "value=100\n", + "for index in range(1,value+1):\n", + " total_sum+=index\n", + "print \"Sum of 1 to \",value,\" = \",total_sum" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum of 1 to 100 = 5050\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "9.11.1,page number:167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def exceptive():\n", + " for index in range(1,90):\n", + " if index%5 == 0:\n", + " continue\n", + " print index\n", + "exceptive()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n", + "4\n", + "6\n", + "7\n", + "8\n", + "9\n", + "11\n", + "12\n", + "13\n", + "14\n", + "16\n", + "17\n", + "18\n", + "19\n", + "21\n", + "22\n", + "23\n", + "24\n", + "26\n", + "27\n", + "28\n", + "29\n", + "31\n", + "32\n", + "33\n", + "34\n", + "36\n", + "37\n", + "38\n", + "39\n", + "41\n", + "42\n", + "43\n", + "44\n", + "46\n", + "47\n", + "48\n", + "49\n", + "51\n", + "52\n", + "53\n", + "54\n", + "56\n", + "57\n", + "58\n", + "59\n", + "61\n", + "62\n", + "63\n", + "64\n", + "66\n", + "67\n", + "68\n", + "69\n", + "71\n", + "72\n", + "73\n", + "74\n", + "76\n", + "77\n", + "78\n", + "79\n", + "81\n", + "82\n", + "83\n", + "84\n", + "86\n", + "87\n", + "88\n", + "89\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit