summaryrefslogtreecommitdiff
path: root/Programming_in_C/Chapter_19.ipynb
diff options
context:
space:
mode:
authorJovina Dsouza2014-06-18 12:43:07 +0530
committerJovina Dsouza2014-06-18 12:43:07 +0530
commit206d0358703aa05d5d7315900fe1d054c2817ddc (patch)
treef2403e29f3aded0caf7a2434ea50dd507f6545e2 /Programming_in_C/Chapter_19.ipynb
parentc6f0d6aeb95beaf41e4b679e78bb42c4ffe45a40 (diff)
downloadPython-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.tar.gz
Python-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.tar.bz2
Python-Textbook-Companions-206d0358703aa05d5d7315900fe1d054c2817ddc.zip
adding book
Diffstat (limited to 'Programming_in_C/Chapter_19.ipynb')
-rw-r--r--Programming_in_C/Chapter_19.ipynb70
1 files changed, 70 insertions, 0 deletions
diff --git a/Programming_in_C/Chapter_19.ipynb b/Programming_in_C/Chapter_19.ipynb
new file mode 100644
index 00000000..d92a3f41
--- /dev/null
+++ b/Programming_in_C/Chapter_19.ipynb
@@ -0,0 +1,70 @@
+{
+ "metadata": {
+ "name": "Chapter XIX"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 19: Object-oriented programming"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": [
+ "Program 19.1, Page number: 414"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#19.1.py\n",
+ "#Working with fractions in python\n",
+ "\n",
+ "#Class declaration\n",
+ "class Fraction:\n",
+ " def __init__(self): #Class constructor\n",
+ " self.numerator=0\n",
+ " self.denominator=0\n",
+ "\n",
+ "#Main()\n",
+ "def main():\n",
+ "\n",
+ " #Creating instance\n",
+ " myFract=Fraction()\n",
+ " myFract.numerator=1\n",
+ " myFract.denominator=3\n",
+ "\n",
+ " print(\"The Fraction is {0}/{1}\".format(myFract.numerator,myFract.denominator))\n",
+ "\n",
+ "#Setting top level conditional script\n",
+ "if __name__=='__main__':\n",
+ " main()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Fraction is 1/3\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file