Giter VIP home page Giter VIP logo

cz1003introduction_to_computationalthinking's People

Contributors

t170815518 avatar

Watchers

 avatar  avatar

cz1003introduction_to_computationalthinking's Issues

Week 8 LAMS

Decomposition (Divide and Conquer)

definition breaking down the complex problem into smaller manageable parts.
*Note: every subsolution needs to be synthesized to form the final solution *

Recursion

definition the function calls itself
function body: base case(conquer), recursive step(divide)
*But recursion may not be efficient

Discussion question #7

Recursion: base case+recursive rules

  • sometimes

Binary trees expression: e.g. [[left child], node, []]

Lab 7

answerList = random.sample([1,2,3,4,5,6,7,8,9,0], 4) choose 4 unique elements from the sample list [read more]
Integer is not iteratable
Three steps

  1. initialization: draw the maze, set the boundaries, set the target
  2. get the input: move the marble, and get the new positions
  3. check the boundaries

sum(board,[]) reduce the dimension of the list board

Lab 6

Fundamental knowledge

  1. the index of tuple also starts from 0
  2. interger is not iterable or subscriptable. i.e. 3[0] is TypeError
  3. mutable objects pass themselves when there is function-call, that is parameter and argument point to the same list; immutable means pointing to a new object.
  para = para[:]```
But the case above, para is new copy of the original list 
# Discussion 
```python
while data['score'] != -1:
...

Main Programme should only show the top-level flow

Decomposition means focus.

Data base implementation

keyerror is common

Module

any python files can be references as a module
module name is the filename without '.py'

when we import the module, the main program will be executed.

Unit Test

in modules, the main program is necessary for the unit test within the module

  1. before imported, the codes in the main program should be commented to "hide" the program
  2. A better way, add a line before the main program
if __name__='__main__':
  • when the module file is executed as

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.