diff --git a/code3/notry.py b/code3/notry.py new file mode 100644 index 000000000..6258a8603 --- /dev/null +++ b/code3/notry.py @@ -0,0 +1,6 @@ +astr = 'Hello Bob' +istr = int(astr) +print('First', istr) +astr = '123' +istr = int(astr) +print('Second', istr) diff --git a/code3/tryexcept.py b/code3/tryexcept.py new file mode 100644 index 000000000..b8a6e6fd7 --- /dev/null +++ b/code3/tryexcept.py @@ -0,0 +1,16 @@ +astr = 'Hello Bob' +try: + istr = int(astr) +except: + istr = -1 + +print('First', istr) + +astr = '123' +try: + istr = int(astr) +except: + istr = -1 + +print('Second', istr) + diff --git a/code3/trynum.py b/code3/trynum.py new file mode 100644 index 000000000..bf7ba0580 --- /dev/null +++ b/code3/trynum.py @@ -0,0 +1,11 @@ +rawstr = input('Enter a number:') +try: + ival = int(rawstr) +except: + ival = -1 + +if ival > 0 : + print('Nice work') +else: + print('Not a number') + diff --git a/lectures3/Pythonlearn-01-Intro.pptx b/lectures3/Pythonlearn-01-Intro.pptx index 0f6767906..910e651cc 100644 Binary files a/lectures3/Pythonlearn-01-Intro.pptx and b/lectures3/Pythonlearn-01-Intro.pptx differ diff --git a/lectures3/Pythonlearn-02-Expressions.pptx b/lectures3/Pythonlearn-02-Expressions.pptx index 0371833fb..6c8c758c7 100644 Binary files a/lectures3/Pythonlearn-02-Expressions.pptx and b/lectures3/Pythonlearn-02-Expressions.pptx differ diff --git a/lectures3/Pythonlearn-03-Conditional.pptx b/lectures3/Pythonlearn-03-Conditional.pptx index 3e9e53e99..9fdfe2c4b 100644 Binary files a/lectures3/Pythonlearn-03-Conditional.pptx and b/lectures3/Pythonlearn-03-Conditional.pptx differ