Documente Academic
Documente Profesional
Documente Cultură
DR JAMES MILLINGTON
DR JON READES
TERM 1 2017/18
Module Aims
to build competence in the use of computational techniques for
cleaning, exploring, visualising and performing reproducible
analysis on data.
Learning Outcomes
understand commonly-used computational techniques and be
able to employ them appropriately
MODULE SYLLABUS
KEATS
MODULE SYLLABUS
Physical Human
Computation
GEOCOMPUTATION TO BRIDGE THE GAP?
Geography
Conway (2013)
A NEW QUANT. REVOLUTION
147642
What ways could we find the average (mean) of these
numbers?
ALGORITHM: FIND THE AVERAGE
Code vs GUI
CODE: FIND THE AVERAGE
COMPUTERS: GOOD OR BAD?
Flexibility
Reproducibility
Scalability
COMPUTER LANGUAGES
Calculating
the mean
in R
Calculating
the mean
in Python
VARIABLES
Hello
message string
Python!
n 42 integer
pi 3.14159 float
THINKING LOGICALLY
Conditional Execution:
Only execute code in given conditions
CONDITIONAL EXECUTION
Conditional
Reserved word Operator colon
if hours > 0:
print(Hours were worked)
indentation
if hours > 0:
print(Hours were worked)
x == y # x is equal to y
x != y # x is not equal to y
x > y # x is greater than y
x < y # x is less than y
x >= y # x is greater than or equal to y
x <= y # x is less than or equal to y
x is y # x is the same as y
x is not y # x is not the same as y
and or not
if hours > 0:
print(Hours were worked)
else:
print(No hours worked)
if hours > 0:
print(Hours were worked)
else:
print(No hours worked)
hours > 0
False
True
print(Hours were print(Hours were
worked) worked)
CHAINED CONDITIONAL
if hours > 0:
print(Hours were worked)
elif hours == 0:
print(No hours worked)
else:
print(invalid input)
print(Hours were
hours > 0
worked) Yes
No
Because of the way the computer stores float values they may
not be actually exactly as they appear
Example: 2.51 cannot be represented by a float and is represented by a
number very close to it
Advice:
Only use == or != to compare int or string types
Use only < or > to compare floats
For more detail than you can handle read this or watch this
INDENTING AND COLONS
if hours > 0:
print(Hours were worked)
Incorrect
else
print(No hours worked)