diff --git a/README.md b/README.md index 4e7e212..6870a5f 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ The official book of the course, C
2. [16/10/24, *the*] Introduction to Computational Thinking - book chapter: [PDF](https://comp-think.github.io/book/01.pdf), [Google Docs](https://comp-think.github.io/book/01) + - slides: [HTML](https://comp-think.github.io/2024-2025/slides/01%20-%20Introduction%20to%20Computational%20Thinking.html) + - exercises: [1](https://github.com/comp-think/2024-2025/issues/1), [2](https://github.com/comp-think/2024-2025/issues/2), [3](https://github.com/comp-think/2024-2025/issues/3)
3. [18/10/24, *the*] Algorithms - book chapter: [PDF](https://comp-think.github.io/book/02.pdf), [Google Docs](https://comp-think.github.io/book/02) diff --git a/docs/slides/.gitignore b/docs/slides/.gitignore index df47ac2..cb135c4 100644 --- a/docs/slides/.gitignore +++ b/docs/slides/.gitignore @@ -1,4 +1,3 @@ -01* 02* 03* 04* diff --git a/docs/slides/01 - Introduction to Computational Thinking.html b/docs/slides/01 - Introduction to Computational Thinking.html new file mode 100755 index 0000000..fd2f091 --- /dev/null +++ b/docs/slides/01 - Introduction to Computational Thinking.html @@ -0,0 +1,361 @@ + + + + + + + Introduction to Computational Thinking + + + + + + + + + + + + + + + +
+
+
+

Introduction to Computational Thinking

+
+
+ +
+

Communication 1

+

Books: Computational Thinking and Programming book (official book of the course - it includes more than 100 exercises with keys!) + accompanying book How To Code in Python

+

Other material: available in the GitHub repository of the course at https://github.com/comp-think/2024-2025/

+
+ +
+

Communication 2

+

As of yesterday, several people have subscribed to the Discord server and has been added to the Discord role for this course (comp-think-24-25)

+

Please subscribe to the Discord server as soon as possible

+

Invitation link to join the group:
https://discord.gg/FQw229MF

+

Once you entered in the main lobby of the server, I will add you the role to see the private channel dedicated to the course (comp-think-24-25)

+
+ +
+

Communication 3

+

We will use the GitHub repository of the course for a series of activities, such as exercises and raising issues

+

Thus, please, create a new account on GitHub: https://github.com/join

+
+ +
+

Communication 4

+

The video of the previous lecture and those of today's lecture and the following one will be made available on the Virtuale space of the course

+

https://virtuale.unibo.it/course/view.php?id=65719

+
+ +
+

Any question about the previous lecture?

+
+ +
+

Historic hero: Noam Chomsky

+ +

Founders of the cognitive science field

+

Father of the modern linguistics

+

Provided a classification for formal grammars

+

A formal grammar is a mathematical tool for defining a language (e.g. English) according to a finite set of production rules, that allows one to construct any syntactic valid sentence of such language

+
+ +
+

Types of formal grammars

+
    +
  • regular grammars (the least expressive)

  • +
  • context-free grammars

  • +
  • context-sensitive grammars

  • +
  • recursively enumerable grammars (the most expressive)

  • +
+

All specify constraints on the way one can use terminal and non-terminal symbols

+
    +
  • terminals are elementary symbols of the language (e.g. words), e.g. "write"

  • +
  • non-terminals (e.g. <sentence>) can be replaced by a combination of terminal and non-terminal symbols

  • +
+
+ +
+

Example of formal grammar

+

A simple grammar defined using the Backus-Naur form

+
<sentence> ::= <pronoun> "write"
+<pronoun> ::= "I"
+<pronoun> ::= "you"
+
+

Is the sentence I write part of the language defined by the aforementioned grammar?

+
<sentence> ⇒
+<pronoun> "write" ⇒
+"I" "write"
+

The sentence I write is part of the language

+
+
+ +
+

Meaning: part 1

+

Computational Thinking and Programming

+

Definition of computational (Oxford Dictionary): using or relating to computers

+

A computer (today): electronic device

+

A computer (before advent of electronic computers): a person who performs mathematical calculations

+
+ +
+

Human computers

+

Groups of people who have to undertake long calculations for specific experiments or measurements

+

In astronomy: used for calculating astronomical coordinates of non-terrestrial things – such as the calculation of passages of Halley's Comet by Alexis Claude Clairaut and colleagues

+

In commerce: Napoleon imposed the creation of mathematical tables to convert quantities from the old imperial system of measurements to the new metric system

+
+ +
+

Towards electronic computers

+

In 1822, Charles Babbage developed the Difference Engine and then the Analytical Engine - the latter one was programmable, making it the very first mechanical general-purpose computer in history

+
+ +

Babbage's Difference Engine

+
+
+ +

Babbage's Analytical Engine

+
+
+ +
+
+

Programmable what?

+
+ +

Babbage's Difference Engine

+

No additional operations permitted

+
+
+ +

Babbage's Analytical Engine

+

Space for additional operations

+
+
+
+

Programmable what?

+
+ +

Babbage's Difference Engine

+

No additional operations permitted

+
+
+ +

Babbage's Analytical Engine

+

User defines new operations

+
+
+
+ +
+

Electronic computers

+
+ +
+

The ideas presented in the Analytical Engine were developed in a physical machine only one century later, since computing technology has had a drastic change as a consequence of World War II

+

In 1946, US developed the Electronic Numerical Integrator and Computer (ENIAC), a programmable computer through patch cables and switches - the fixed point in time that generated all modern computers

+
+ +
+

Our take

+

In this course, with computer we mean any information-processing agent (i.e. a person or a machine acting mechanically if appropriately instructed) that can make calculations and produce some output starting from input

+
+ +
+

Meaning: part 2

+

Computational Thinking and Programming

+

The word programming stands for programming language

+

Natural language vs Programming language

+
+ +
+

Natural language

+

An ordinary language (e.g. English), either written or oral, that has evolved naturally in humans, usually without a specific and premeditated planning

+

Usually, natural languages are very expressive but intrinsically ambiguous

+
+

by Groucho Marx, a line from a memorable joke

+

One morning I shot an elephant in my pajamas

+
+
+ +
+

Programming language

+

A formal-born language, defined using Chomsky's context-free languages, usually

+

They oblige to specific syntactic rules that avoid possible ambiguous statements, mainly by restricting the expressiveness of the language

+

All the sentences in such language are conveying just one possible meaning

+
+ +
+

Kinds of languages 1/2

+
+

Machine language

+
100010110101010000100100000010001000001111111010000000000111011100000110101110000000000000000000000000000000000011000011100000111111101000000010011101110000011010111000000000010000000000000000000000001100001101010011101110110000000100000000000000000000000010111001000000010000000000000000000000001000110100000100000110011000001111111010000000110111011000000111100010111101100110001001110000010100101011101011111100010101101111000011
+
+
+

Low-level programming language

+
fib:
+    mov edx, [esp+8]
+    cmp edx, 0
+    ja @f
+    mov eax, 0
+    ret
+    
+    @@:
+    cmp edx, 2
+    ja @f
+    mov eax, 1
+    ret
+    
+    @@:
+    push ebx
+    mov ebx, 1
+    mov ecx, 1
+ +
    @@:
+        lea eax, [ebx+ecx]
+        cmp edx, 3
+        jbe @f
+        mov ebx, ecx
+        mov ecx, eax
+        dec edx
+    jmp @b
+    
+    @@:
+    pop ebx
+    ret
+
+
+ +
+

Kinds of languages 2/2

+
+

High-level programming language

+
unsigned int fib(unsigned int n) {
+    if (n <= 0) return 0;
+    else if (n <= 2) return 1;
+    else {
+        unsigned int a,b,c;
+        a = 1;
+        b = 1;
+        while (1) {
+            c = a + b;
+            if (n <= 3) return c;
+            a = b;
+            b = c;
+            n--;
+        }
+    }
+}
+
+
+

Natural language

+
The function for calculating the nth Fibonacci number takes as input an integer “n”. If “n” is less than or equal to 0, then 0 is returned as a result. Otherwise, if “n” is less than or equal to 2, then 1 is returned. Otherwise, in all the other cases, associate the value “1” to two distinct variables “a” and “b”. Then, repeat the following operations indefinitely. Set the variable “c” as the sum of “a” plus “b”. If “n” is less than or equal to “3” then return “c”, otherwise assign the value of “b” to “a” and the value of “c” to “b”, and finally decrease the value of “n” by 1 before repeating.
+
+
+ +
+

Meaning: part 3

+

Computational Thinking and Programming

+

To think (definition, Oxford Dictionary): use one's mind actively to form connected ideas

+

Addressed in the previous lecture! Some lesson learnt:

+
    +
  • Leaving out unneeded material

  • +
  • Trial-and-error prodedure may be effective

  • +
  • Recognising similarity of a problem to one already solved makes the problem easier to solve

  • +
  • Use of patterns provided by experience is the most rapid way of solving problems

  • +
+ +
+ +
+

Human-computer communication

+

Writing a program: communicating to a computer in a (formal) language that such a computer and the human instructor can both understand

+

What we need:

+
    +
  1. agree on which language to use for the communication between us and a computer (either human or machine)

  2. +
  3. think about possible instructions that, if followed systematically by the computer, can enable it to return the expected result to a certain problem

  4. +
+
+ +
+

What are they?

+

+

Two objects, each composed by a stack of usually rectangular pages (346 and 288 respectively) made of paper oriented with one edge fixed together and then bound to the flexible spine of a protective cover of heavier material, containing a text written by someone (Lewis Carroll) in a natural language (Italian and English respectively)

+
+ +
+

Abstraction is the key

+

The process of leaving out of consideration one or more properties of a complex object or situation by extracting common features from specific examples

+

+
+ +
+

What is Computational Thinking

+

An approach for solving problems, designing systems and understanding human behaviour that draws on concepts fundamental to computing

+

Reshape the abstractions we have ingested as consequence of our life experiences – that we are unconsciously reusing

+

Being again fully conscious of such abstractions, we can use an appropriate language for making them understandable to a computer, in order to automatise them

+

Final goal of Computational Thinking: to complement the other thinking strategies one has already learnt in the past with another tool to describe reality

+
+ +
+

+ END + Introduction to Computational Thinking +

+ +
+
+
+ + + + + + +