summaryrefslogtreecommitdiff
path: root/Programming_in_C/Chapter_19.ipynb
diff options
context:
space:
mode:
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