Presentation is loading. Please wait.

Presentation is loading. Please wait.

GIS 4107 – Week 5. David Francey … working in Toronto train yards, the Yukon bush, and as a carpenter in the Eastern Townships … releases his first CD.

Similar presentations


Presentation on theme: "GIS 4107 – Week 5. David Francey … working in Toronto train yards, the Yukon bush, and as a carpenter in the Eastern Townships … releases his first CD."— Presentation transcript:

1 GIS 4107 – Week 5

2 David Francey … working in Toronto train yards, the Yukon bush, and as a carpenter in the Eastern Townships … releases his first CD in 1999 at the age of 42. Look for songs “Waking Hour”,Waking Hour “Broken Glass”, “Lucky Man”, “Paper Boy”, …Broken GlassLucky ManPaper Boy

3 Evernote can be your exocortexexocortex “As marvelous as the brain is, we can turbocharge it by providing some key support.” Check out Evernote (video)video

4 Overview Miscellaneous PATH and utility scripts folder Types of error: syntax, logic, run-time Decision / branching / selection structures True & False in Python Relational & Boolean operators if … if … else if … elif … else

5 PATH and utility scripts folder Create and use a folder (e.g. C:\utils) on your system for useful scripts and executables (bat, py, exe, etc.) Video

6 Types of error Syntax Not obeying the rules of the language e.g. Not putting “:” at end of function header line Run-time Program failure while it runs. e.g. Unexpected input (string instead of number) Logic / Semantic Programmer makes mistake in coding that produces unexpected results. e.g. Invalid branching statement

7 Program flow overview Programs in any language have three types of flow Sequential Decision/Branching/Selection Repetition Combined in two ways Stacking Nesting Next week

8 Sequential - stacked

9 Decision / Branching / Selection Branching depends on a conditional expression Conditional expressions must evaluate to True or False How does the programming language represent True or False? How does the language make comparisons?

10 True & False in Python True and False are also True and False values True valuesFalse Values Non-zero numbers (postive & negative) 0 Non-empty stringEmpty string Non-empty listEmpty list Non-empty tupleEmpty tuple Non-empty dictionaryEmpty dictionary not None Null object (None)

11 Comparison operators & Boolean expressions With earlier versions of Python: True = 1 False = 0 Relational operators in Gaddis

12 if … If true, do. If not true (false), do not do. if …is a single-alternative decision structure Syntax: Indented statements!

13 True or False …

14 if … else if … else is a dual-alternative decision structure UML Activity Diagram If true, do. If not true (false), do something else.

15 if … elif … else Syntax: if … elif … else is a multi-alternative decision structure

16 Nested if Only execute the “nested if” when the “parent if” is true

17 Logical operators: and or not Short-circuit evaluation For “and”, if left side is False, right side is not evaluated. For “or”, if left side is True, right side is not evaluated.

18 Order of evaluation (precedence)

19 String comparisons Python uses ASCII codes to determine character values that are used in Boolean expressions.

20 Boolean expression as a value Same result as above if … else

21 We’re done


Download ppt "GIS 4107 – Week 5. David Francey … working in Toronto train yards, the Yukon bush, and as a carpenter in the Eastern Townships … releases his first CD."

Similar presentations


Ads by Google