CS50 - Lecture 0 - Scratch
CS50 - Lecture 0 - Scratch
● Welcome!
● Website, syllabus, and FAQs at cs50.harvard.edu/college.
● Adding/dropping courses? Try using cs50.courses.
● We'll follow up via email about sections.
● Visit cs50.ly/screen to view projector on your laptop and ask questions
during class via chat. (That link will open an in-class Zoom "webinar.")
● Join us for CS50 Puzzle Day this Sat 9/7, 12pm–3:30pm! Register at cs50.ly/register.
Free 🍕, puzzles, and prizes. And free 👕. Roommates and friends welcome.
● Introduce yourself to 2+ classmates near you (that you don't already know)!
(To break the ice, tell them you're just following this step!)
● We'll take a break partway through class, with cake after class! 🧁
● Do come up and say hi during break or after class!
● Email [email protected] with questions!
most CS50 students
have never taken CS before
what ultimately matters in this course is not so much where
you end up relative to your classmates but where
you end up relative to yourself when you began
computer science
computational thinking
problem solving
input → → output
unary
base-1
base-2
binary digit
binary digit
binary digit
bitnary digi
0
1
base-10
decimal
123
1
123
10 1
123
100 10 1
123
100 10 1
123
100 × 1
100 10 1
123
100 × 1 + 10 × 2
100 10 1
123
100 × 1 + 10 × 2 + 1×3
100 10 1
123
100 + 20 + 3
123
100 10 1
###
102 101 100
###
22 21 20
###
4 2 1
###
4 2 1
000
4 2 1
001
4 2 1
010
4 2 1
011
4 2 1
100
4 2 1
101
4 2 1
110
4 2 1
111
4 2 1
000
8 4 2 1
1000
byte
128 64 32 16 8 4 2 1
00000000
128 64 32 16 8 4 2 1
11111111
A
128 64 32 16 8 4 2 1
01000001
65
ASCII
01001000 01001001 00100001
72 73 33
H I !
72 73 33
Unicode
11110000100111111001100010000010
4036991106
U+1F602
RGB
72 73 33
72 73 33
input → → output
algorithm
algorithm
n
n n/2
n n/2
n n/2
n n/2
log2 n
algorithm
code
pseudocode
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
4 If person is on page
5 Call person
6 Else if person is earlier in book
7 Open to middle of left half of book
8 Go back to line 3
9 Else if person is later in book
10 Open to middle of right half of book
11 Go back to line 3
12 Else
13 Quit
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
4 If person is on page
5 Call person
6 Else if person is earlier in book
7 Open to middle of left half of book
8 Go back to line 3
9 Else if person is later in book
10 Open to middle of right half of book
11 Go back to line 3
12 Else
13 Quit
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
4 If person is on page
5 Call person
6 Else if person is earlier in book
7 Open to middle of left half of book
8 Go back to line 3
9 Else if person is later in book
10 Open to middle of right half of book
11 Go back to line 3
12 Else
13 Quit
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
4 If person is on page
5 Call person
6 Else if person is earlier in book
7 Open to middle of left half of book
8 Go back to line 3
9 Else if person is later in book
10 Open to middle of right half of book
11 Go back to line 3
12 Else
13 Quit
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
4 If person is on page
5 Call person
6 Else if person is earlier in book
7 Open to middle of left half of book
8 Go back to line 3
9 Else if person is later in book
10 Open to middle of right half of book
11 Go back to line 3
12 Else
13 Quit
● functions
○ arguments, return values, variables
● conditionals
● Boolean expressions
● loops
● ...
artificial intelligence
If student says hello
Say hello
If student says hello
Say hello
Else if student says goodbye
Say goodbye
If student says hello
Say hello
Else if student says goodbye
Say goodbye
Else if student asks how you are
Say well
If student says hello
Say hello
Else if student says goodbye
Say goodbye
Else if student asks how you are
Say well
Else if student asks why 111 in binary is 7 is decimal
…
large language models
Not Reasonable
Using AI-based software other than CS50's own…
Reasonable
Using CS50's own AI-based software…
CS50 Duck
cs50.ai
Visual Studio Code for CS50
cs50.dev
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}
011111110100010101001100010001100000001000000001000000010000000000000000000000000000000000000000000000
000000000000000000000000000000000100000000001111100000000000000001000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000001010000000000010000000000000000000000000000000000000000000000000000000000000000000000000
000000000100000000000000000000000000000000000000000000000100000000000000000010100000000000000001000000
000101010101001000100010011110010101001000100000111110110000010000001100011100000010001001110001110100
100010111110000000000000000000000000000000000000000000000000000000000000000010110000000000001110100000
000000000000000000000000000000010010001011111100000000000000000000000000000000000000000000000000000000
0000000001001000...01111111010001010100110001000110000000100000000100000001000000000000000000000000000
000000000000000000000000000000000000000000000000000110000000000111110000000000000000100000000000000000
000000011000000000011110000000000000000000000000000000000000000000000000100000000000000000000000000000
000000000000000000000000000000000001010000011001000000000000000000000000000000000000000000000000000000
000000000000000000000000000010000000000000000111000000000000000011100000000010000000000000000011100000
000000001100100000000000000010000000000000000000000000000010100000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000001011100001001010000000000000
00000000000000000000000000000000000...0010111101101100011010010110001001100011001011100111001101101111
001011100011011000100000001011110111010101110011011100100010111101101100011010010110001000101111011110
000011100000110110010111110011011000110100001011010110110001101001011011100111010101111000001011010110
011101101110011101010010111101101100011010010110001001100011010111110110111001101111011011100111001101
101000011000010111001001100101011001000010111001100001001000000010000001000001010100110101111101001110
010001010100010101000100010001010100010000100000001010000010000000101111011011000110100101100010001011
110111100000111000001101100101111100110110001101000010110101101100011010010110111001110101011110000010
110101100111011011100111010100101111011011000110010000101101011011000110100101101110011101010111100000
101101011110000011100000110110001011010011011000110100...
break
011111110100010101001100010001100000001000000001000000010000000000000000000000000000000000000000000000
000000000000000000000000000000000100000000001111100000000000000001000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000001010000000000010000000000000000000000000000000000000000000000000000000000000000000000000
000000000100000000000000000000000000000000000000000000000100000000000000000010100000000000000001000000
000101010101001000100010011110010101001000100000111110110000010000001100011100000010001001110001110100
100010111110000000000000000000000000000000000000000000000000000000000000000010110000000000001110100000
000000000000000000000000000000010010001011111100000000000000000000000000000000000000000000000000000000
0000000001001000...01111111010001010100110001000110000000100000000100000001000000000000000000000000000
000000000000000000000000000000000000000000000000000110000000000111110000000000000000100000000000000000
000000011000000000011110000000000000000000000000000000000000000000000000100000000000000000000000000000
000000000000000000000000000000000001010000011001000000000000000000000000000000000000000000000000000000
000000000000000000000000000010000000000000000111000000000000000011100000000010000000000000000011100000
000000001100100000000000000010000000000000000000000000000010100000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000001011100001001010000000000000
00000000000000000000000000000000000...0010111101101100011010010110001001100011001011100111001101101111
001011100011011000100000001011110111010101110011011100100010111101101100011010010110001000101111011110
000011100000110110010111110011011000110100001011010110110001101001011011100111010101111000001011010110
011101101110011101010010111101101100011010010110001001100011010111110110111001101111011011100111001101
101000011000010111001001100101011001000010111001100001001000000010000001000001010100110101111101001110
010001010100010101000100010001010100010000100000001010000010000000101111011011000110100101100010001011
110111100000111000001101100101111100110110001101000010110101101100011010010110111001110101011110000010
110101100111011011100111010100101111011011000110010000101101011011000110100101101110011101010111100000
101101011110000011100000110110001011010011011000110100...
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
}
Scratch
scratch.mit.edu
side effect
input → algorithm → output
→ algorithm → output
→ → output
→ →
return value
input → algorithm → output
→ algorithm → output
→ → output
→ →
input → algorithm → output
→ algorithm → output
→ → output
→ →
→
→
→ →
→ → →