Upload
yi-lung-tsai
View
3.155
Download
6
Embed Size (px)
DESCRIPTION
Slides for http://interactivepython.org/runestone/static/pythonds/index.html
Citation preview
Problem Solving with Algorithms and Data
Structures
Bruce Tsai
Computer Science
• Algorithm
• Step-by-step procedure for calculations
• Data structure
• Way of organizing data
Problem-solving• Human
• Time consuming
• Computer
• Efficiency
• Reuse
• Communication tool
• Program
• Method and Data
• Mathematical model
• Input/Output
Sorting Example
50, 19, 1, 120, 6, 5, 999
1, 5, 6, 19, 50, 120, 999
Python Data Type
• int
• float
• bool
• weak type
• dynamic strongly type
Python Collection
• List []
• ordered
• duplicate elements
• mutable
• compound data
• Tuple ()
• ordered
• duplicate elements
• immutable
• heterogeneous data
Python Collection
• Set {}, set()
• unordered
• no duplicate elements
• mutable
• heterogeneous data
• Dictionary { key: value}
• key-value pair
• no duplicate keys
• mutable
• heterogeneous data
Python String
• “” or ‘’
• ordered
• duplicate elements
• immutable
• homogeneous
Python Control Structure
• while
• execute code repeatedly based on given condition
• for
• allow code to repeatedly executed
• if, elif, else
• perform different computations depending on condition
Exception
• Syntax error
• Logical error (runtime error)
• Exception
• prevent program to terminate from runtime error
Function
• Mathematical function
• Black box
• Input/Output
Reference
• http://interactivepython.org/runestone/static/pythonds/index.html
• https://docs.python.org/2/tutorial/
• http://zeroturnaround.com/rebellabs/there-is-more-to-code-quality-than-just-pretty-vs-ugly/