unit 2: programming - david-abel.github.io · 1001… 0011… 0101 ... romeo, a young man with a...
TRANSCRIPT
![Page 1: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/1.jpg)
1
February 12th, 2016
Dave Abel
Unit 2: Programming
![Page 2: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/2.jpg)
Outline for Today
2
‣ Revisit clicker question from Wednesday
‣ Finish Scratch Overview (Lists, Randomness)
‣ Demystify how programming can reconfigure a computer
‣ Close the unit with a quick look at other languages
![Page 3: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/3.jpg)
Clicker Question!
3
Q: Which loop will move the cat more steps?
[A] [B]
[C]
![Page 4: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/4.jpg)
Clicker Answer!
4
Q: Which loop will move the cat more steps?
[A] [B]
[C]
![Page 5: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/5.jpg)
Clicker Question!
5
Why not [C]
[A] [B]
[C]
![Page 6: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/6.jpg)
Clicker Question!
6
Why not [C]
[C]Forever:
1) if counter is 10, move
2) add 1 to counter
![Page 7: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/7.jpg)
Clicker Question!
7
Why not [C]
[C]Forever:
1) if counter is 10, move
2) add 1 to counter
Counter will only be set to 10 one time!
![Page 8: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/8.jpg)
Things You’ll Do in Scratch
8
‣ Machine Learning: Writer a classifier, similar to how your email determines what is “Spam” and what is “Not Spam”!
‣ Programming: A simple game
‣ Vision + NLP: Model Roald Dahl’s style of writing!
‣ Recursion: Draw pretty pictures
‣ And more…
![Page 9: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/9.jpg)
Things You’ll Do in Scratch
9
‣ Machine Learning: Writer a classifier, similar to how your email determines what is “Spam” and what is “Not Spam”!
‣ Programming: A simple game
‣ Vision + NLP: Model Roald Dahl’s style of writing!
‣ Recursion: Draw pretty pictures
‣ And more…
![Page 10: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/10.jpg)
Block Types
10
Event/Trigger (e.g. when clicked)
Ending StatementBoolean ValueNumeric Value
Container (loops, if statements)
Statement (e.g. move cat)
String Value
![Page 11: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/11.jpg)
More Scratch Things: Lists
11
Idea: a collection of things.
![Page 12: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/12.jpg)
12
Idea: a collection of things.
Q: What’s the biggest number in “numbers”?Q: Is there a kiwi in the “basket”?
More Scratch Things: Lists
![Page 13: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/13.jpg)
Lists
13
Index
![Page 14: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/14.jpg)
Lists
14
Index Contents
![Page 16: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/16.jpg)
Clicker Question:
16
Q: What will “numbers” look like after running this block?
![Page 17: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/17.jpg)
Clicker Question:
17
Q: What will “numbers” look like after running this block?
[A] [B] [C]
![Page 18: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/18.jpg)
Clicker Question:
18
Q: What will “numbers” look like after running this block?
[A] [B] [C] Hint: Think about the basket!
![Page 19: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/19.jpg)
Clicker Question:
19
Q: What will “numbers” look like after running this block?
[A] [B] [C] Hint: Think about the basket!
![Page 20: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/20.jpg)
Clicker Question:
20
Q: What will “numbers” look like after running this block?
Hint: Think about the basket!
Index Contents
![Page 21: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/21.jpg)
Clicker Question:
21
Q: What will “numbers” look like after running this block?
Hint: Think about the basket!
Index
We will always grab thing from
lists by their index
![Page 23: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/23.jpg)
Clicker Question!
23
Q: What does the mystery block do?
![Page 24: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/24.jpg)
Clicker Question!
24
Q: What does the mystery block do?
(A) Counts the number of total items in the list “basket”
(B) Finds the longest fruit name in “basket”
(C) Looks through basket, counting the number of items with the name parameter
(D) Finds the the index of the item with the name of parameter
(E) Looks through basket to determine if an item with the name parameter is in it.
![Page 25: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/25.jpg)
Clicker Answer!
25
Q: What does the mystery block do?
(A) Counts the number of total items in the list “basket”
(B) Finds the longest fruit name in “basket”
(C) Looks through basket, counting the number of items with the name parameter
(D) Finds the the index of the item with the name of parameter
(E) Looks through basket to determine if an item with the name parameter is in it.
![Page 26: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/26.jpg)
Recall: Unit 2 Takeaway
26
Programming lets us reconfigure what a computer does!
![Page 27: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/27.jpg)
Recall: Unit 2 Takeaway
27
Programming lets us reconfigure what a computer does!
Seen some examples:
![Page 28: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/28.jpg)
Recall: Unit 2 Takeaway
28
Programming lets us reconfigure what a computer does!
So how does this work?
![Page 29: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/29.jpg)
The Computer
29
‣ Internal states
‣ Complex logic relating bits
‣ Mechanism for setting bits (input)
‣ Mechanism for displaying bits (output)
Memory
CPU
Mouse
Keyboard
Monitor
![Page 30: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/30.jpg)
30
‣ Internal states
‣ Complex logic relating bits
‣ Mechanism for setting bits (input)
‣ Mechanism for displaying bits (output)
Memory
CPU
Mouse
Keyboard
Monitor
The Computer
![Page 31: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/31.jpg)
Memory
The Computer
….
![Page 32: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/32.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
![Page 33: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/33.jpg)
32 bits32 bits32 bits32 bits32 bits
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
32 bits
32 bit operating system
![Page 34: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/34.jpg)
64 bits64 bits64 bits64 bits64 bits
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
64 bits
64 bit operating system
![Page 35: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/35.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
10KB = 10 Kilobytes
![Page 36: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/36.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
10KB = 10 Kilobytes
1 Kilobyte = 1024 bytes
![Page 37: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/37.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
10KB = 10 Kilobytes
1 Kilobyte = 1024 bytes
(power of 2!!!)
![Page 38: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/38.jpg)
A Quick TangentNumber of Bytes Name
2^10 =1,024 1 Kilobyte
2^20 = 1,048,576 1 Megabyte
2^30 = 1,073,741,824 1 Gigabyte
… …
2^100 = 1,267,650,600,228,229,401,496,703,205,376 ???
Approximate # atoms in the known universe: 10^80
![Page 39: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/39.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
10KB = 10 Kilobytes
1 Kilobyte = 1024 bytes
= 10 * 1024 bytes
![Page 40: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/40.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
= 10 * 1024 bytes
![Page 41: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/41.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
=
![Page 42: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/42.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
![Page 43: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/43.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… 0101… 1110… 0001… 1001…
![Page 44: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/44.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
![Page 45: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/45.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
Commands themselves are also binary
![Page 46: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/46.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
CPU
![Page 47: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/47.jpg)
The Computer
1101…CPU
![Page 48: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/48.jpg)
The Computer
1101…CPU
![Page 49: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/49.jpg)
The Computer
1101…CPU
gets translated into Machine Code:
![Page 50: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/50.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
CPU
![Page 51: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/51.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
CPU
![Page 52: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/52.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
CPU
![Page 53: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/53.jpg)
Memory
The Computer
….100010101010010101000111111001010010100
1001… 0011… … 1101…
CPU
![Page 54: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/54.jpg)
Recap!Becomes
machine code that carries out the “When flag clicked” block, in binary and
logic
![Page 55: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/55.jpg)
Recap!
Becomes machine code that carries out
that block in binary and logic
![Page 56: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/56.jpg)
Abstraction
![Page 57: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/57.jpg)
Abstraction
![Page 58: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/58.jpg)
Abstraction
x,y,size
![Page 59: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/59.jpg)
Abstraction
x,y,size
![Page 60: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/60.jpg)
Abstraction
x,y,size
![Page 61: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/61.jpg)
“Natural Language Programming”
“Cat, draw a triangle” x,y,size
![Page 62: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/62.jpg)
“Natural Language Programming”
“Cat, draw a triangle” x,y,size
Problem:
![Page 63: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/63.jpg)
Other Languages
63
![Page 64: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/64.jpg)
Other Languages: Prolog
64
![Page 65: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/65.jpg)
Esoteric Languages: CHEF
65
Lobsters with Fruit and Nuts.
Ingredients.
72 g hazelnuts
101 eggs
108 g lobsters
…
Method.
Put lemon juice into the mixing bowl.
Put passion fruit into the mixing bowl.
Put durian into the mixing bowl.
Put lobsters into the mixing bowl.
...
![Page 66: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/66.jpg)
66
Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.
…
Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward! You are as
stupid as the difference between a handsome rich brave hero and thyself!
Speak your mind!
…
Esoteric Languages: Shakespeare
![Page 67: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/67.jpg)
Unit 2 Reflection
67
‣ Scratch!
- Drawing Squares
- Loops, Conditions
- Making Blocks
- Variables
- Lists
- Randomness
‣ How do programs reconfigure a computer?
![Page 68: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/68.jpg)
68
Unit 2: Takeaway1. Physical gates are inflexible.
2. Programming lets us reconfigure what a computer does!
![Page 69: Unit 2: Programming - david-abel.github.io · 1001… 0011… 0101 ... Romeo, a young man with a remarkable patience. ... ‣ We’ve seen that programs can solve certain problems,](https://reader031.vdocument.in/reader031/viewer/2022022600/5b40cbfa7f8b9af6438da686/html5/thumbnails/69.jpg)
69
Up Next: Algorithms!‣ We’ve seen that programs can solve certain problems, e.g. “What’s the smallest number in my list?”
‣ What other problems are solvable with programs?
‣ What ones are easy? What ones are hard?
‣ The study of algorithms is the formal study of solving problems using computational tools!
‣ Central idea of computer science.