summaryrefslogtreecommitdiff
path: root/Programming_in_C/Chapter_09.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Programming_in_C/Chapter_09.ipynb')
-rw-r--r--Programming_in_C/Chapter_09.ipynb37
1 files changed, 0 insertions, 37 deletions
diff --git a/Programming_in_C/Chapter_09.ipynb b/Programming_in_C/Chapter_09.ipynb
index 684317a5..56b0b95f 100644
--- a/Programming_in_C/Chapter_09.ipynb
+++ b/Programming_in_C/Chapter_09.ipynb
@@ -27,10 +27,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.1.py\n",
- "#Illustrating a Structure/Class in python\n",
"\n",
- "#Main()\n",
"def main():\n",
"\n",
" #Class Declaration\n",
@@ -55,7 +52,6 @@
" print(\"Today's date is {0}/{1}/{2}\".format(today.month,today.day,today.year%100));\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -84,10 +80,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.2.py\n",
- "#Determining Tomorrows Date\n",
"\n",
- "#Main()\n",
"def main():\n",
" #Class Declaration\n",
" class date:\n",
@@ -125,7 +118,6 @@
" print(\"Tomorrow's date is {0}/{1}/{2}\\n\".format(tomorrow.month,tomorrow.day,tomorrow.year));\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -156,10 +148,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.3.py\n",
- "#Revising the Program to Determine Tomorrow's Date\n",
"\n",
- "#Class Declaration\n",
"class date:\n",
" def __init__(self): #Class Constructor\n",
" #Default values\n",
@@ -168,7 +157,6 @@
" year=0\n",
" \n",
"\n",
- "#Main()\n",
"def main():\n",
" #creating instances\n",
" today=date()\n",
@@ -196,7 +184,6 @@
" print(\"Tomorrow's date is {0}/{1}/{2}\\n\".format(tomorrow.month,tomorrow.day,tomorrow.year));\n",
"\n",
"\n",
- "#Function to find the number of days in a month \n",
"def numberOfDays(d):\n",
" \n",
" #List Declaration\n",
@@ -209,7 +196,6 @@
" return days\n",
"\n",
"\n",
- "#Function to determine if it's a leap year\n",
"def isLeapYear(d):\n",
" if ( (d.year % 4 == 0 and d.year % 100 != 0) or d.year % 400 == 0 ):\n",
" leapYearFlag = True # Its a leap year\n",
@@ -220,7 +206,6 @@
"\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -251,10 +236,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.4.py\n",
- "#Revising the Program to Determine Tomorrow's Date--Version 2\n",
"\n",
- "#Class Declaration\n",
"class date:\n",
" def __init__(self): #Class Constructor\n",
" #Default values\n",
@@ -282,7 +264,6 @@
"\n",
"\n",
"\n",
- "#Main()\n",
"def main():\n",
" #creating instances\n",
" thisDay=date()\n",
@@ -299,7 +280,6 @@
"\n",
"\n",
"\n",
- "#Function to find the number of days in a month \n",
"def numberOfDays(d):\n",
" \n",
" #List Declaration\n",
@@ -313,7 +293,6 @@
"\n",
"\n",
"\n",
- "#Function to determine if it's a leap year\n",
"def isLeapYear(d):\n",
" if ( (d.year % 4 == 0 and d.year % 100 != 0) or d.year % 400 == 0 ):\n",
" leapYearFlag = True # Its a leap year\n",
@@ -324,7 +303,6 @@
"\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -355,10 +333,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.5.py\n",
- "#Updating the Time by One Second\n",
"\n",
- "#Class Declaration\n",
"class time:\n",
" def __init__(self):\n",
" hour=0\n",
@@ -379,7 +354,6 @@
"\n",
" return now\n",
"\n",
- "#Main()\n",
"def main():\n",
" #Creating instances\n",
" currentTime=time()\n",
@@ -396,7 +370,6 @@
"\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -427,13 +400,9 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.6.py\n",
- "#Illustrating Arrays of Structures\n",
"\n",
- "#Import sys Library\n",
"import sys\n",
"\n",
- "#Class Declaration\n",
"class time:\n",
" def __init__(self,h,m,s):\n",
" #Variable Declarations\n",
@@ -455,7 +424,6 @@
"\n",
" return now\n",
"\n",
- "#Main()\n",
"def main():\n",
" #Creating instances\n",
" testTimes = []\n",
@@ -477,7 +445,6 @@
"\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],
@@ -510,11 +477,8 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "#9.7.py\n",
- "#Illustrating Structures and Arrays\n",
"\n",
"\n",
- "#Main()\n",
"def main():\n",
" #Class Declaration\n",
" class month:\n",
@@ -545,7 +509,6 @@
" print(\"{0}{1}{2} {3}\\n\".format(months[i].name[0],months[i].name[1],months[i].name[2], months[i].numberOfDays))\n",
"\n",
"\n",
- "#Setting top level conditional script\n",
"if __name__=='__main__':\n",
" main()"
],