LunaNotes

Download Subtitles for CS50x 2026 Lecture 0 - Scratch Video

CS50x 2026 - Lecture 0 - Scratch

CS50x 2026 - Lecture 0 - Scratch

CS50

3323 segments EN

SRT - Most compatible format for video players (VLC, media players, video editors)

VTT - Web Video Text Tracks for HTML5 video and browsers

TXT - Plain text with timestamps for easy reading and editing

Subtitle Preview

Scroll to view all subtitles

[00:00]

Heat.

[00:02]

[Music]

[00:21]

Heat.

[00:22]

[Music]

[00:38]

[Music]

[00:46]

in your heart to light the magic of the

[00:50]

dark lighting

[00:53]

from this

[00:57]

[Music]

[01:00]

Heat. Heat.

[01:13]

Heat. Heat.

[01:16]

[Music]

[01:16]

[Applause]

[01:20]

[Music]

[01:23]

Heat.

[01:26]

[Music]

[01:33]

Heat.

[01:35]

[Music]

[01:53]

[Music]

[02:03]

[Applause]

[02:04]

All right. This is

[02:10]

This is CS50, Harvard University's

[02:13]

introduction to the intellectual

[02:14]

enterprises of computer science and the

[02:16]

arts of programming. My name is David

[02:18]

Men and this is week zero. And by the

[02:20]

end of today, you'll know not only what

[02:21]

these light bulbs here spell, but so

[02:23]

much more. But why don't we start first

[02:25]

with the uh the elephant or the elephant

[02:27]

in the room that is artificial

[02:29]

intelligence, which is seemingly

[02:30]

everywhere over the past few years. And

[02:32]

it's been said that it's going to change

[02:34]

programming. And that's absolutely the

[02:35]

case. It's been that way actually for

[02:37]

the past several years. Is only going to

[02:39]

get to be the case all the more. But

[02:40]

this is an incredibly exciting time.

[02:42]

This is actually a good thing. I do

[02:44]

think in so far as now using AI in any

[02:47]

number of forms, you can ask the

[02:48]

computer to help solve some problem for

[02:50]

you. You can find some bug or mistake in

[02:52]

your code. Better still, increasingly

[02:54]

you can tell the AI what additional

[02:56]

features you want to add to your

[02:58]

software. And this is huge because even

[03:00]

in industry for years, humans have been

[03:01]

programming in some form for decades,

[03:03]

building products and solutions to

[03:05]

problems, the reality is that you and I

[03:07]

as humans have long been the bottleneck.

[03:09]

There's only so many hours in the day.

[03:11]

There's only so many people on your team

[03:13]

or in your company and there's so many

[03:15]

more bugs that you want to solve and so

[03:17]

many more features that you want to

[03:18]

implement, but at the same time, you

[03:20]

still really need to understand the

[03:22]

fundamentals. And indeed, a class like

[03:24]

this CS50 has never been about teaching

[03:26]

you how to program. like that's actually

[03:28]

one of the side effects of taking a

[03:29]

class like this. But the overarching

[03:31]

goal is to teach you how to think, how

[03:33]

to take input and produce correct output

[03:35]

and how to master these and other tools.

[03:37]

And so by the end of the semester, not

[03:39]

only you will be not only will you be

[03:41]

acquainted with languages like Scratch,

[03:42]

which we'll touch on today if you've not

[03:44]

seen it already, languages like C and

[03:46]

Python and SQL, HTML, CSS, and

[03:48]

JavaScript. You'll be able to teach

[03:50]

yourself new things ultimately, and

[03:52]

ultimately be able to tell computers

[03:54]

increasingly what it is you want it to

[03:56]

do. But you'll still be in the driver's

[03:58]

seat, so to speak. You'll be the pilot.

[04:00]

You'll be the conductor, whatever your

[04:01]

preferred metaphor is. And that's what I

[04:03]

think is so empowering still about

[04:04]

learning introductory material,

[04:06]

foundational material, because you'll

[04:08]

know what you're ultimately talking

[04:09]

about and what you can in fact solve.

[04:11]

And we've been through this before, like

[04:12]

when calculators came out. It's still

[04:14]

valuable, I dare say, all these years

[04:16]

later, to still know how to do addition

[04:18]

and subtraction and whatnot. And yet, I

[04:19]

think back on some of my own math

[04:20]

classes. I remember learning so many

[04:22]

darn ways in college how to take

[04:24]

derivatives and integrals. And after

[04:26]

like the six process of that, I sort of

[04:28]

realized, okay, I get it. I get the

[04:30]

idea. Do I really need to know this many

[04:31]

ways? And here too, with AI and with

[04:34]

code, can you increasingly sort of

[04:36]

master the ideas and then lean on a a

[04:38]

co-pilot assistant to actually help you

[04:41]

solve those same problems? So, let's do

[04:42]

some of this ourselves here. In fact,

[04:44]

just to give you a teaser of what you'll

[04:46]

be able to do yourselves before long,

[04:48]

let me go ahead and open up a little

[04:50]

something called Visual Studio Code, aka

[04:52]

VS Code for short. This is popular

[04:55]

largely open- source or free software

[04:57]

that's used by real world people in

[04:58]

industry to write code. And it's

[05:00]

essentially a text editor similar to

[05:02]

Notepad if you're familiar with that or

[05:03]

text edit kind of like Google Docs but

[05:05]

no boldfacing and underlining and and

[05:07]

things like that that you'd find in word

[05:09]

processing programs. And this is CS50's

[05:11]

version thereof. We're going to

[05:12]

introduce you to this all the more next

[05:14]

week. But for now, let's just give you a

[05:16]

taste of what you can do with an

[05:17]

environment like this. So I'm going to

[05:19]

switch over to this program already

[05:21]

running VS Code. And in this uh bottom

[05:24]

of the screen, you're going to see a

[05:25]

so-called terminal window. Again, more

[05:27]

on that next week, but it's in this

[05:28]

terminal window that I can write

[05:30]

commands that tells the computer what I

[05:31]

want it to do. For instance, let's

[05:33]

suppose just for the sake of discussion

[05:35]

that I want to make my own chatbot, not

[05:37]

chat GPT or Gemini and Claude, like

[05:40]

let's make our own in some sense. So,

[05:42]

I'm going to code up a program called

[05:43]

chat.py. And you might be familiar that

[05:46]

I using a language here.py is it's just

[05:49]

called Python. And if unfamiliar, you're

[05:51]

in good company. You'll learn that too

[05:53]

within a few weeks. And at the top of

[05:54]

the file here, I can write my code. And

[05:56]

at the bottom of the file of the window

[05:58]

here, I can run my code. So, here's how

[06:01]

relatively easy it is nowadays to write

[06:03]

even your own chatbot using the AI

[06:06]

technologies that we already have. I'm

[06:08]

going to go ahead and type a command

[06:09]

like import uh uh I'm going to go ahead

[06:12]

and type the following from OpenAI.

[06:15]

import open AI. We'll learn what this

[06:18]

means ultimately, but what I'm going to

[06:19]

do is write my own program on top of an

[06:23]

API, application programming interface

[06:26]

that someone else provides, a big

[06:27]

company called OpenAI, and they're

[06:29]

providing features and functionality

[06:30]

that now I can write code against. I'm

[06:33]

going to create a so-called client,

[06:34]

which is to say a program of my own

[06:37]

that's going to use this OpenAI

[06:39]

software. And then I'm going to go ahead

[06:41]

and ask this software for a response.

[06:43]

And I'm going to set that equal to

[06:46]

client.responses.create

[06:49]

whatever all that means. And then inside

[06:51]

of these parenthesis I'm going to say

[06:52]

the following. The input I want to give

[06:55]

to this underlying API is quote unquote

[06:57]

something like in one sentence

[07:00]

what is CS50? Much like I would ask

[07:03]

chatpt itself. If you're familiar with

[07:05]

things like chat GPT and AI more

[07:06]

generally nowadays, you know there's

[07:08]

these thing called models which are like

[07:09]

statistical models that ultimately drive

[07:11]

what the AIs can do. I'm going to go

[07:12]

ahead and say model equals quote unquote

[07:14]

gpt5 which is the latest and greatest

[07:16]

version at least as of today. Now down

[07:19]

in my terminal window I'm going to run a

[07:21]

different command python of chat.py and

[07:25]

so long as I have made no typographical

[07:27]

errors in this program I should be able

[07:29]

to ask openai not with chatgpt.com but

[07:33]

with my own code for the answer to some

[07:36]

question. But I want to know what the

[07:37]

answer to that question is. So, I

[07:39]

actually want to print out that response

[07:41]

by saying print response output text. In

[07:45]

other words, these 10 lines, and it's

[07:46]

not even 10 lines because a few of them

[07:48]

are blank, I've implemented my own

[07:49]

chatbot that at the moment is hardcoded

[07:52]

that is permanently configured to only

[07:54]

answer one question for me. And let's

[07:57]

see, with the cross of the fingers, CS50

[07:59]

is Harvard University's introductory

[08:00]

computer science course, the

[08:02]

intellectual enterprises of computer

[08:03]

science and the art of programming.

[08:04]

weirdly familiar covering problems

[08:06]

solving algorithms, data structures, and

[08:07]

more using languages like C, Python, and

[08:09]

SQL. Okay, interesting. But let's make

[08:11]

the program itself more dynamic. Suppose

[08:14]

you wanted to write code that actually

[08:15]

asks the human what their question is

[08:17]

because very quickly might we want to

[08:20]

learn something more than just this one

[08:21]

question. So up here, I'm going to go

[08:23]

and change my code and type something

[08:25]

like this. Type prompt equals input with

[08:28]

parenthesis. More on this another time,

[08:31]

too. But what I'm going to ask the user

[08:32]

for is to give me an actual prompt. That

[08:35]

is a question that I want this AI to

[08:36]

answer. And down here, what you'll

[08:39]

notice, even if you've never programmed

[08:40]

before, is that I can do something

[08:42]

somewhat intuitive in so far as line

[08:44]

five is now asking the human for input.

[08:46]

Let's just stipulate that this equal

[08:48]

sign means store that answer in a

[08:50]

variable called prompt where variables

[08:52]

just like in math X, Y, or Z. Let's go

[08:54]

ahead and store that in prompt. So the

[08:56]

input I want to give to OpenAI now is

[08:58]

that actual prompt. So, it's a

[09:00]

placeholder containing whatever

[09:01]

keystrokes the human typed in. If I now

[09:04]

run that same command again, python of

[09:06]

chat.py, hit enter, cross my fingers,

[09:09]

I'll see now dynamic prompting. So,

[09:13]

what's a question I might want to ask?

[09:14]

Well, let's just say it again. In one

[09:16]

sentence, whoops, in one sentence, what

[09:19]

is CS50? Question mark. Enter. And now

[09:22]

the answer comes back as probably

[09:25]

roughly the same but a little bit

[09:27]

different. a variant thereof. But maybe

[09:29]

we can distill this even more

[09:31]

succinctly. How about let's run it

[09:33]

again. Python of chat.py and let's say

[09:35]

in one word what is CS50 and see if the

[09:39]

underlying AI obliges

[09:41]

and after a pause course in a word. So

[09:45]

that's not all that incorrect. And maybe

[09:47]

we can have a little fun with this. Now

[09:49]

how about in one word which is

[09:53]

which is better? Maybe Harvard

[09:57]

or Stanford.

[10:00]

Hope you picked right. Let's see. The

[10:03]

answer is

[10:05]

depends. Okay. So would not in fact

[10:08]

oblige. But notice what I keep doing in

[10:10]

this code. I keep providing a prompt as

[10:13]

the human like in one sentence in one

[10:15]

word. Well, if you want the AI to behave

[10:17]

in a certain way, why don't we just tell

[10:19]

the underlying system to behave in that

[10:21]

way? So I the human don't have to keep

[10:22]

asking it in one sentence, in one

[10:24]

sentence, in one word. So, we can

[10:25]

actually introduce one other feature

[10:26]

that you'll hear discussed in industry

[10:28]

nowadays, which is not only a prompt

[10:31]

from the user, which I'm going to now

[10:32]

temporarily rename to user prompt. Just

[10:35]

to make clear, it's coming from the

[10:36]

user. I'm going to also give our what's

[10:38]

called a system prompt by setting this

[10:40]

equal to some standardized instructions

[10:44]

that I want the AI to respect, like

[10:47]

limit your answer to one sentence, quote

[10:51]

unquote. And now in addition to passing

[10:53]

in as input the user prompt, I'm gonna

[10:56]

actually tell OpenI to use these

[10:59]

instructions coming from this other

[11:01]

variable called system prompt. So in

[11:04]

other words, I'm still using the same

[11:05]

underlying service, but I'm handing it

[11:07]

now not only what the user typed in, but

[11:09]

also this standardized text limit your

[11:11]

answer to one sentence. So the human

[11:13]

like me doesn't have to do that anymore.

[11:15]

Let's now go back to my terminal, run

[11:17]

Python of chat.py once more, and this

[11:19]

time we'll be prompted. But now I can

[11:21]

just ask what is CS50 question mark and

[11:25]

I'll likely get a correct and similar

[11:28]

answer to before. And indeed it's

[11:30]

Harvard University's flagship

[11:32]

introductory computer science course dot

[11:33]

dot dot. So seems spot on too. But now

[11:35]

we can have some fun with this too. And

[11:37]

you might know that these GPTs nowadays

[11:40]

have sort of personalities. You can make

[11:41]

them obliged to behave in one way or

[11:43]

another. Why don't we go into our system

[11:44]

prompt here and say something silly like

[11:46]

pretend you're a cat. And now let's go

[11:50]

back to the prompt one final time. Run

[11:52]

Python of chat.py. Prompt again will be

[11:55]

say what is CS50? And with a final

[11:58]

flourish of hitting enter, what do we

[12:01]

get back?

[12:03]

CS50 is Harvard University's

[12:05]

introductory computer science course

[12:06]

teaching programming algorithms, data

[12:07]

structures, and problem solving. And

[12:08]

it's available free online. Meow. So

[12:11]

that was enough to coersse this

[12:13]

particular behavior. So this is to say

[12:15]

that with programming you have the

[12:17]

ability in like 10 lines of text, not

[12:20]

all of which you might understand yet,

[12:22]

but that's the whole point of a class

[12:23]

like this to build fairly powerful

[12:25]

things, maybe silly things like this,

[12:27]

but in fact it's using these same

[12:28]

primitives that CS50 has its own virtual

[12:31]

rubber duck. And we'll talk more about

[12:32]

this in the weeks to come, but long

[12:33]

story short, in the world of

[12:35]

programming, it's kind of a thing to

[12:36]

keep a rubber duck literally on your

[12:39]

desk or really any inanimate cute object

[12:41]

like this because when you are

[12:42]

struggling with some problem, some bug

[12:45]

or mistake in your code and you don't

[12:46]

have a friend, a teaching assistant, a

[12:48]

parent, or someone else who's more

[12:50]

knowledgeable than you about code, well,

[12:52]

you literally are encouraged in

[12:53]

programming circles to like talk to the

[12:55]

rubber duck. And it's through that

[12:56]

process of just verbalizing your

[12:58]

confusion and organizing your thoughts

[13:00]

enough to convey it to another person or

[13:02]

duck in this case that so often that

[13:04]

proverbial light bulb goes off and you

[13:06]

realize ah I'm being an idiot now I hear

[13:08]

in my own thoughts the illogic or the

[13:10]

mistake I'm making and you solve that

[13:12]

problem as well. So CS50 drawing

[13:14]

inspiration from this will give to you a

[13:16]

virtual duck in computer form and in

[13:18]

fact among the other URLs you'll use

[13:20]

over the course of the semester is that

[13:22]

here cs50.ai AI which is also built into

[13:24]

that previous URL cs50.dev whereby these

[13:28]

are the AIS you can use in CS50 to solve

[13:31]

problems and you are encouraged to do so

[13:33]

as you'll see in the course's syllabus.

[13:35]

is not reasonable. It is not allowed to

[13:36]

use AI based software other than CS50

[13:39]

zone, be it claw, Gemini, chat GPT or

[13:41]

the like, but it is reasonable and very

[13:43]

much encouraged along the way to turn

[13:45]

not only to humans like me, your

[13:47]

teaching assistant and others in the

[13:48]

class, but to CS50's own AI based

[13:51]

software. And what you'll find is that

[13:52]

this virtual duck is designed to behave

[13:55]

as close to a good human tutor as you

[13:58]

might expect from an actual human in the

[13:59]

real world. knows about CS50, knows how

[14:01]

to lead you to a solution, ideally

[14:03]

without simply spoiling it and providing

[14:05]

it outright. So with that said, that's

[14:09]

sort of the endgame to be able to write

[14:11]

code like that and more. But let's

[14:13]

really start back at the beginning and

[14:15]

see how we can't get from zeros and ones

[14:17]

that computers speak all the way back to

[14:20]

artificial intelligence. So computer

[14:21]

science is the in the name of the

[14:23]

course, computer science 50. But what is

[14:25]

that? Well, it's really just the study

[14:26]

of information. How do you represent it?

[14:29]

How do you process it? And very much

[14:30]

gerine to computer science is what the

[14:32]

world calls computational thinking which

[14:33]

is just the application of ideas from

[14:35]

computer science or CS to problems

[14:39]

generally in the real world. And in fact

[14:40]

that's ultimately I dare say what

[14:42]

computer science really is. It's about

[14:44]

problem solving. And even though we use

[14:46]

computers you learn how to program along

[14:48]

the way. These are really just tools and

[14:50]

methodologies that you can leverage to

[14:52]

solve problems. Now what does that mean?

[14:55]

Well, a problem is perhaps most easily

[14:56]

distilled into a simple picture like

[14:58]

this. We've got some input which is like

[15:00]

the problem we want to solve and the

[15:02]

output which is the goal we want the

[15:04]

solution there too. And then somewhere

[15:05]

in the middle here is the proverbial

[15:07]

black box the sort of secret sauce that

[15:08]

gets that input from output. So this

[15:11]

then I would say is in essence is

[15:13]

problem solving and thus computer

[15:15]

science. But we have to agree especially

[15:17]

if we're going to use devices, Macs,

[15:19]

PCs, phones, whatever. How do we all

[15:21]

represent information, the inputs and

[15:22]

the outputs in some standardized way? Is

[15:25]

it with English? Is it with something

[15:26]

else? Well, you all probably know, even

[15:28]

if you're not computer people, that at

[15:29]

the end of the day, computers somehow

[15:31]

use zeros in one entirely. That is their

[15:34]

entire alphabet. And in fact, you might

[15:36]

be familiar already with certain such

[15:38]

systems. So the unary uh notation, which

[15:41]

means you essentially use single digits

[15:43]

like fingers on your hand. For instance,

[15:45]

unary aka base one is something you can

[15:47]

do on your own human hand. So for

[15:48]

instance, with one human hand, how high

[15:50]

can I count?

[15:52]

>> All right. So hopefully 1 2 3 4 five.

[15:54]

And if you want to count to six and uh

[15:57]

to 11 and 10 and so forth, you need to,

[16:00]

you know, take out another hand or your

[16:01]

toes or the like because it's fairly

[16:03]

limiting. But if I think a little

[16:04]

harder, instead of just using unary,

[16:06]

what if I use a different system

[16:08]

instead? What about something like

[16:10]

binary? Well, how high if you think a

[16:11]

little harder can you count on one human

[16:13]

hand?

[16:15]

So 31 says someone who studied computer

[16:17]

science before. But why is that? It's

[16:19]

kind of hard to imagine, right? Because

[16:20]

1 2 3 4 5 seems to be the five possible

[16:24]

patterns. But that's only when you're

[16:25]

looking at the totality of fingers that

[16:27]

are actually up. Five in total or four

[16:29]

in total or one or the like. But what if

[16:31]

we take into account the pattern of

[16:33]

fingers that are up and we just

[16:34]

standardize what each of those fingers

[16:36]

represent. So maybe we all agree like a

[16:38]

good computer would too that maybe no

[16:40]

fingers up means the number zero. And if

[16:42]

we want to count to one, let's go with

[16:44]

the obvious. This is now one. But

[16:46]

instead of two being this, which was my

[16:48]

first instinct, maybe two can just be

[16:51]

this. A single second finger up like

[16:54]

this. And that means we could now use

[16:57]

two fingers up to represent three. I'll

[17:01]

propose we can use just one middle

[17:03]

finger up to offend everyone, but

[17:05]

represent four. I could maybe use these

[17:07]

two fingers with some difficulty to

[17:09]

represent five, six, seven. And I'm

[17:13]

already up to seven having used only

[17:15]

three fingers. And in fact, if we keep

[17:17]

going higher and higher, I bet I can get

[17:19]

as high as 31 for 32 possible

[17:22]

combinations. But the first one was

[17:23]

zero. So that's as high as we can count.

[17:25]

So we'll make this connection in just a

[17:27]

moment. But what I started to do there

[17:29]

is something called base 2. Instead of

[17:31]

just having fingers up or fingers down,

[17:33]

I'm taking into account the positions of

[17:35]

those fingers and giving meaning to like

[17:37]

this finger here, this finger here, this

[17:40]

finger here, and so forth. Different

[17:41]

weights, if you will. So the binary

[17:44]

system is indeed all computers

[17:46]

understand and you might be familiar

[17:48]

with some terminology here. Binary digit

[17:50]

is not really something anyone really

[17:52]

says but the shorthand for that is going

[17:54]

to be bit. So if you've heard of bits

[17:57]

and we'll soon see bytes and then

[17:58]

kilobytes and megabytes and gigabytes

[18:00]

and terabytes and more. This just refers

[18:03]

to a bit meaning a single binary digit

[18:07]

either a zero or a one. A zero is

[18:11]

perhaps most simply represented by just

[18:13]

like turning maybe keeping a finger down

[18:15]

or in the world of computers which have

[18:17]

access to electricity be it from the

[18:19]

wall or maybe a battery. You know what

[18:21]

we could do? We could just decide sort

[18:24]

of universally that when the light bulb

[18:26]

is off that thing represents a zero and

[18:29]

when the light bulb is on that thing's

[18:30]

going to represent a one instead. Now

[18:33]

why is this? Well, electricity is such a

[18:35]

simple thing right? It's either flowing

[18:37]

or it's not. And we don't even have to

[18:39]

therefore worry about how much of it is

[18:40]

flowing. And if you're vaguely remember

[18:42]

a little bit about voltage, we can sort

[18:44]

of be like zero volts. Nothing's there

[18:46]

available for us. Or maybe it's 5 volts

[18:48]

or something else in between. But what's

[18:50]

nice about binary only using zeros and

[18:53]

ones is that it maps really nicely to

[18:55]

the real world by like throwing a light

[18:57]

switch on and off. You can represent

[18:59]

information by just using a little bit

[19:00]

of electricity or the lack thereof. So

[19:03]

what do I mean by this? Well, suppose we

[19:05]

want to start counting using binary

[19:08]

zeros and ones only. Well, let's think

[19:10]

of them metaphorically as like akin to

[19:11]

these light bulbs here. And in fact, let

[19:13]

me grab a few of these light bulbs and

[19:15]

let me propose that if we want to

[19:17]

represent the number zero, well, it

[19:19]

stands to reason that here single light

[19:22]

bulb that is off can be agreed upon as

[19:24]

representing zero. Now, in practice,

[19:26]

computers don't have little light bulbs

[19:28]

inside, but they do have little switches

[19:30]

inside. Millions of tiny little things

[19:32]

called transistors that if turned on,

[19:35]

can allow it to capture a little bit of

[19:36]

electricity and effectively turn on a

[19:38]

metaphorical bulb. Or the switch can go

[19:41]

off. The transistor can go off and

[19:42]

therefore let the electricity dissipate

[19:44]

and you have just now a zero.

[19:46]

Unfortunately, even though I can let

[19:48]

some electricity, there's the battery I

[19:52]

mentioned is required. Even though we

[19:54]

might have some electricity available to

[19:55]

us, I can therefore count to one. But

[19:57]

how do I go about counting?

[20:01]

Hardware problem. How do I go about

[20:03]

counting higher than one with just a

[20:05]

light bulb?

[20:08]

Yeah. So, I need more of them. So, let

[20:09]

me grab another one here. And now I

[20:12]

could put it next to it. And this two,

[20:13]

I'll claim is just still the number one.

[20:16]

But if I want to turn two of them on,

[20:18]

well, that would I could count to two.

[20:20]

And if I maybe grab another one, now I

[20:22]

can count as high as three. But wait a

[20:24]

minute, I'm doing something wrong

[20:25]

because with three human fingers, how

[20:27]

high was I able to count?

[20:29]

So seven in total starting at zero. So

[20:32]

I've done something wrong here. But let

[20:33]

me be a little more clever than about

[20:35]

the pattern that I'm actually using.

[20:37]

Perhaps this can still be one. But just

[20:40]

like my finger went up and only one

[20:42]

finger in the second version of this,

[20:45]

this can be what we represent as two.

[20:48]

Which one do I want to turn on as three?

[20:50]

Your left or your right?

[20:53]

>> So, you're right. Because now this

[20:54]

matches what I was doing with my fingers

[20:56]

a moment ago. And I claimed we could

[20:57]

represent three like this. If we want to

[20:59]

represent four, that's fine. We have to

[21:01]

turn that off, this off, and this on.

[21:05]

And that's somehow four. And let's go

[21:07]

all the way up to seven. Which ones need

[21:08]

to be on to represent the number seven?

[21:11]

All right. So, all of them here. Now, if

[21:13]

you're not among those who just sort of

[21:15]

naturally said all of them, like what

[21:16]

the heck is going on? And how do half

[21:18]

the people in this room know what these

[21:20]

patterns are supposed to be? Well, maybe

[21:21]

you're remembering what I did with my

[21:23]

fingers. But it turns out you're already

[21:24]

pretty familiar with systems like this,

[21:27]

even if you might not have put a name to

[21:28]

it. So, in the human world, the real

[21:30]

world, most of us deal every day with

[21:32]

the so-called base 10 system, otherwise

[21:34]

known as decimal deck implying 10.

[21:37]

Because in the decimal system, you have

[21:39]

10 digits available to you, 0 through 9.

[21:42]

In the binary system, we only had two by

[21:44]

implying two. So zero and one and unary

[21:47]

we had just one a single digit there or

[21:51]

not. So in the decimal system we just

[21:53]

have more of a vocabulary to play with

[21:55]

and yet you and I have been doing this

[21:56]

since grade school. So this is obviously

[21:58]

the number 123. But why? It's

[22:01]

technically just three symbols 1 2 3.

[22:04]

But most of us your mind and meal e goes

[22:06]

okay 123. Pretty obvious pretty natural.

[22:09]

But at some point you like me were

[22:11]

probably taught that this is the one's

[22:12]

place and this is the 10's place and

[22:15]

this is the 100's place and so forth.

[22:18]

And the reason that this pattern of

[22:20]

symbols 1 2 3 is 123 is that we're all

[22:24]

doing some quick mental math and

[22:26]

realizing well that's 100 * 1 + 10 * 2 +

[22:29]

1 * 3. Oh okay there's how we get 100 +

[22:32]

20 + 3 gives us the number we all know

[22:34]

mathematically is 123. Well, it turns

[22:37]

out whether you're using decimal or

[22:39]

binary or other base systems that we'll

[22:42]

talk about later in the course, the

[22:43]

system is still fundamentally the same.

[22:45]

Let's kind of generalize this away.

[22:46]

Here's a three-digit number in some base

[22:48]

system, specifically in decimal. And I

[22:50]

know that only because of the

[22:52]

placeholders that I've got on top of

[22:53]

each of these numbers. But if we do a

[22:55]

little bit of math here, 1 10 100 1,000

[22:58]

10,000 and so forth. What's the pattern?

[23:00]

Well, technically this is 10^ the 0 10

[23:03]

the 1 10 the 2 and so forth. And we're

[23:06]

using 10 because we can use as many as

[23:09]

10 digits under each of those columns.

[23:11]

But if we take some of those digits away

[23:13]

and go from decimal down to binary. The

[23:16]

motivation being it's way easier for a

[23:18]

computer to distinguish electricity

[23:20]

being on or off than coming up with like

[23:23]

10 unique levels of electricity to

[23:26]

distinguish among. You could do it. It

[23:27]

would be annoying and difficult to build

[23:29]

in hardware. You could do it so much

[23:31]

simpler to just say on and off. It's a

[23:34]

nice simple world that way. So let's

[23:36]

change the base from 10 to two. And what

[23:39]

does this get us? Well, if we now do

[23:41]

undo the math, that's two to the 0 is 1.

[23:44]

2 to the 1 is 2. 2 to the 2 is 4. So the

[23:47]

man the mental math is now about to be

[23:49]

the same, but the columns represent

[23:51]

something a little bit different. So,

[23:53]

for instance, if I turn all of these off

[23:55]

again such that I've got off, off off,

[23:58]

otherwise known as 0 0, it's zero

[24:02]

because it's 4 * 0 + 2 * 0 + 1 * 0 still

[24:07]

gives me zero. By contrast, if I turn on

[24:10]

maybe just this one all the way over on

[24:12]

the left, well, that's four * 1 because

[24:16]

on represents one and off represents 0,

[24:18]

plus 2 * 0 + 1 * 0, that gives me four.

[24:22]

And if I turn both of these on such that

[24:24]

all three of them are now on on on aka 1

[24:29]

one one that's four * 1 + 2 * 1 + 1 * 1

[24:35]

that then gives me seven. And we can

[24:37]

keep adding more and more bits to this.

[24:38]

In fact, if we go all the way up uh

[24:40]

numerically, here's how we would

[24:42]

represent in binary the number you and I

[24:44]

know is zero. Here's how we would

[24:46]

represent one. Here's how we would

[24:48]

represent two and three and four and

[24:52]

five. And you can kind of see in your

[24:53]

mind's eye now because I only have zeros

[24:55]

and ones and no twos or threes, not to

[24:58]

mention nines. I'm essentially going to

[25:00]

be carrying a one in a moment if we were

[25:02]

to be doing some math. So to go from

[25:03]

five to six, that's why the one ends up

[25:06]

in the middle column. To go to seven

[25:08]

here gives us now one one or on on on.

[25:11]

How do I represent eight

[25:14]

using ones and zeros? Yeah,

[25:17]

>> we need to add another digit.

[25:18]

>> Yeah. So, we're going to need to add

[25:19]

another digit. We need to throw hardware

[25:21]

at the problem using an additional digit

[25:23]

so that we actually have a column

[25:25]

representing eight. Now, as an aside,

[25:27]

and we'll talk about this before long,

[25:28]

if you don't have an additional digit

[25:30]

available, if your computer doesn't have

[25:32]

enough memory, so to speak, you might

[25:35]

accidentally count from 0 1 2 3 4 5 6 7

[25:39]

and then accidentally end up back at

[25:41]

zero. Because if there's no room to

[25:43]

store the fourth bit, well, all you have

[25:46]

is part of the number. And this is going

[25:48]

to create all sorts of problems then

[25:50]

ultimately in the real world. So, let me

[25:52]

go ahead and put these back and propose

[25:54]

that we have a system now. If you agree

[25:57]

to sort of count numbers in this way via

[26:00]

which we can represent information in

[26:02]

some standard way and all the device

[26:04]

underneath the hood needs is a bit of

[26:06]

electricity to make this work. It's got

[26:07]

to be able to turn things on, aka use

[26:09]

some transistors, and it's got to be

[26:11]

able to turn those things off so as to

[26:13]

represent zeros instead of ones. But the

[26:16]

reality is like two bits, three bits,

[26:18]

four bits aren't very useful in the real

[26:20]

world because even with three bits you

[26:22]

can count to seven, with four you can

[26:23]

count to 15. These aren't very big

[26:25]

numbers. So it tends to be more common

[26:27]

to actually use units of measure of

[26:30]

eight bits at a time. A bite is just

[26:33]

that. One bite is eight bits. So if

[26:35]

you've ever used the vernacular of

[26:37]

kilobytes, megabytes, gigabytes, that's

[26:39]

just referring to some number of bits,

[26:41]

but eight of them together compose one

[26:45]

individual bite. So here, for instance,

[26:47]

is a bite worth of bits, eight of them

[26:50]

total. I've added all the additional

[26:52]

placeholders. And what number does this

[26:54]

represent in decimal even though you're

[26:55]

looking at eight binary digits?

[26:58]

>> It's a zero cuz like literally every

[27:00]

column is a zero. Now, this is a bit

[27:02]

more of mental math, but unless you know

[27:04]

it already, what if I change all of the

[27:06]

zeros to ones? I turn all eight light

[27:08]

bulbs on. What number is this?

[27:10]

>> Yeah. So, 255. Now, some of those of you

[27:13]

who didn't get that instantly, that's

[27:15]

fine. You could certainly do the math

[27:16]

manually. I dare say some of you have

[27:18]

some prior knowledge of how to do this

[27:20]

sort of system. But 255 means that if

[27:23]

you start counting at zero and you go

[27:25]

all the way up to 255, okay, that's 256

[27:29]

total possibilities. Once you include

[27:31]

zero in the total number of patterns of

[27:33]

zeros and ones, and this is just going

[27:35]

to be one of these common numbers in

[27:37]

computer science, 256. Why? Because it's

[27:40]

referring to 8 of something. 2 to the 8

[27:43]

gives you 256. And so, you're going to

[27:45]

commonly see certain values like that.

[27:47]

256. Back in the day, computers could

[27:49]

only show 256 colors on the screen.

[27:52]

Certain graphics formats nowadays that

[27:54]

you might download can only use as many

[27:56]

as 256 colors because as we'll see

[27:59]

they're only using for instance eight

[28:01]

bits and therefore they can only

[28:03]

represent so many colors of the rainbow

[28:05]

as a result. So this then is how we

[28:10]

might go from just zeros and ones

[28:11]

electricity inside of a computer to

[28:14]

storing actual numbers with which we're

[28:16]

familiar. And honestly we can go higher

[28:17]

than 255. What do you need to count

[28:19]

higher than 255? a ninth bit, a tenth

[28:21]

bit, an 11th bit, and so forth. And it

[28:23]

turns out common conventions nowadays,

[28:26]

and we'll see this in code, too, is to

[28:28]

use as many as 32 bits at a time. So

[28:31]

that's a good chunk of bits. And anyone

[28:33]

want to ballpark how high you can count

[28:34]

count if you've got 32 bits available to

[28:37]

you.

[28:39]

Oh, a fewer people now. Yeah, in the

[28:41]

back. Yeah. So, it's roughly 4 billion.

[28:44]

And it's technically two billion if you

[28:46]

also want to represent negative numbers,

[28:48]

but we'll revisit that question. But 2

[28:50]

to the 32nd power is roughly 4 billion.

[28:53]

However, nowadays it's even more common

[28:55]

with the Macs and PCs you might have on

[28:56]

your laps and even your phones nowadays

[28:58]

to use 64 bits, which is a big enough

[29:01]

number that I'm not even sure offh hand

[29:03]

to pronounce it. That's a lot of

[29:04]

permutations. That's 2 to the 64

[29:07]

possible permutations, but that's

[29:08]

increasingly common place. And as an

[29:10]

aside, just to dovetail things with our

[29:12]

discussion of AI, among the reasons that

[29:14]

we're living through over these past few

[29:15]

years, especially this crazy interesting

[29:18]

time of AI is because computers have

[29:20]

been getting so much faster,

[29:22]

exponentially so over time, they have so

[29:25]

much more memory available to them.

[29:26]

There's so much data out there on the

[29:28]

internet in particular to train these

[29:30]

models that it's an interesting

[29:32]

confluence of hardware now actually

[29:33]

meeting the mathematics and statistics

[29:35]

that we'll talk about later in the class

[29:37]

that ultimately make tools like the cat

[29:39]

we just built possible. But of course

[29:41]

computers are not all math and in fact

[29:43]

we'll use very little math per se in

[29:45]

this class. And so let's move away

[29:47]

pretty quickly from just zeros and ones

[29:48]

and talk about letters of the alphabet.

[29:50]

Say in English here is the letter A.

[29:53]

Suppose you want to use this letter in

[29:55]

an email, a text message, or any other

[29:56]

program. What is the computer doing

[29:58]

underneath the hood? How can the

[30:00]

computer store a capital letter A in

[30:03]

English? If at the end of the day, all

[30:05]

the computer has access to is a source

[30:07]

of electricity from the wall or from a

[30:10]

battery and it has a lot of switches

[30:13]

that it can turn on and off and treat

[30:15]

the electricity in units of 8 or 32 or

[30:18]

64 or whatever. How might a computer

[30:22]

represent a letter A?

[30:26]

>> Yeah, we need to give it an identity so

[30:28]

to speak as an integer. In other words,

[30:29]

at the end of the day, if your entire

[30:32]

canvas, so to speak, consists only of

[30:34]

zeros and ones. Like that is going to be

[30:36]

the answer to every question today. You

[30:38]

only have zeros and ones as the solution

[30:40]

to these problems. We just need to agree

[30:42]

what pattern of zeros and ones and

[30:44]

therefore what integer, what number

[30:46]

shall be used to represent the letter A.

[30:49]

And hopefully when we look at that

[30:51]

pattern of zeros and ones in the right

[30:53]

context, we'll indeed see it as an A. So

[30:55]

if we look inside of a computer so to

[30:57]

speak in the context of like a text

[30:59]

messaging program or a word processor or

[31:01]

anything like that, that pattern shall

[31:03]

be interpreted hopefully as a capital

[31:05]

letter A. But if I open up Mac OS's or

[31:07]

Windows or my phone's calculator

[31:09]

program, I would want that same pattern

[31:11]

of zeros and ones to be interpreted

[31:13]

instead as a number. If I open up

[31:16]

Photoshop, as we'll soon see, I want

[31:18]

that same pattern of zeros and ones to

[31:19]

be interpreted as a color presumably,

[31:22]

not to mention videos and sound and so

[31:24]

forth, but it's all just zeros and ones.

[31:26]

And so, even though I, when writing that

[31:28]

chat program a few minutes ago, didn't

[31:30]

have to worry about telling the

[31:32]

computer, oh, this is text, this is a

[31:34]

number, this is something else. We'll

[31:36]

see as we write code ourselves that you

[31:38]

as the programmer will have control over

[31:40]

telling the computer how to treat some

[31:43]

pattern of zeros and ones telling it

[31:44]

this is a number, this is a color, this

[31:46]

is a letter or something else. Um, how

[31:49]

do we represent the letter A? Well,

[31:51]

turns out a bunch of humans in a room

[31:52]

years ago decided ah this pattern of

[31:55]

zeros and ones shall be known globally

[31:58]

as a capital letter English A. What is

[32:01]

that number if you do the quick mental

[32:03]

math? So indeed 65 because we had a one

[32:06]

in the 64's place and a one in the onees

[32:08]

place. So 65 that's just sort of it. It

[32:11]

would have been nice if it were just the

[32:12]

number one or maybe the number zero. But

[32:15]

at least after the capital letter A,

[32:17]

they kept things consistent such that if

[32:19]

you want to represent a letter B, it's

[32:21]

going to be 66. Capital letter C, it's

[32:24]

going to be 67. Why? Because the humans

[32:26]

in this room, a bunch of Americans at

[32:27]

the time, standardized on what's called

[32:29]

ASKI, the American standard code for

[32:31]

information interchange. It doesn't

[32:32]

matter what the acronym represents, but

[32:35]

it was just a mapping. Someone on a

[32:37]

piece of paper essentially started

[32:38]

writing down letters of the alphabet and

[32:40]

corresponding numbers so that computers

[32:42]

subsequently could all speak that same

[32:45]

standard representation. And here's an

[32:47]

excerpt thereof. In this case, we're

[32:48]

seeing seven bits worth, but eventually

[32:50]

we ended up using eight bits in total to

[32:52]

represent letters. And some of these are

[32:54]

fairly cryptic. Maybe more on those

[32:56]

another time. But down here, if we

[32:57]

highlight just one column, we'll see

[32:59]

that indeed on this cheat sheet, 65 is

[33:02]

capital A, 66 is B, 67 is C, and so

[33:05]

forth. So, why don't we do a little

[33:07]

exercise here? What pattern of zeros and

[33:11]

ones do I see here? I've got three

[33:13]

bytes. So, three sets of eight bits. And

[33:16]

even though there's no placeholders now

[33:17]

over the columns, what is this

[33:20]

number?

[33:23]

It's 60. Yeah. Yeah. So, we got the

[33:26]

ones, twos, fours, 8s, uh, 16, 32, 64s

[33:32]

column. So, indeed, this is going to be

[33:33]

the number 72. 72. This is not what

[33:36]

computer scientists spend their day

[33:37]

doing. This is just to reinforce what it

[33:39]

is we just looked at. And I'll spoil it.

[33:41]

The rest of these numbers are 72 73 33.

[33:44]

And anyone in this room could have done

[33:46]

that if you took out a piece of paper,

[33:47]

figured out what the columns are, and

[33:48]

just do a bit of quick or mental or

[33:50]

written math. But this is to say,

[33:52]

suppose that you just got a text message

[33:54]

or an email that if you had the ability

[33:57]

to look underneath the hood of the

[33:58]

computer and see what pattern of zeros

[34:00]

and ones did you just receive over the

[34:02]

internet. Suppose that pattern of zeros

[34:04]

and ones was three bytes of bits, which

[34:08]

when you do the math are the numbers 72,

[34:10]

73, 33. Well, here's the cheat sheet

[34:13]

again. What message did you just get?

[34:16]

>> Yeah. So, it's high. Why? Because 72 is

[34:18]

H and 73 is I. Now, some of you said hi

[34:22]

fairly emphatically. Why? Well, 33 turns

[34:25]

out, and you wouldn't know this unless

[34:26]

you looked it up or someone told you, is

[34:28]

an exclamation point. So, literally, if

[34:30]

you were to text someone like right now,

[34:32]

if you haven't already, hi exclamation

[34:34]

point in all caps, you would essentially

[34:36]

be sending three bytes of information

[34:39]

somehow over the internet to that

[34:41]

recipient. And because their phone

[34:43]

similarly understands ASI because it was

[34:46]

programmed years ago to do so, it knows

[34:48]

to show you hi exclamation point and not

[34:51]

a number three numbers no less or colors

[34:54]

or something else altogether. So here we

[34:57]

then have hi three digits in a row here.

[35:00]

Um what else is worth noting here? Well,

[35:02]

there's some fun sort of trivia embedded

[35:04]

even in this cheat sheet. So here again

[35:06]

is a b cde e fg and so forth 65 on down.

[35:11]

Let me just highlight over here the

[35:13]

lowercase letters. 97, 98, 99, and so

[35:17]

forth. If I go back and forth, does

[35:19]

anyone notice the consistent pattern

[35:22]

between these two?

[35:24]

>> Yeah. So, the lowercase letters are 32

[35:28]

away from the uppercase letters. Well,

[35:30]

how do we know that? Well, 97 - 65 is

[35:33]

Yeah. 32. Uh 98 - 66 is okay. 32. And

[35:37]

that pattern continues. What does this

[35:40]

mean? Well, computers know how to do

[35:41]

this. Most normal humans don't need this

[35:43]

information. But what it means is if you

[35:45]

are representing in binary with your

[35:48]

transistors on and off representing some

[35:49]

pattern and this is the pattern

[35:51]

representing capital letter A, which is

[35:53]

why we have a one in the 64's place and

[35:55]

a one in the one's place. How does a

[35:58]

computer go about lowercasing this same

[36:00]

letter? Yeah.

[36:05]

>> Perfect. All the computer has to do is

[36:07]

change this one bit in the 32's place to

[36:10]

a one because that has the effect

[36:12]

mathematically per our discussion of

[36:14]

adding the number 32 to whatever it is.

[36:16]

So it turns out you can force text from

[36:18]

uppercase to lowerase or back by just

[36:21]

changing a single bit inside of that

[36:24]

pattern of eight bits in total. All

[36:26]

right, why don't we maybe reinforce this

[36:28]

with another quick exercise? We have an

[36:30]

opportunity perhaps here for um maybe to

[36:32]

give you some stress balls right at the

[36:33]

very start of class. Could we get eight

[36:34]

volunteers to come up on stage? Maybe

[36:37]

over here and over here and uh over here

[36:40]

on the left. Let me go all the way on

[36:42]

the right. Uh let's see. Okay, the high

[36:45]

hand here. The the hand that's highest

[36:46]

there. Yes, we're making eye contact.

[36:48]

How about all the way? Wait, let's see.

[36:50]

Let's go here in the crimson sweatshirt

[36:52]

here. And how about in the the white

[36:54]

shirt here? Come on up. Did I count

[36:56]

correctly? Let's see.

[37:00]

Come on down. The eight of you. I didn't

[37:02]

count right, did I? 1 2 3 4 5 6. It's

[37:06]

ironic that I'm not counting correctly.

[37:08]

Eight here. How about on the left in

[37:09]

gray? Okay. Oh, and uh Okay. In black

[37:13]

here. Come on down. All right.

[37:14]

Hopefully, this is eight. 1 2 3 4 5 6 7.

[37:20]

I pretty. Okay. Eight. There we go. All

[37:22]

right. So, let's go ahead and do the

[37:24]

following exercise. I've got some sheets

[37:25]

of paper preprinted here. If each of you

[37:27]

indeed want to do exactly what you're

[37:28]

doing and line up from left to right,

[37:30]

each of you is going to represent a

[37:32]

placeholder essentially. So we have over

[37:35]

here the ones place all the way over

[37:37]

here. And then we have the two's place

[37:40]

and the four's place and the eights.

[37:44]

16 32 64 128. And we come bearing a

[37:50]

microphone if each of you want to say a

[37:51]

quick hello. your name, maybe your dorm

[37:53]

or house, and something besides computer

[37:55]

science that you're studying or want to.

[37:57]

>> Hi, I'm loud. Okay. I'm Allison. I'm a

[38:01]

freshman in Matthews and um I like

[38:05]

climbing and I'm thinking of CS and

[38:07]

econ.

[38:09]

>> Number two.

[38:10]

>> Hi, I'm Lily. I'm in Herbut this year

[38:12]

and I'm thinking of doing CS in

[38:14]

government.

[38:16]

>> Nice to meet.

[38:17]

>> Hi. Hi, I'm Sean. I'm in candidate hall

[38:20]

and I'm thinking of doing astrophysics

[38:21]

and CS. Welcome.

[38:23]

>> Hi, I'm Jordan. I'm doing applied math

[38:26]

with a specialization in CS and econ.

[38:29]

And um I'm in Widdlesworth and I like

[38:32]

going to the gym.

[38:34]

>> Okay, nice. 16.

[38:36]

>> Hi, I'm Shiv. I'm studying Mcki and I'm

[38:38]

in Canada G.

[38:40]

>> Nice.

[38:41]

>> Hi, I'm Sophia. I'm in the think of

[38:44]

doing electrical engineering.

[38:46]

>> Welcome. Hi, my name is Marie and I'm in

[38:50]

Canada B and I really like CS physics

[38:53]

and astrophysics.

[38:55]

>> Hi, I'm Alyssa. I'm in Hullworthy. I'm

[38:59]

also thinking of studying math or

[39:00]

physics and I also like to climb.

[39:03]

>> Nice. Welcome to you all. So, on the

[39:05]

backs of their sheets of paper, they

[39:07]

have a little cheat sheet that's

[39:08]

describing what they should do in each

[39:10]

of three rounds. We're going to spell

[39:11]

out together a threeletter word. You all

[39:14]

as the audience have a cheat sheet above

[39:15]

you that represents numbers to letters.

[39:18]

These folks don't necessarily know what

[39:20]

they're spelling. They only know what

[39:21]

they individually are spelling. So if

[39:22]

your sheet of paper tells you to

[39:24]

represent a zero in a given round, just

[39:26]

kind of stand there awkwardly, no hands

[39:28]

up. But if you're told on your sheet of

[39:29]

paper to represent a one, just raise a

[39:32]

single hand to make obvious to the

[39:33]

audience that you're representing a one

[39:35]

and not a zero. And the goal here is to

[39:37]

figure out what we are spelling using

[39:38]

this system called ASKI. All right,

[39:40]

round one. Execute.

[39:45]

What number is this here?

[39:49]

I'm hearing. You can just shout it out.

[39:52]

What number?

[39:54]

>> 66 or B. So, you're spelling B. All

[39:57]

right. Hands down. Round two.

[40:01]

More math.

[40:05]

Feel free to shout it out.

[40:07]

>> Oh, I heard it. Yeah. 79, which is

[40:10]

>> O. Okay. Okay, so we have B O. Hands

[40:13]

down. Third and final round. Execute

[40:16]

number

[40:20]

87.

[40:21]

>> Yes. 87. Which is the letter?

[40:23]

>> W. Which spells?

[40:26]

>> Bow. If you want to take your bow now.

[40:29]

>> Ah, okay. Here we go. You guys can keep

[40:31]

those.

[40:34]

Okay. Thank. All right. You guys can

[40:36]

head back. Thank you to our volunteers

[40:38]

here. Very nicely done. We indeed

[40:40]

spelled out bow and that's just because

[40:42]

we all standardized on representing

[40:44]

information in exactly the same way.

[40:46]

Which is why when you type b on your

[40:48]

phone or your computer, the recipient

[40:50]

sees the exact same thing. But what's

[40:52]

noteworthy in this discussion is that

[40:54]

you can't spell a huge number of words.

[40:57]

Like yeah, English, okay, we've got that

[40:59]

covered. But odds are you're noticing

[41:00]

depending on your own background, what

[41:02]

human languages you read or speak

[41:04]

yourself, um that a whole bunch of

[41:06]

symbols might be missing from your

[41:07]

keyboard. For instance, we have accented

[41:09]

characters here in a lot of Asian

[41:10]

languages. There's so many more glyphs

[41:12]

than we could have even fit in that

[41:13]

cheat sheet of numbers and letters. And

[41:15]

so ASI is not the only system that the

[41:18]

world uses. It was one of the earliest,

[41:20]

but we've moved on in modern times to a

[41:23]

superset of ASI that's generally known

[41:25]

as Unicode. And Unicode uses so many

[41:28]

more bits than ASI that we even have

[41:30]

room for all of these little things that

[41:32]

we seem to send constantly nowadays.

[41:34]

These are obviously images that you

[41:36]

might send with your phone or your

[41:37]

computer, but they're technically

[41:39]

characters. They're technically just

[41:41]

patterns of zeros and ones that have

[41:43]

similarly been standardized around the

[41:45]

world to look a certain way, but they're

[41:48]

this is an emoji keyboard in the sense

[41:50]

that you're sending characters. You're

[41:53]

not sending images, per se. The

[41:54]

characters are displayed as images

[41:56]

obviously, but really these are just

[41:58]

like characters in a different font. And

[42:00]

that font happens to be very colorful

[42:02]

and graphical as well. So, Unicode

[42:04]

instead of using just seven or eight

[42:06]

bits, which if you do the quick mental

[42:08]

math, if ASI only used seven or let's

[42:11]

say eight bits, how many possible

[42:14]

characters can you represent in ASKI

[42:15]

alone?

[42:17]

256. Because if we do that quick mental

[42:19]

math, 2 to the 8, 256 possibilities,

[42:21]

like that's it. That is that's enough

[42:22]

for English because you can cram all the

[42:24]

uppercase letters, the lowercase

[42:25]

letters, the numbers, and a whole bunch

[42:27]

of punctuation as well. But it's not

[42:29]

enough for certain other punctuation

[42:31]

symbols, not to mention many other human

[42:33]

languages. And so the Unicode

[42:34]

Consortium, its charge in life has been

[42:37]

to come up with a digital representation

[42:39]

of all human language, past, present,

[42:42]

and hopefully future by using not just

[42:45]

seven or eight bits, but maybe 16 bits

[42:47]

per character, 24 bits, or heck, even 32

[42:50]

bits per character. And per before, if

[42:52]

you've got as many as 32 bits available

[42:54]

to you, you can represent what, like 4

[42:57]

billion characters in total. And that's

[42:59]

just one of the reasons why these emoji

[43:01]

have kind of exploded in popularity and

[43:03]

availability. There's just so many darn

[43:05]

patterns. Like, what else are we going

[43:06]

to do with all of these zeros and ones?

[43:08]

But more importantly, emoji have been

[43:10]

designed to really represent people and

[43:13]

places and things and emotions in a way

[43:15]

that transcends human language. But even

[43:18]

then, they're somewhat open to

[43:19]

interpretation. In fact, here's a

[43:21]

pattern of I think 32 zeros and ones.

[43:24]

I'm guessing no one's going to do the

[43:25]

quick mental math here, but this

[43:27]

represents what decimal number if we do

[43:29]

in fact do out the math with that's

[43:30]

being the ones place all the way over to

[43:32]

the left. Well, that's the number 4

[43:34]

bill36,991,16.

[43:37]

Who knows what that is? It's not a and

[43:40]

it's nothing near a uppercase or

[43:42]

lowerase, but it is among the most

[43:44]

popular emoji that you might send

[43:45]

typically on your phone, laptop, or

[43:48]

other device. namely this thing here

[43:50]

face with tears of joy which odds are

[43:53]

you've sent or received recently but

[43:55]

interestingly even though many of you

[43:57]

might have iPhones and see and send the

[44:00]

same image you'll notice that if you see

[44:02]

a friend who's got Android or some other

[44:04]

device maybe you're using uh Meta's

[44:06]

messenger program or Telegram or some

[44:08]

other messaging service sometimes these

[44:10]

emoji look a little bit different why

[44:13]

because what a unicode has done is they

[44:15]

decided there shall exist an emoji known

[44:18]

as excuse me faced with tears of joy

[44:21]

then Apple and Google and Microsoft and

[44:24]

others they're sort of free to interpret

[44:26]

that as they see fit. So what you see on

[44:27]

the screen here is a recent version from

[44:29]

iOS Apple's operating system. Google's

[44:32]

version of the same looks a little

[44:33]

something like this. And on Telegram, if

[44:35]

you have animations enabled, the same

[44:37]

idea faced with tears of joy is actually

[44:39]

animated. But it's the same pattern of

[44:41]

zeros and ones in each case, but again,

[44:44]

they each essentially have different

[44:45]

graphical fonts to present to you what

[44:48]

each of those images actually is. All

[44:51]

right, so those are each, excuse me,

[44:54]

images.

[44:58]

So those are each images. How is the

[45:01]

computer representing them though? At

[45:03]

the end of the day, we've represented

[45:05]

numbers. We've represented letters. But

[45:08]

how about these things here, colors? So,

[45:10]

how do we represent red or green or

[45:13]

blue, not to mention every other color

[45:15]

in between? At the end of the day, we

[45:17]

only have one canvas at our disposal.

[45:20]

Yeah.

[45:21]

So, integers is the exact same answer as

[45:24]

before. We just need to agree on what

[45:26]

number do we use for red, what do we use

[45:28]

for green, what do we use from blue and

[45:30]

we can come up with some standardized

[45:31]

pattern for this. In fact, one of the

[45:33]

most common techniques for doing this

[45:35]

and the common one of the most common

[45:36]

ways to do this in the real world is to

[45:38]

use a combination of three colors

[45:40]

together. Some amount of red, some

[45:42]

amount of green, and some amount of blue

[45:44]

and mix them together to get most any

[45:46]

color of the rainbow that you might

[45:47]

want. This is sort of a a picture of

[45:49]

something I grew up with back in the day

[45:51]

where in like middle school when we'd

[45:52]

watch movies or some kind of show in

[45:54]

like in in class, we would kind of uh

[45:57]

the projector screen would be over here.

[45:59]

This is a old school projector with

[46:01]

three different lenses, one of which

[46:02]

projects some amount of green, some

[46:04]

amount of red, some amount of blue. And

[46:06]

so long as the lenses are correctly

[46:08]

oriented to all point at the same circle

[46:10]

or like rectangular region on the

[46:12]

screen, you would see any number of

[46:14]

colors coming to life in the old school

[46:17]

video. I still remember all these years

[46:18]

later we would kind of sit and lean up

[46:20]

against it because it was super warm and

[46:22]

you could heal it easy way to fall

[46:23]

asleep back in grade school. But we use

[46:25]

the same fundamental color system

[46:27]

nowadays as well including in modern

[46:30]

programs like Photoshop. So let's

[46:31]

abstract that away. Focus on just three

[46:34]

colors, some amount of red, green, and

[46:36]

blue. And let's suppose for the sake of

[46:38]

discussion that we want to mix together

[46:40]

like a medium amount of red, a medium

[46:42]

amount of green, and just a little bit

[46:44]

of blue. For instance, let's suppose

[46:47]

that we'll use 72 amount of red, 72

[46:51]

amount 73 amount of green or or 33

[46:55]

amount of blue, RGB. Now, why these

[46:57]

numbers? Well, in the context of ASI or

[47:00]

Unicode, which is just a supererset

[47:02]

thereof, what does this spell?

[47:04]

>> High. But again, if you were instead to

[47:07]

open a file containing these three

[47:09]

numbers, or really these three bytes of

[47:12]

bits in Photoshop, you would hope that

[47:15]

they're going to be interpreted not as

[47:16]

letters on the screen, but as some m uh

[47:20]

the the color of a dot on the screen

[47:22]

instead. So it turns out that in

[47:25]

typically when you have a three of these

[47:27]

numbers together, each of them is using

[47:29]

a single bite. So eight bits. So you can

[47:31]

have zero red or 255 red. 0 green or 255

[47:36]

green or 0 to 255 of blue. So 0 is none,

[47:40]

255 is the max. So if we mix these

[47:43]

together, imagine that just like that

[47:45]

projector consolidating these three

[47:48]

colors into one central point. Anyone

[47:50]

want to guess what you're going to get

[47:51]

if you mix some red, some green, some

[47:53]

blue in those amounts in way back?

[47:58]

>> Yeah, you're going to get a dark shade

[47:59]

of yellow. I've brightened it up a

[48:00]

little bit for the projector here, but

[48:02]

you're going to get roughly this shade

[48:03]

of yellow. And we could play with these

[48:05]

numbers all day long and get similar

[48:07]

results if we want to represent

[48:08]

different colors as well. And indeed,

[48:10]

whether it's Photoshop or some other

[48:12]

program, you can actually combine these

[48:14]

amounts in all sorts of ratios to get

[48:16]

different colors. So if you had 0 0, so

[48:19]

no red, no green, no blue, take a guess

[48:21]

as to what color that's going to be in

[48:22]

the computer.

[48:24]

>> So it's going to be black, like the

[48:25]

absence of all three of those colors.

[48:26]

But if you mix the maximum amount of

[48:28]

each of those 255 red and green and

[48:31]

blue, that's going to give you white.

[48:33]

Now, if any of you have made web pages

[48:34]

before or used programs like Photoshop,

[48:37]

you might have seen numbers like 00 or

[48:40]

FF. Long story short, that's just

[48:42]

another base system for representing

[48:44]

numbers between 0 and 255 as well. But

[48:47]

we'll come back to that mid-semester

[48:48]

when we make some of our own filters uh

[48:51]

in sort of an Instagram-like way,

[48:52]

manipulating images of our own. So,

[48:55]

where are these colors coming from or

[48:57]

where can we actually see them? Well,

[48:58]

here's just a picture of that same emoji

[49:00]

face with tears of joy. If I kind of

[49:02]

zoom in on that and maybe zoom in again,

[49:04]

you can start to see if you blow it up

[49:06]

enough or if you put your eyes close

[49:08]

enough to the device, sometimes you can

[49:10]

actually see individual dots or squares.

[49:13]

These are generally known as pixels. And

[49:15]

they're just the individual dots that

[49:17]

collectively compose an image. Which is

[49:20]

to say that if each of these dots, which

[49:22]

is part of the image, is going to be a

[49:24]

distinct color. Like this one's yellow,

[49:26]

this one's brown, and then there's a

[49:28]

bunch in between. Well, you're using

[49:30]

some number of bits to represent each of

[49:33]

those pixels colors. So, if you imagine

[49:36]

using the RGB system, that's 8 + 8 + 8

[49:40]

bits. So, that's 24 bits or three bytes

[49:43]

just to keep track of the color of each

[49:46]

and every one of these dots. So now, if

[49:48]

you think about having downloaded a GIF

[49:50]

at some point, a ping, PNG file, um a

[49:53]

JPEG or any other file format, it's

[49:55]

usually measured in what file size? like

[49:57]

megabytes typically that means millions

[50:00]

of bytes. Why? Because if it's a pretty

[50:02]

big photograph or pretty big image, each

[50:04]

of those dots takes up at least three

[50:07]

bytes it would seem. And if you do out

[50:09]

the math, if you got thousands of dots,

[50:11]

each of which uses three bytes, you're

[50:12]

going to quickly get to megabytes, if

[50:14]

not even larger for things like say

[50:16]

videos. But again, it's just patterns of

[50:19]

zeros and ones. And so long as the

[50:21]

programmer knows what they're doing and

[50:23]

tells the computer how to interpret

[50:24]

those zeros and ones. And equivalently,

[50:26]

so long as the software knows, look at

[50:28]

these zeros and ones and interpret them

[50:30]

as numbers or letters or colors, we

[50:33]

should see what we intended to

[50:35]

represent. All right, so that's num

[50:38]

that's uh colors and images. What about

[50:41]

how many of you kind of played with

[50:42]

these little flip books as a kid where

[50:43]

they've got like a hundred different

[50:44]

little pictures and you flip through

[50:46]

them really quickly and you see what

[50:47]

looks like animation in book form. Well,

[50:50]

this is essentially a video. So

[50:52]

therefore, what is a video or how can

[50:54]

you think of what a video is? It's just

[50:56]

a whole bunch of like images flying

[50:58]

across the screen either on paper or

[51:00]

digitally nowadays on your phone or your

[51:01]

laptop. And that's kind of nice because

[51:03]

we're sort of composing more interesting

[51:05]

media now based on these lower level

[51:07]

building blocks. And this is going to be

[51:09]

thematic. We literally started with

[51:10]

zeros and ones. We worked our way up to

[51:12]

letters. We then worked our way up to

[51:14]

sort of images and uh colors and thus

[51:16]

images. Now we're up at this level of

[51:18]

hierarchy in terms of video because

[51:20]

what's a video? It's like 30 images per

[51:24]

second flying across the screen or maybe

[51:26]

slightly fewer than that. That

[51:28]

collectively tricks our mind into

[51:29]

thinking we are seeing motion pictures.

[51:32]

And that's the old school term for

[51:33]

movies, but it literally is what it was.

[51:36]

motion pictures was this film was

[51:38]

showing you 30 pictures per second and

[51:40]

it looks like motion even though you're

[51:42]

just looking at images much like this

[51:43]

flip book very quickly one after the

[51:46]

other. What about music? Well, how could

[51:48]

you go about representing musical notes

[51:50]

if again your only ingredients are zeros

[51:54]

and ones? Even if you're not a musician,

[51:57]

how do you represent music like that on

[51:59]

the screen here? Yeah. Okay. So, the

[52:01]

frequency like the tone that you're

[52:03]

actually hearing from the device. What

[52:05]

else might weigh in beside besides the

[52:07]

frequency of the note? Yeah.

[52:10]

>> So the speed of the note or maybe the

[52:11]

duration like if you think about a

[52:12]

physical piano like how long you're

[52:14]

holding the key down for or not. What

[52:16]

else? So the amplitude maybe how loud

[52:19]

like how hard did you hit the keyboard

[52:20]

to generate that sound. So let me

[52:22]

propose at the risk of simplifying we

[52:24]

could represent each of these notes

[52:26]

using three numbers. maybe 0 to 255 or

[52:29]

some other range that represents the

[52:31]

frequency or the pitch of the note, the

[52:33]

duration, and the loudness. And so long

[52:35]

as the person receiving a file

[52:38]

containing all of those zeros and ones

[52:40]

knows how to interpret them three at a

[52:42]

time, I bet you could share uh a musical

[52:45]

file with someone else that they could

[52:47]

hear in exactly the same way that you

[52:49]

yourself intended. Let me pause here to

[52:53]

see if there's any questions now because

[52:56]

we've already built our way up from

[52:57]

zeros and ones now to video and sound.

[53:01]

>> Yeah, in front.

[53:03]

>> How does the computer know differentiate

[53:05]

between what the letter like 65 would be

[53:08]

and then what the number 65?

[53:10]

>> So, how does the computer distinguish

[53:11]

between the letter 65 and the number 65?

[53:14]

It's context dependent. So put simply

[53:16]

and we'll see this as early as next week

[53:18]

the programmer tells the computer how to

[53:21]

display the information either as a

[53:23]

number or a letter or equivalently once

[53:26]

programmed the software knows that when

[53:28]

it opens a GIF file or JPEG or something

[53:32]

else to interpret those zeros and ones

[53:35]

as colors instead of as like docx for a

[53:38]

Microsoft Word file or the like. Other

[53:41]

questions on any of these

[53:43]

representations?

[53:45]

Yeah. In front.

[53:46]

>> Can we go over like the base 10 base 2

[53:48]

thing like really briefly?

[53:50]

>> Sure. So, can we go over base 10 and

[53:51]

base two? So, base 10 is like literally

[53:54]

the numbers you and I use every day.

[53:55]

It's base 10 in the sense that you have

[53:57]

10 digits at your disposal. 0 through 9.

[54:00]

And any numbers you want to represent in

[54:02]

the real world must be composed using 0

[54:05]

through 9. The binary system or base 2

[54:08]

is fundamentally the same. It's just the

[54:10]

computer doesn't have access to 2

[54:11]

through 9. It only has access to zero

[54:14]

and one. But much like the light bulbs I

[54:16]

was displaying here, you can simply

[54:18]

ascribe different weights to each of the

[54:21]

digits. So that instead of it being as

[54:23]

much as the ones place, the t's place,

[54:25]

and the hundred's place, if we more

[54:26]

modestly say the ones place, the two's

[54:28]

place, the four's place, we can use the

[54:30]

same system. In binary, you might need

[54:32]

to use more digits to count as high.

[54:36]

Because in 255, you can just write 255.

[54:39]

That's three digits in decimal. But in

[54:41]

binary, we've seen you need to use eight

[54:43]

such digits, which is more, but it's

[54:46]

still much better than unary, which

[54:47]

would have had 255 light bulbs on

[54:50]

instead.

[54:51]

>> And is

[54:53]

binary and like the same thing.

[54:56]

>> Is binary and base 2 the same thing?

[54:58]

Yes. Just like base 10 and decimal are

[55:00]

the same thing as well. And unary and

[55:02]

base 1 are the same thing as well. All

[55:05]

right. So let me just stipulate that

[55:07]

even though we sort of took this tour

[55:09]

quickly at the end of the day computers

[55:10]

only have zeros and ones at their

[55:11]

disposal. So again the answer to any

[55:13]

question as to how can we represent X is

[55:17]

going to somehow involve permuting those

[55:19]

zeros and ones into patterns or

[55:21]

equivalently into the numbers that they

[55:23]

represent. But if we now have a way to

[55:25]

represent all inputs in the world be it

[55:27]

letters, numbers, images, videos,

[55:29]

anything else and get output from some

[55:31]

problem-solving process like how do we

[55:33]

actually solve problems? Well, the

[55:35]

secret sauce in the middle here is

[55:36]

another term that you've probably heard

[55:37]

in the real world nowadays, which is

[55:39]

that of algorithm. Stepbystep

[55:41]

instructions for solving some problem.

[55:44]

So, this ultimately is what computer

[55:45]

science really is about too, is not just

[55:48]

representing information, but somehow

[55:49]

processing it, doing something

[55:51]

interesting with it to actually solve

[55:53]

the problem that you've been provided as

[55:54]

input so you can output the correct

[55:56]

answer. Now, there's all sorts of

[55:58]

algorithms implemented in our phones and

[56:01]

in our Macs and PCs, and that's all

[56:02]

software is. It's an implementation in

[56:05]

code, be it C++ or Java or anything

[56:08]

else. Other languages exist too in code

[56:12]

that the computer understands, but it's

[56:14]

still just step-by-step instructions.

[56:15]

And among the things we'll learn in CS50

[56:17]

is how to express yourself in different

[56:19]

ways to solve problems, not only in

[56:21]

different languages, but using different

[56:23]

methodologies as well. Because as we'll

[56:24]

see, among the reasons we introduce

[56:26]

these several languages is you don't

[56:27]

just learn more and more languages that

[56:29]

allow you to solve the same problems.

[56:32]

different languages will allow you to

[56:33]

solve different problems and even save

[56:35]

you time by being better tools for the

[56:38]

job. So here for instance on uh an

[56:40]

iPhone is maybe a bunch of contacts

[56:42]

which is presumably familiar where we

[56:44]

might have a whole bunch of friends and

[56:45]

family and whatnot alphabetized by first

[56:48]

name or last name and suppose we want to

[56:49]

find one such person like John Harvard

[56:51]

whose number here might be plus1

[56:52]

949-468-2750

[56:55]

feel free to call or text him sometime.

[56:57]

Um this is the goal of this problem. If

[57:00]

we have our contacts app and I start

[57:02]

typing in John's name by first name or

[57:04]

last name, the autocomplete nowadays

[57:06]

kicks in and it somehow filters the list

[57:08]

down from my 10 friends or 100 friends

[57:10]

or a thousand friends into just the

[57:12]

single directory entry that matches. So

[57:15]

here too, back in the days of RG&B um

[57:19]

projector, we had uh phone books like

[57:21]

this here too. Um I'm pleased to say

[57:23]

thanks to our friend Alexis, this is the

[57:24]

largest phone book that we've used for

[57:26]

this demonstration. Uh, this is an old

[57:28]

school phone book that's essentially the

[57:30]

same thing as our contacts app or

[57:31]

address book nowadays whereby I've got a

[57:33]

whole bunch of names and numbers

[57:35]

alphabetically sorted by first name or

[57:37]

last name, whatever, and corresponding

[57:39]

to each of those as a number. So, back

[57:40]

in the day and frankly even nowadays in

[57:43]

your phones, how do you go about finding

[57:45]

someone in a phone book or your contacts

[57:47]

app? Well, you could very naively just

[57:49]

start at the beginning and look down and

[57:51]

just turn one page at a time looking for

[57:54]

John Harvard in this case. Now, so long

[57:56]

as I'm paying attention, this

[57:57]

step-by-step process will get me to John

[58:00]

Harvard. Like, this is a correct

[58:02]

algorithm, even though you might kind of

[58:05]

object to how I'm doing this. Why? Like,

[58:08]

what's bad about this algorithm?

[58:10]

>> It's just slow. I mean, this is crazy

[58:12]

slow. If there's like a thousand pages

[58:13]

in this phone book, which looks like

[58:14]

there are, like this could take me as

[58:16]

many as a thousand pages, or maybe he's

[58:18]

roughly in the middle, like 500 pages.

[58:20]

Like, that's crazy. That's really rather

[58:22]

slow, especially if I'm going to do this

[58:23]

again and again. Well, what if I do it a

[58:25]

little smarter? Grade school, I sort of

[58:26]

learned how to count two at a time. So,

[58:28]

2 4 6 8 10 12 14 16 18. Again, if I'm

[58:33]

paying attention, I'll get there twice

[58:35]

as fast because I'm counting two at a

[58:37]

time. But is that algorithm step by step

[58:39]

correct?

[58:41]

And I'm seeing no, but why?

[58:44]

>> I might skip over John Harvard. So, just

[58:46]

by bad luck and kind of with 50/50

[58:48]

probability, he's going to be sandwiched

[58:50]

between two of the pages. Now, I don't

[58:52]

have to abort this algorithm alto

[58:54]

together. I could just as soon as I get

[58:56]

past the J section if we're doing it by

[58:57]

first name. I could just double back one

[58:59]

page and just make sure that I haven't

[59:02]

missed him. So, it's recoverable. And

[59:04]

this algorithm therefore is sort of

[59:05]

twice as fast plus one extra step maybe

[59:08]

to double back. But that's arguably

[59:10]

otherwise a bug or mistake in the

[59:11]

algorithm if I don't fix it

[59:13]

intelligently. But what did we do back

[59:14]

in the day? And what does your iPhone or

[59:16]

Android phone do? What they typically do

[59:18]

is they go roughly to the middle, look

[59:21]

physically or virtually down. They see,

[59:23]

oh, I'm in the M section. And so, which

[59:25]

side is John Harbor to? To the left or

[59:27]

to the right? So, he's to the left. So,

[59:29]

I could literally now

[59:34]

Jesus Christ.

[59:37]

We talked about this before class that

[59:38]

this might be more Oh my god. There we

[59:41]

go. We can tear the problem in half.

[59:44]

Thank you.

[59:49]

It's been a while. We can tear the

[59:51]

problem in half. We know that John

[59:52]

Harvard is to the left. So, I can throw

[59:55]

half of the problem away if uh

[59:58]

dramatically such that I've now gone

[59:59]

from a thousandpage problem to 500 pages

[60:02]

instead. What now can I do? I can go

[60:04]

roughly to the middle here and maybe I'm

[60:06]

in the E section. So, I went a little

[60:07]

too far back to the left, but I kept it

[60:09]

simple and I just divided so that I can

[60:11]

conquer this problem, if you will. And

[60:12]

if I'm in the E section now, is John

[60:14]

Harvard to the left or to the right? To

[60:16]

the right. So I can again Jesus Christ.

[60:22]

Tear the problem in half. And now, thank

[60:25]

you. So now John Harvard again is going

[60:27]

to be in this half. I can throw this

[60:29]

half away. So now I've gone from a,000

[60:30]

to 500 to 250. And I can repeat, repeat,

[60:33]

repeat down to 125. Half of that, half

[60:35]

of that, half of that until I'm left

[60:37]

with finally just a single page. And

[60:39]

John Harvard is hopefully now on this

[60:41]

page such that I can call him or not at

[60:43]

all at which point this is all sort of

[60:45]

for not. But what's powerful about each

[60:48]

of those algorithms is that there sort

[60:49]

of good better and best like they all

[60:51]

get the job done conditional on the

[60:53]

second one having that little fix just

[60:55]

to make sure I don't miss John Harbor

[60:57]

between two pages but they're

[60:58]

fundamentally different in their

[61:00]

efficiency and the quality of their

[61:02]

design. And this is really

[61:04]

representative of one of the emphases of

[61:06]

a class like this. It's not just about

[61:07]

writing correct code or getting the job

[61:09]

done, but doing it well and doing it

[61:12]

quickly. Using the least amount of CPU

[61:15]

or computing resources, using the

[61:17]

minimal amount of RAM, using the fewest

[61:19]

number of people, using the least amount

[61:21]

of money, whatever your constrained

[61:23]

resource is, solving a problem better.

[61:25]

So that first algorithm step-by-step

[61:28]

instructions was all about doing

[61:30]

something like this whereby the first

[61:33]

algorithm if we plot things on a grid

[61:35]

like this we have on the x-axis a

[61:38]

representation of the size of the

[61:40]

problem. So this would mean small

[61:41]

problem like zero pages. This would mean

[61:43]

big problem like a thousand pages. And

[61:45]

on the y or vertical axis we have some

[61:48]

measurement of time. So this is the

[61:49]

number of seconds or the number of page

[61:51]

turns whatever your metric actually is.

[61:54]

So this would be uh not much time at

[61:56]

all, so fast. This would be a lot of

[61:58]

time, so slow. So what's the

[61:59]

relationship if we just roughly draw

[62:01]

these three algorithms? Well, the first

[62:03]

one is technically a straight line. And

[62:05]

we'll describe that as n. The slope is n

[62:07]

because if you think of n as a number

[62:09]

for the number of pages, well, there's a

[62:10]

one toone relationship in the first

[62:12]

algorithm as to how many times I have to

[62:15]

turn the page based on how many pages

[62:17]

there actually is. And you can think

[62:18]

about this in the extreme. If I was

[62:20]

looking for someone whose name started

[62:22]

with Z, I might have to go through like

[62:24]

a thousand darn pages to get to that

[62:26]

person whose name started with Z, unless

[62:28]

again I do something hackish and just

[62:29]

kind of cheat and go to the end. If we

[62:31]

execute these algorithms again and again

[62:33]

the same way, that's going to be pretty

[62:35]

slow. But the second algorithm was

[62:37]

pretty much twice as fast plus that one

[62:39]

extra step potentially. But it's still a

[62:41]

straight line because if there's a

[62:42]

thousand pages and I'm dividing the

[62:45]

problem and I'm doing two pages at a

[62:46]

time, well that's like n divided by two

[62:48]

steps plus one give or take. But it's

[62:51]

still a straight line because but it's

[62:53]

still better. Notice if this is the size

[62:55]

of the problem, a thousand pages for

[62:57]

instance, we'll notice that the first

[62:59]

algorithm took literally twice as much

[63:02]

time as the second algorithm. So we're

[63:04]

doing better already. But the third

[63:06]

algorithm fundamentally is going to look

[63:08]

something like this. And if you remember

[63:09]

your logarithm so to speak, sort of the

[63:11]

opposite of an exponential. This curve

[63:14]

is so much lower and flatter if you will

[63:18]

than either of these two mathematically.

[63:19]

More on this another time. The slope is

[63:21]

going to be like log base 2 of n or just

[63:24]

logarithmic in nature. But what it means

[63:26]

is that it's growing very very very

[63:29]

slowly. It's still going up. It's never

[63:30]

going to flatline and go perfectly

[63:32]

horizontal, but it goes up very slowly.

[63:34]

Why? Well, if you think about two towns

[63:36]

nearby, like Cambridge on this side of

[63:38]

the river and the town of Alustin on the

[63:40]

other. Suppose that they still have

[63:41]

phone books like this one, and they

[63:42]

merge their phone books for whatever

[63:44]

reason. So, overnight, we go from a

[63:46]

thousandpage phone book to a 2,000page

[63:48]

phone book. The first algorithm is going

[63:50]

to take literally twice as long as will

[63:53]

the second one because we're only going

[63:54]

through it one or two pages at a time.

[63:56]

But if the phone book size doubles from

[63:59]

this year, for instance, to next year,

[64:01]

you can kind of in your mind's eye think

[64:03]

about the green line. It's not going to

[64:05]

go up that much higher. Why? Well,

[64:08]

practically speaking, even if the phone

[64:10]

book becomes 2,000 pages long. Well, how

[64:13]

many more times do you have to tear or

[64:16]

divide that problem in half?

[64:18]

>> Just one. Because you're taking a,000

[64:21]

page bite out of it, or a 500 than a

[64:23]

250. taking much bigger bites out of it

[64:25]

than just one or two at a time. And so

[64:28]

what computer science and what

[64:29]

algorithms and about good design is

[64:31]

about is figuring out what is the logic

[64:34]

via which you can solve problems not

[64:36]

only correctly but efficiently as well.

[64:39]

And that then gives us these things

[64:41]

called algorithms. And when it comes

[64:42]

time to code, which we're about to do

[64:44]

too, code is just an implementation and

[64:47]

a language the computer understands of

[64:49]

an algorithm. Now this assumes that

[64:51]

we've come up with some digital way that

[64:53]

is to say zero in onebased way to

[64:55]

represent names and numbers. But

[64:57]

honestly we already did that. We came up

[64:59]

with a asky and then unicode to

[65:01]

represent the names. Representing

[65:02]

numbers is even easier than that. That's

[65:04]

really where we started. So code is just

[65:07]

about taking as input some standardized

[65:09]

representation of names and numbers and

[65:11]

spitting out answers. And that's truly

[65:13]

what iOS and Android are doing. When you

[65:15]

start doing autocomplete, they could be

[65:18]

searching from the top to the bottom,

[65:20]

which is fine if you've only got a few

[65:22]

friends and family in the phone. But if

[65:23]

you've got a thousand or if you've got

[65:25]

10,000 or if it's not a phone book

[65:27]

anymore, it's some database with lots

[65:29]

and lots of data. Well, it stands to

[65:31]

reason that it'd be nice maybe if the

[65:33]

computer kept it all alphabetized just

[65:35]

like that book and jumped to the middle,

[65:37]

then the middle of the middle, then the

[65:39]

middle of the middle of the middle, and

[65:40]

so forth. Why? because the speed is

[65:43]

going to be much much faster,

[65:45]

logarithmic in nature and not linear so

[65:48]

to speak in nature. But we'll revisit

[65:49]

those topics as well. But for now,

[65:51]

before we get into actual code, let's

[65:54]

talk for a moment about pseudo code. So

[65:56]

pseudo code is not one formal thing.

[65:58]

Every human will come up with their own

[66:00]

way of representing pseudo code. It's an

[66:02]

English-like or humanlike formulation of

[66:05]

step-by-step instructions just using tur

[66:08]

correct English or whatever human

[66:10]

language. So, for instance, if I want to

[66:12]

translate what I did somewhat

[66:13]

intuitively with that phone book by just

[66:15]

dividing in half, dividing in half into

[66:17]

step-by-step instructions, I could hand

[66:18]

you or now it is like a robot or

[66:21]

something like that. Well, step one was

[66:23]

essentially to pick up the phone book,

[66:24]

which I did. Step two was I open to the

[66:26]

middle of the phone book in the third

[66:28]

and final algorithm. Step three was look

[66:30]

at the page as I did. Step four got a

[66:33]

little more interesting. Even though I

[66:34]

didn't verbalize this, presumably I was

[66:36]

asking myself a question. If the person

[66:38]

I'm looking for, John Harbert, is on the

[66:40]

page, then I would have called him right

[66:43]

then. But if he weren't on the page, if

[66:46]

he instead were earlier in the book, as

[66:48]

did happen, well, then I'm going to go

[66:50]

to the left, so to speak, but more

[66:52]

methodically, I'm going to open to the

[66:54]

middle of the left half of the book.

[66:56]

Then I'm going to go back to line three.

[66:59]

That's interesting. We'll come back to

[67:00]

that in a moment. But else if the person

[67:02]

is later in the book, well, I'm going to

[67:04]

open to the middle of the right half of

[67:05]

the book. and then go back to line

[67:09]

three. Now, let's pause here. Why do I

[67:12]

keep going back to line three? This

[67:13]

would seem to get me doing the same

[67:15]

thing forever endlessly,

[67:19]

but not quite. Why?

[67:20]

>> As soon as you hit the one, the

[67:22]

condition on line.

[67:24]

>> Yeah. So, because I am dividing the

[67:27]

problem in half, for instance, on line

[67:29]

six or line N implicitly, just based on

[67:32]

how I've written this, the problem's

[67:33]

getting smaller and smaller and smaller.

[67:35]

So, it's fine if I keep doing the same

[67:37]

logic again and again because if the

[67:39]

problem's getting smaller, eventually

[67:40]

it's going to bottom out and I'm going

[67:41]

to have just one person on that page

[67:44]

that I want to call and so the algorithm

[67:46]

is done. But there is a perverse corner

[67:48]

case, if you will. And this is where

[67:50]

it's ever more important to be precise

[67:52]

when writing code and anticipate what

[67:54]

could go wrong. I should probably ask

[67:56]

one more question in this code, not just

[67:59]

these three. What might that question

[68:04]

be?

[68:05]

Yeah.

[68:06]

>> If John Harvard is in the book.

[68:07]

>> Yeah. So, if John Harvard is not in the

[68:09]

book, there's this corner case where

[68:11]

what if I'm just wasting my time

[68:12]

entirely and I get to the end of the

[68:13]

phone book and John Harvard's not there.

[68:15]

What should the computer do? Well, as an

[68:17]

aside, if you've ever been using your

[68:18]

Mac or PC or phone and the thing just

[68:19]

freezes or like the stupid little beach

[68:21]

ball starts spinning or something like

[68:23]

that and you're like, "What is going

[68:24]

on?" Some human at Google or Microsoft

[68:27]

or Apple or the like made a mistake.

[68:29]

they forgot for instance that fourth

[68:32]

uncommon but possible situation wherein

[68:35]

if they don't tell the computer how to

[68:36]

handle it the computer's effectively

[68:38]

going to freak out and do something

[68:39]

undefined like just hang or reboot or do

[68:43]

something else. So we do want to add

[68:44]

this else quit altogether. So you have

[68:48]

welldefined behavior and truly think

[68:50]

that the next time your computer or

[68:52]

phone spontaneously reboots or dies or

[68:54]

does something wrong, it's probably not

[68:56]

your fault per se. It's some other human

[68:58]

elsewhere did not write correct code.

[69:01]

They didn't anticipate cases like these.

[69:04]

But now let's use some terminology here.

[69:05]

There's some salient ideas that we're

[69:07]

going to see in Scratch and C and Python

[69:09]

and these other languages I alluded to

[69:11]

earlier. Everything I've just

[69:12]

highlighted here henceforth we're going

[69:14]

to think of as functions. Functions are

[69:17]

verbs or actions that really get some

[69:19]

small piece of work done for you.

[69:21]

Functions are verbs or actions. Here

[69:24]

though highlighted is the beginning of

[69:25]

what we'll call conditionals.

[69:27]

Conditional is like a fork in the road.

[69:29]

Do I go this way? Do I go this way or

[69:31]

some other way altogether? How do you

[69:32]

decide what road to go down? We're going

[69:35]

to call these questions you ask yourself

[69:37]

boolean expressions. Named after a

[69:40]

mathematician Bull. And a boolean

[69:41]

expression is just a question that has a

[69:43]

yes or no answer or a true or false

[69:46]

answer or a one or zero answer just it's

[69:49]

a binary state yes or no typically.

[69:52]

Otherwise we have this go back to go

[69:55]

back to which is what we're generally

[69:56]

going to call a loop which somehow

[69:58]

induces cyclical behavior again and

[70:01]

again. And those functions and those

[70:03]

conditionals, boolean expressions, and

[70:05]

loops and a few other concepts are

[70:06]

pretty much what will underly all of the

[70:08]

code that we write, whether it is in

[70:10]

Scratch, C, or something else

[70:12]

altogether. But we need to get to that

[70:15]

point. And in fact, let's go and infer

[70:19]

what this program here does. At the end

[70:21]

of the day, computers only understand

[70:22]

zeros and ones. So I claim here is a

[70:24]

program of zeros and ones. What does it

[70:27]

do?

[70:29]

Anyone

[70:31]

want to guess? I mean, we could spend

[70:32]

all day converting all of these zeros

[70:34]

and ones to numbers, but they're not

[70:35]

going to be numbers if it's code. What

[70:37]

do you think?

[70:39]

>> That's amazing. It does in fact print

[70:42]

hello world.

[70:45]

All right. So, no one except like maybe

[70:47]

you and me and a few others in the room

[70:48]

should know, and that was probably guess

[70:49]

admittedly or advancing on the slide.

[70:51]

But why is that? Well, it turns out that

[70:53]

not only do computers standardize

[70:55]

information, data like numbers and

[70:57]

letters and colors and other things,

[70:59]

they also standardize instructions. And

[71:01]

so, if you've heard of companies like

[71:02]

Intel or AMD or Nvidia or others, among

[71:06]

the things they do is they decide as a

[71:08]

company what pattern of zeros and ones

[71:10]

shall represent what functionality. And

[71:13]

it's very low-level functionality. those

[71:15]

companies and others decide that some

[71:17]

pattern of zeros and ones means add two

[71:19]

numbers together or subtract or

[71:22]

multiply. Another pattern might mean

[71:23]

load information from the computer's

[71:25]

hard drive into memory. Another might

[71:27]

mean store it somewhere else. Another

[71:29]

might mean print something out to the

[71:31]

screen. So nested somewhere in here and

[71:34]

admittedly I have no idea which pattern

[71:35]

off because it's not interesting enough

[71:37]

to go figure it out at this level says

[71:39]

print. And somewhere in there, like this

[71:42]

gentleman proposed, I bet we could find

[71:44]

the representation of H, which was 72

[71:47]

and E and L and L and O and everything

[71:50]

that composes hello world. Because, as

[71:52]

it turns out in programming circles, the

[71:54]

very first program that students

[71:56]

typically write is that of hello world.

[71:58]

Now, this one here is written in a much

[72:01]

more intelligible way. Even if you're

[72:03]

not a programmer, odds are if I asked

[72:05]

you, what does this program do? you

[72:06]

would have said,

[72:09]

"Oh, hello world." Even though there's a

[72:10]

lot of clutter here, like no idea what

[72:12]

this is until next week. Int main void.

[72:14]

That looks cryptic. There's these weird

[72:15]

curly braces, which we rarely use in the

[72:17]

real world, but at least I understand a

[72:19]

few words like hello in world. And this

[72:21]

is kind of familiar. Print f, but it's

[72:24]

not print, but it's probably the same

[72:25]

thing. So, here too is an example of

[72:27]

this hierarchy. Back in the day, in the

[72:29]

earliest days of computers, humans were

[72:32]

writing code by representing zeros and

[72:34]

ones. If you've ever heard your parents

[72:36]

talk about punch cards or the like,

[72:37]

you're effectively representing patterns

[72:39]

that tell the computer what to do or

[72:41]

what to represent, like literally holes

[72:42]

in paper. Well, pretty quickly early on,

[72:44]

this got really tedious, only writing

[72:47]

code at such a low level. So, someone

[72:48]

decided, you know what, I'm going to put

[72:50]

in the effort. I'm going to figure out

[72:52]

what patterns of zeros and ones I can

[72:53]

put together so as to be able to convert

[72:56]

something more user friendly to those

[73:00]

zeros and ones. And as a teaser for next

[73:02]

week, that person invented the first

[73:04]

compiler. A compiler is just a program

[73:06]

that translates one language to another.

[73:08]

And more modernly, this is a language

[73:10]

called C, which we'll spend a few weeks

[73:11]

on together because it's so fundamental

[73:13]

to how the computer works. Even this is

[73:15]

going to get tedious by like week six of

[73:17]

the class. And this is going to get

[73:19]

stupid. This is going to get annoying.

[73:20]

This is going to get cryptic. We're just

[73:22]

going to write print hello on the screen

[73:24]

in order to use a different language

[73:26]

called Python. Why? because someone

[73:28]

wrote in C a program that can convert

[73:32]

Python, this is a white lie, to C which

[73:35]

can then be converted to zeros and ones

[73:37]

and so forth. So in computing there's

[73:39]

this principle of abstraction where we

[73:41]

start with the basics and thank god we

[73:42]

can all trust that someone else solved

[73:44]

these really hard problems or way uh

[73:46]

long ago. Then they wrote programs to

[73:48]

make it easier. We wrote programs to

[73:50]

make it easier. You can now write code

[73:52]

like I did with the chatbot to make

[73:54]

things even easier. Why? because OpenAI

[73:56]

and other companies have abstracted away

[73:58]

a lot of the lower level implementation

[74:00]

details. And that's where I think this

[74:01]

stuff gets really exciting. We can stand

[74:03]

on the shoulders of others so long as we

[74:05]

know how to use and assemble these kinds

[74:08]

of building blocks. And speaking of

[74:10]

building blocks, let's start here. Now,

[74:12]

odds are some of you might have started

[74:13]

here in like grade school playing with

[74:14]

Scratch. And it's great for like after

[74:16]

school programs learning how to program.

[74:18]

And you probably used it this language

[74:20]

to make games and graphics and just

[74:22]

maybe playful art or the like. But in

[74:24]

Scratch, which is a graphical

[74:26]

programming language designed about 20

[74:27]

years ago from our friends down the road

[74:29]

at MIT's Media Lab, it represents pretty

[74:32]

much everything we're going to be doing

[74:34]

fundamentally over the next several

[74:35]

weeks in more modern languages like C

[74:39]

and Python, more textual languages, if

[74:41]

you will. I bet I could ask the group

[74:43]

here, what does this program do when you

[74:44]

click a green flag? Well, it says hello

[74:48]

world on the screen. Because with

[74:50]

Scratch, you have the ability to express

[74:52]

yourself with functions and loops and

[74:53]

conditionals and all of this, but by

[74:55]

using drag and drop puzzle pieces. So,

[74:58]

what we're about to do is this. We're

[75:00]

going to go on my screen to

[75:01]

scratch.mmit.edu.

[75:03]

It's a browser-based programming

[75:04]

environment and we're only going to

[75:05]

spend one week or really a few days in

[75:07]

CS50 on this language, but the

[75:09]

overarching goal is to one make sure

[75:12]

everyone's comfortable applying some of

[75:13]

these building blocks and actually

[75:14]

developing something that's interesting

[75:16]

and visual and audio as well, but to

[75:18]

also give us some visuals that we can

[75:20]

rely on and fall back on when all of

[75:23]

those curly braces and parentheses and

[75:25]

sort of stupid syntax comes back. that's

[75:28]

necessary in many languages, but can

[75:30]

very quickly become a distraction early

[75:32]

on from the interesting and useful

[75:34]

ideas. So, what we're about to see is

[75:36]

this in a browser. This is the Scratch

[75:38]

programming environment, and there's a

[75:39]

few different parts of this world. This

[75:41]

is the blocks pallet, so to speak. Uh

[75:43]

that is to say, there's a bunch of

[75:44]

puzzle pieces or building blocks that

[75:46]

represent functions and conditionals and

[75:49]

v and uh loops and other such

[75:51]

constructs. There's going to be the

[75:53]

programming area here where you can

[75:54]

actually write your code by dragging and

[75:56]

dropping these puzzle pieces. There's a

[75:58]

whole world of sprites here. By default,

[76:00]

Scratch is uh and is a cat by design,

[76:03]

but you can make Scratch look like a

[76:05]

dog, a bird, a garbage can, or anything

[76:07]

else as we'll soon see. And then this is

[76:09]

the world in which Scratch itself lives.

[76:11]

So Scratch can go up, down, left, right,

[76:14]

and generally be animated within that

[76:15]

world. For the curious, kind of like

[76:17]

high school geometry class, there's sort

[76:19]

of this XY plane here. So 0 0 would be

[76:21]

in the middle. 0 180 is here. 0 comma

[76:25]

180 is here. Uh -240 is here. And

[76:29]

positive 240 here. Generally you don't

[76:31]

need to worry about the numbers but they

[76:33]

exist. So that when you say up or down,

[76:35]

you can actually tell the program go up

[76:38]

one pixel or 10 pixels or 100 pixels so

[76:40]

that you have some definition of what

[76:42]

this world actually is. All right. So

[76:45]

let's actually put this to the test. Let

[76:47]

me go ahead here and flip over to in

[76:50]

just a moment the actual Scratch website

[76:53]

whereby I'm going to have on my screen

[76:56]

in just a moment that same user

[76:58]

interface once I've logged in that via

[77:01]

which I can actually write some code of

[77:03]

my own. Let me go ahead and zoom in on

[77:05]

the screen a little bit here and let's

[77:06]

make the simplest of these programs

[77:08]

first. Maybe a program that simply says

[77:10]

hello world. Now at a glance it's kind

[77:12]

of overwhelming how many puzzle pieces

[77:13]

there are. And honestly, even over 20

[77:15]

years, I've never used them all. And MIT

[77:17]

occasionally adds to it. But the point

[77:18]

is that they're colorcoded to resemble

[77:21]

the type of functionality that they

[77:22]

offer. And also, it's meant to be the

[77:24]

sort of thing where you can just kind of

[77:26]

scroll through and get a visual sense of

[77:28]

like what you could do and then figure

[77:29]

out how you might assemble these puzzle

[77:31]

pieces together. So, I'm going to go

[77:33]

under this yellow or orangish category

[77:36]

here to begin with. So there exists in

[77:38]

the world of Scratch, not quite the same

[77:40]

jargon that I'm using now, functions and

[77:43]

conditionals and loops. That's more of

[77:44]

the programmer's way. This is more of

[77:46]

the child-friendly way, but it's really

[77:48]

the same idea. Under events, you have

[77:50]

puzzle pieces that represent things that

[77:52]

can happen while the world is running.

[77:55]

So for instance, the first one here is

[77:57]

sort of the canonical when the green

[77:59]

flag is clicked. Why is that relevant?

[78:01]

Well, in the two-dimensional world that

[78:02]

Scratch lives in, there's a stop sign,

[78:04]

which means stop, and there's a green

[78:06]

flag, which means go. So, I can

[78:07]

therefore drag one of these puzzle

[78:09]

pieces over here, so that when I click

[78:11]

that green flag, the cat will in fact do

[78:14]

something for me. Doesn't really matter

[78:16]

where I drop it, so long as it's

[78:17]

somewhere in the middle here. I'm going

[78:18]

to go ahead and let go. Now, I want the

[78:21]

look of the cat to change. I want to see

[78:22]

like a cartoon speech bubble come out

[78:24]

for now. So, I'm going to go under looks

[78:27]

here, and there's a bunch of different

[78:28]

ways to say things and think things. I'm

[78:30]

going to keep it simple and just drag

[78:32]

this one here. And now notice when I get

[78:34]

close enough to that first puzzle piece,

[78:36]

they're sort of magnetic and they want

[78:38]

to snap together. So I can just let go

[78:40]

and boom, because they're a similar

[78:41]

shape, they will lock together

[78:43]

automatically. And notice too, if I zoom

[78:45]

in here, the white oval, which by

[78:48]

default says hello, is actually editable

[78:50]

by me because it turns out that some

[78:52]

functions can take arguments or more

[78:56]

generally inputs that influence their

[78:57]

behavior. So, if I kind of click or

[78:59]

double click on this, I can change it to

[79:00]

the more canonical hello world or hello

[79:03]

David or hello whatever I want the

[79:05]

message to be. I'm going to go ahead and

[79:07]

zoom out. And now over here at top

[79:09]

right, notice that I can very simply

[79:10]

click the green flag. And I'll have

[79:13]

written my first program in Scratch. I

[79:16]

clicked the green flag, it said go. And

[79:18]

now notice it's sort of stuck on that

[79:20]

because I never said stop saying go. But

[79:22]

that's where I can click the red stop

[79:24]

sign and sort of get the cat back to

[79:26]

where I want it. So think about for just

[79:28]

a moment what it is we just did. So at

[79:30]

the one hand we have a very obvious

[79:32]

puzzle piece that says say and it said

[79:34]

something but it really is a function

[79:36]

and that function does take an input

[79:38]

represented by the white oval here

[79:40]

otherwise known as an argument or a

[79:42]

parameter. But what this really is is

[79:44]

just an input to the function. And so we

[79:47]

can map even this simple simple scratch

[79:49]

program onto our model of problem

[79:52]

solving before with an addition of what

[79:54]

we'll call moving forward a side effect.

[79:56]

A side effect in a computer program is

[79:58]

often something that happens visually on

[80:01]

the screen or maybe audibly out of a

[80:03]

speaker. It's something that just kind

[80:04]

of happens as a result of you using a

[80:07]

function like a speech bubble appearing

[80:08]

on the screen. So here more generally is

[80:11]

what we claimed it represents the

[80:13]

solving of a problem. And let's just

[80:14]

consider what the input is. The input to

[80:17]

this problem say something on the screen

[80:19]

is this white oval here that I typed in

[80:21]

hello world. The algorithm, the

[80:24]

step-by-step instructions are not

[80:26]

something really I wrote like our

[80:27]

friends at MIT implemented that purple

[80:30]

say block. So someone there knows how to

[80:33]

get the cat to say something out of its

[80:35]

uh comical mouth. So the algorithm

[80:37]

implemented in code is really equivalent

[80:39]

to the say function. So a function is

[80:42]

just a piece of functionality

[80:44]

implemented in code which in turn

[80:46]

implements an algorithm. So algorithm is

[80:48]

sort of the concept and the function is

[80:50]

actually the incarnation of it in code.

[80:52]

What's the output? Well, hopefully it's

[80:54]

this side effect seeing the speech

[80:56]

bubble come out of the cat's mouth like

[80:59]

this. All right, so that's one such

[81:02]

program, but it's always going to play

[81:04]

and look the same. What if I actually

[81:06]

want to prompt the human for their

[81:08]

actual name? Well, let me go back to the

[81:10]

puzzle pieces here. Let me go ahead and

[81:12]

throw this whole thing away. Okay. And

[81:14]

if you want to delete blocks, you can

[81:15]

either rightclick or control-click and

[81:16]

choose from a menu. Or you can just drag

[81:18]

them there and sort of let go and

[81:20]

they'll disappear. I'm going to go back

[81:21]

in and get another uh another event

[81:24]

block, even though I could have reused

[81:25]

that same one. I'm going to go ahead and

[81:28]

go under sensing now. And if I zoom in

[81:30]

over here, you'll see a whole bunch of

[81:32]

things like I can sense distance and

[81:33]

colors. But more pragmatically, I can

[81:36]

use this function in blue, ask

[81:38]

something, and then wait for the answer.

[81:41]

And what's different about this puzzle

[81:43]

piece is that it two is yes a function.

[81:45]

It too takes an argument, but instead of

[81:47]

having an immediate side effect like

[81:49]

displaying something on the screen, it's

[81:51]

essentially inside of the computer going

[81:54]

to hand me back the response. It's going

[81:57]

to return a value, so to speak. And a

[82:00]

return value is something that the code

[82:01]

can see, but the human can't. A side

[82:04]

effect is something the human sees, but

[82:05]

a return value is something only the

[82:07]

computer sees. It's like the computer is

[82:08]

handing me back the user's input. So,

[82:11]

how does this work? Well, notice, and

[82:12]

this is a bit strange. This isn't

[82:14]

usually how variables work, but Scratch

[82:16]

2 supports variables, and that was a

[82:18]

word I used quickly at the very start

[82:20]

when we were making the chatbot. A

[82:22]

variable like in math, X, Y, or Z, just

[82:24]

store some value, but it doesn't have to

[82:25]

store a number. In code, it can store

[82:27]

like a human name. So, what's going to

[82:29]

happen when I use this puzzle piece is

[82:31]

that once the human types in their name

[82:33]

and hits enter, MIT, or really Scratch

[82:36]

is going to store the answer, the

[82:38]

so-called return value in a variable

[82:40]

that's designed to be called answer.

[82:42]

But, as we'll see, you can make your own

[82:44]

variables down the line if you want and

[82:46]

call them anything you want. But, let me

[82:48]

go ahead and zoom out. Let me drag this

[82:50]

over here. I'm going to use the default

[82:52]

question, what's your name? But I could

[82:54]

certainly change the text there. And let

[82:56]

me go under looks again. Let me go ahead

[82:59]

and grab the say block and let me go

[83:02]

ahead and say just for consistency like

[83:04]

hello,

[83:06]

okay? And now let me go under maybe

[83:08]

sensing I want to say how do I want to

[83:11]

say this answer. Well, notice this. The

[83:12]

shapes are important. This too is an

[83:14]

oval even though it's not white but

[83:16]

that's just because it's not editable.

[83:17]

It's going to be handed to me by the ask

[83:20]

function. Let me zoom out and grab a

[83:22]

second say block like this. And notice

[83:26]

it will magnetically clip together. I

[83:27]

don't want to say hello again. So, I

[83:29]

could delete that. But now it's still

[83:31]

the same shape even though it's a little

[83:32]

smaller. Let me go back to sensing. And

[83:34]

notice what can happen here. When you

[83:36]

have values like words inside of a

[83:39]

so-called variable, you can use those

[83:41]

instead of manual input at your

[83:43]

keyboard. And notice it too wants to

[83:44]

magnetically snap into place. It'll grow

[83:46]

to fit that variable because the shape

[83:48]

is the same. And now let's do this. Let

[83:50]

me click the green flag at right. I'm

[83:53]

seeing quote unquote what's your name?

[83:54]

I'm getting a text box this time, like

[83:56]

on a web page for instance. Let me type

[83:58]

in my name and watch closely what comes

[84:00]

out of the cat's mouth as soon as I

[84:02]

click the check mark or hit enter.

[84:05]

Huh. Okay, I got my name right, but let

[84:07]

me do it once more. Let me stop and

[84:09]

start. Dav

[84:12]

enter. No, it didn't work. Let me try

[84:15]

one other. Maybe it's my name. Let's try

[84:17]

Kelly. Enter. What's missing? Obviously,

[84:22]

the the hello. There's a bug, a mistake

[84:25]

in this program. But is there like what

[84:27]

explains this? Even if you've never

[84:28]

programmed before, intuitively, what

[84:30]

could explain why I'm not seeing hello?

[84:36]

>> Exactly. It's on two different lines.

[84:37]

So, it's doing one after the other. So,

[84:39]

it is happening. It's just you and I is

[84:40]

the slowest things in the room are just

[84:43]

not seeing it in time because it's

[84:45]

happening so darn fast. Because my

[84:47]

computer is so, you know, so new and so

[84:48]

fast, it's happening, but way too

[84:50]

quickly. So, how can we solve this? So,

[84:52]

we can solve this in a few different

[84:53]

ways. And this is where in Scratch, at

[84:55]

least for problems at zero, when wherein

[84:57]

you'll have an opportunity to play

[84:58]

around with this, I can scroll around

[85:00]

here. And okay, under control, I see

[85:03]

something like weight. So, I can just

[85:04]

kind of slow things down. And now

[85:06]

notice, too, if you hover over the

[85:08]

middle of two blocks, if it's the right

[85:10]

shape, it'll just snap into the middle

[85:11]

two. Or you can, just so you know, kind

[85:14]

of drag things away to magnetically

[85:16]

separate them. But this might solve

[85:17]

this. So, let me hit stop and then

[85:19]

start. DAV. Enter.

[85:22]

Hello, David. All right, that was a

[85:24]

little Let's do like maybe two seconds

[85:26]

to see it again. Green flag. DAV ID.

[85:29]

Enter. Hello,

[85:32]

David. All right, it's working better.

[85:34]

It's sort of more correct because I'm

[85:36]

seeing the hello and the David, but kind

[85:38]

of stupid, right, to see one and then

[85:40]

the other. Wouldn't it be nice to say it

[85:42]

all in one breath, so to speak? Well,

[85:44]

here's where we can maybe compose some

[85:45]

ideas. So, let me get rid of this weight

[85:47]

and the additional block. Let's confine

[85:49]

ourselves to just one say block. But let

[85:52]

me go down to operations where we

[85:54]

haven't been before. And this is

[85:56]

interesting. There's this bigger oval

[85:58]

here that says join two things like

[86:00]

apple and banana. And those are just

[86:01]

random placeholder words that you can

[86:03]

override with anything you want. But

[86:05]

they're both ovals and white, which

[86:06]

means I can edit them. So let me go

[86:08]

ahead and do this. Let me drag this on

[86:10]

top of the say block. And this is just

[86:12]

going to therefore uh override the hello

[86:15]

I put there. Now I don't want to say

[86:17]

apple or banana but I do want to say

[86:18]

hello

[86:20]

and I then want to say my name. Okay. So

[86:22]

now I can go back to sensing go back to

[86:25]

answer drag and drop this here. That'll

[86:28]

snap into place. And let me zoom in. Now

[86:31]

what I've done is take a function and on

[86:32]

top of it I've nested another function

[86:35]

the join function that takes two

[86:36]

arguments or inputs and presumably joins

[86:40]

them together as per its name. So let's

[86:42]

see what this does for us. Let me click

[86:44]

stop and start. I'll type in David

[86:47]

enter. And it's so close. Now, this is

[86:49]

just kind of an aesthetic bug. What have

[86:51]

I done wrong here?

[86:53]

There's no space. So, it looks a little

[86:55]

wrong, but that's an easy fix. I just

[86:57]

need to literally go into the hello

[86:59]

block after the comma, hit the space

[87:01]

bar, so that now when I stop and start

[87:03]

again and type in David, now I see

[87:05]

something that's closer to the grammar

[87:07]

we might typically expect syntactically

[87:09]

here. All right. So, let's model this

[87:11]

after what we just saw earlier. We've

[87:14]

now introduced a so-called return value.

[87:16]

And this return value is something we

[87:18]

can then use in the way we want. It's

[87:20]

not happening immediately like the

[87:22]

speech bubble. It's clearly being passed

[87:24]

to me in some way that I can use to plug

[87:26]

in somewhere else like into that join

[87:28]

block. So if we consider the role of

[87:30]

these variables playing, let's consider

[87:32]

the picture now as follows. If the input

[87:34]

now to the first function, the ask block

[87:37]

is what's your name? Quote unquote,

[87:39]

that's indeed being fed into the ask

[87:40]

block. And the result this time is not a

[87:42]

speech bubble. It's not some immediate

[87:44]

visual side effect. It is the answer

[87:47]

itself stored in a so-called variable as

[87:50]

represented by this blue oval.

[87:52]

Meanwhile, what I want to do is combine

[87:56]

that answer with some text I came up

[87:58]

with in advance by kind of stacking

[88:00]

these things together. Now, visually in

[88:01]

Scratch, you're stacking them on top,

[88:03]

but it's really that you're passing one

[88:05]

into the other into the other because

[88:07]

much like math when you have the

[88:08]

parenthesis and you're supposed to do

[88:10]

what's inside the parenthesis and then

[88:11]

work your way out. Same idea here. You

[88:13]

want to join hello and answer together.

[88:15]

And whatever that output is, that then

[88:18]

becomes the input to the say block,

[88:20]

which like in math is outside of the

[88:22]

join block itself. So pictorially, it

[88:24]

might now look like this. There's two

[88:26]

inputs to this story. Hello, comma,

[88:29]

space, and the answer variable. The

[88:31]

puzzle piece in question is join. Its

[88:33]

goal in life had better be to give me

[88:36]

the full phrase that I want. Hello,

[88:38]

David. Let's shift everything over now

[88:40]

because that output is about to become

[88:42]

the input to the say block which itself

[88:45]

will now have the so-called side effect.

[88:48]

And so this too is what programming and

[88:50]

in turn what computer science is about

[88:52]

is composing with the solutions to

[88:55]

smaller problems solutions to bigger

[88:57]

problems using those component pieces.

[88:59]

And that's what each of these puzzle

[89:00]

pieces represents is a smaller problem

[89:03]

that someone else or maybe even you has

[89:06]

already solved. Now, we can kind of

[89:07]

spice things up here. If I go back to

[89:09]

Scratch's interface, we don't have to

[89:11]

use just the puzzle piece here. I can do

[89:12]

something like this. Let me go ahead and

[89:14]

drag these apart and get rid of the say

[89:16]

block down here. Just for fun, there's

[89:18]

all these extensions that you can add

[89:19]

over the internet to your own Scratch

[89:21]

environment. And if I go to like text to

[89:23]

speech down here, I can, for instance,

[89:26]

do uh a speak block instead of a say

[89:28]

block colored here in green. I can now

[89:31]

reconnect the join block in here. And if

[89:33]

we could raise the volume just a little

[89:35]

bit. Let me stop the old version, start

[89:37]

the new version, type in my name, and

[89:39]

hear what Scratch actually sounds like.

[89:42]

>> Hello, David.

[89:44]

>> Okay, not very cat-like, but we can kind

[89:46]

of waste some time on this by like

[89:47]

dragging the set voice to box. And I can

[89:50]

put this anywhere I want above the speak

[89:53]

block. So, I'm just going to put it

[89:55]

here, even though I've already asked a

[89:56]

question. Maybe kitten sounds

[89:57]

appropriate. Let's try again. D-av

[90:01]

>> meow meow.

[90:03]

>> Okay. And then let's see. Uh, giant

[90:07]

little creepier. Here we go. DAV. And

[90:09]

lastly,

[90:11]

>> hello David.

[90:12]

>> All right. Little ransomlike instead.

[90:14]

All right. So, that's just some

[90:16]

additional puzzle pieces, but really

[90:17]

just the same idea, but I like that

[90:18]

we've introduced some sound. So, let's

[90:20]

do this. Let me go ahead and throw away

[90:21]

a lot of those puzzle pieces, leave

[90:23]

ourselves with just the when green flag

[90:25]

clicked, and play around with some other

[90:27]

building blocks that we've seen already

[90:29]

thus far. Let me go ahead for instance

[90:30]

under sound and let's make the cow

[90:33]

actually meow. So it turns out Scratch

[90:34]

being a cat by default comes with some

[90:36]

sounds by default like meowing. So if we

[90:39]

go ahead and click the green flag after

[90:41]

programming this program. Let's hear

[90:43]

what he sounds like now.

[90:46]

Okay, kind of cute. And if you want it

[90:48]

scratch to meow twice, you can just play

[90:50]

the game again

[90:52]

and a third time. All right, but that's

[90:55]

going to get a little tedious as cute as

[90:56]

it is. So I can solve that. Let's just

[90:58]

grab three of the puzzle pieces and just

[91:00]

drag them together and let them connect.

[91:02]

And now click the green flag.

[91:06]

All right. Doesn't it gets less cute

[91:07]

quickly, but maybe we can slow it down

[91:09]

so that the cat doesn't sound so so

[91:11]

hungry. Maybe let me go under uh let's

[91:14]

see under control. Let's grab one of

[91:16]

those. Wait one second and maybe plop a

[91:18]

couple of these in the middle here. That

[91:20]

might help things. And now click the

[91:21]

green flag.

[91:25]

Okay, still a little hungry. But let's

[91:27]

see if we change it to two. And then I

[91:29]

change it to two down here in both

[91:30]

places. Let's play it again.

[91:35]

Okay, cuter maybe. But now I'm venturing

[91:39]

into badly programmed territory. This is

[91:41]

correct. If my goal is to get the cat to

[91:43]

meow three times, pausing in between,

[91:46]

sorry, three times pausing in between.

[91:48]

What is bad about this code? Even if

[91:51]

you've never programmed before though.

[91:54]

Yeah. In the middle.

[91:56]

>> Yeah. I literally had to repeat myself

[91:58]

three times. Essentially copy pasting.

[92:00]

And frankly, I could have been really

[92:01]

lazy and I could rightclick or

[92:02]

control-click and I could have chosen

[92:04]

duplicate. But generally when you copy

[92:07]

paste code or when you duplicate puzzle

[92:09]

pieces probably doing something wrong.

[92:12]

Why? It's solving the problem correctly.

[92:14]

But it's not well designed even if for

[92:16]

only because when I changed the number

[92:18]

of seconds now I had to change it in two

[92:20]

places. So, I had one initially, then I

[92:22]

had to change it to two. And if you just

[92:24]

imagine in your mind's eye having not

[92:26]

like six puzzle pieces, but 60 or 600 or

[92:30]

6,000, you're going to screw up

[92:31]

eventually if it's on you to remember to

[92:33]

change something here and here and here

[92:34]

and here. Like, you're going to mess up.

[92:37]

It's better to keep things simple and

[92:39]

ideally centralized by factoring out

[92:41]

common functionality. And clearly,

[92:43]

playing sound and waiting is something

[92:45]

I'm doing at least twice, if not a third

[92:47]

time here as well. So, how can we do

[92:49]

this better? Well, remember this thing,

[92:52]

loops. Maybe we can just do something a

[92:54]

little more cycllically. So, I tell the

[92:55]

computer to do something once, but I

[92:57]

tell it how many times to do that al

[92:59]

together. So, notice here by coincidence

[93:01]

under control, I have a repeat block,

[93:04]

which doesn't say loop, but that's

[93:05]

certainly the right semantics. Let me go

[93:07]

ahead and drag the repeat block in, and

[93:09]

I'll change the 10 to three just for

[93:10]

consistency here. I'm going to go back

[93:12]

to sound. I'm going to go ahead and play

[93:14]

sound meow until done, just as before.

[93:17]

And just so it's not meowing too fast

[93:19]

under control, I'm going to grab a

[93:21]

weight one second and keep it inside the

[93:23]

loop. And notice that the loop here is

[93:25]

sort of hugging these puzzle pieces by

[93:27]

growing to fill however many pieces I

[93:30]

actually cram in there. So now if I

[93:32]

click play, the effect is going to be

[93:34]

the same, but it's arguably not only

[93:35]

correct, but also well

[93:38]

designed because now if I want to change

[93:41]

the weight, change it in one place. If I

[93:44]

want to change the total number of

[93:45]

times, change it in one place. So I've

[93:47]

modularized the code and made it better

[93:50]

designed in this case. But now this is

[93:52]

silly because even though I want the cat

[93:56]

to meow, it feels like any program in

[93:58]

which I want this cat to meow, I have to

[93:59]

make these same puzzle pieces and

[94:01]

connect them together. Wouldn't it be

[94:02]

nice to invent the notion of meowing

[94:05]

once and then actually have a puzzle

[94:06]

piece called meow? So when I want the

[94:08]

cat to meow, it will just meow. Well, I

[94:11]

can do that, too. Let me scroll down to

[94:13]

my blocks here in pink. I'm going to

[94:15]

click make a block and I'm going to

[94:17]

literally make a new puzzle piece that

[94:18]

MIT didn't think of called meow. And I'm

[94:21]

going to go ahead and click okay. Now I

[94:24]

have in my code area here a define block

[94:28]

which literally means define meow as

[94:31]

follows. So how am I going to do this?

[94:33]

Well, I'm going to propose that meowing

[94:35]

just means to play the sound meow until

[94:38]

done and then wait 1 second. And notice

[94:40]

now I have nothing inside my actual

[94:43]

program which begins when I click the

[94:45]

green flag. But notice at top left

[94:47]

because I made a block called meow, I

[94:50]

now have access to one that I can drag

[94:52]

and drop. So now I can drag me into this

[94:56]

loop. And per my comment about

[94:59]

abstracting the lower level

[95:01]

implementation details away, I'm going

[95:02]

to sort of unnecessarily dramatically

[95:04]

just move that out of the way. It still

[95:06]

exists. I didn't delete it, but now out

[95:08]

of sight, out of mind. Now, if you agree

[95:11]

with me that meow means for the cat to

[95:12]

make a sound, we've abstracted away what

[95:14]

it means mechanically for the cow to say

[95:17]

that sound. And so, we now have our own

[95:20]

puzzle piece that I can just now use

[95:21]

forever because I invented the meow

[95:23]

block already. Now, I can do one better

[95:25]

than this. It would be nice if I could

[95:27]

just tell the meow block how many times

[95:28]

I want it to meow because then I don't

[95:29]

need to waste time using loops either

[95:32]

myself. So, let me do this. Let me zoom

[95:34]

out and let me go back to my define

[95:38]

block. Let me rightclick or

[95:39]

control-click and just edit it. Or I

[95:41]

could delete it and start over. But I'll

[95:42]

just edit it. And specifically, let me

[95:44]

say, you know what, let's add an input,

[95:46]

otherwise known as an argument, to this

[95:48]

meow block. And we'll call it maybe n

[95:50]

for the number of times I want it to

[95:52]

meow. And just to be super clear, I'm

[95:54]

going to add a label, which has no

[95:56]

functional impact, but it just helps me

[95:57]

remember what this does. So I'm going to

[95:59]

say meow end time, so that when I see

[96:01]

the puzzle piece, I know what the N

[96:02]

actually represents. If I now click

[96:05]

okay, my puzzle piece looks a little

[96:07]

different at top left. Now it has the

[96:09]

white oval into which I can type or drag

[96:11]

input. Notice down here in the define

[96:13]

block, I now see that same input called

[96:16]

N. So what I can do now is this. Let me

[96:19]

go under control. Glag drag the repeat

[96:22]

block here. And I have to do a little

[96:24]

switcheroo. Let me disconnect this. Plug

[96:26]

it inside of the repeat block. Reconnect

[96:29]

all of this. And I don't want 10. And

[96:31]

heck, I don't even want three down here

[96:33]

anymore. I can drag this input because

[96:35]

it's the right shape and now declare

[96:38]

that meowing n times means to repeat the

[96:41]

following n times. Play sound meow until

[96:43]

done. Wait one second and keep doing

[96:46]

that n total times. If I now zoom out

[96:49]

and scroll up, notice that my usage of

[96:52]

this puzzle piece has changed such that

[96:54]

I don't actually need the repeat block

[96:56]

anymore. I can disconnect this. And

[96:58]

heck, I can actually rightclick and uh

[97:01]

control-click and delete it. just use

[97:03]

this under the green flag. Change this

[97:05]

to a three. And now I have the essence

[97:08]

of this meowing program. The

[97:10]

implementation details are out of sight,

[97:12]

out of mind. Once they're correct, I

[97:14]

don't need to worry about them again.

[97:15]

And this is exactly how Scratch itself

[97:17]

works. I have no idea how MIT

[97:19]

implemented the weight block or the

[97:21]

repeat block. Heck, there's a forever

[97:23]

block and there's a few others, but I

[97:25]

don't need to know or care because

[97:27]

they've implemented those building

[97:29]

blocks that I can then implement myself.

[97:31]

I don't necessarily know how to build a

[97:32]

whole chatbot, but on top of OpenAI's

[97:35]

API, this web-based service, I can

[97:38]

implement my own chatbot because they've

[97:40]

done the heavy lift of actually

[97:42]

implementing that for me. Well, let's do

[97:44]

just a few more examples here. Let's

[97:45]

bring the cat all the more to life. Let

[97:47]

me throw away the meowing. Let me open

[97:49]

up under when green flag clicked. How

[97:51]

about that forever block that we just

[97:53]

glimpsed? Let me go ahead and now add to

[97:55]

the mix what we called earlier

[97:57]

conditionals which allow us to ask

[97:59]

questions and decide whether or not we

[98:01]

should do something. So under this, let

[98:03]

me go ahead and under forever say if the

[98:06]

following is true. Well, what boolean

[98:11]

expression do I want to ask? Well, let's

[98:13]

implement how about this program and

[98:14]

we'll figure out if it works. Uh under

[98:16]

sensing, I'm going to grab this uh very

[98:19]

angled puzzle piece called touching

[98:21]

mouse pointer. that is the cursor and

[98:24]

only if that question has a yes answer

[98:26]

do I want to play the sound meow until

[98:29]

done. So let me zoom in here and in

[98:32]

English

[98:33]

what is this going to implement really

[98:38]

just describe what this program does

[98:40]

less arcanely as the code itself.

[98:41]

Yeahouse

[98:47]

>> yeah if you move the mouse over the cat

[98:49]

it will make noise. So, it's kind of

[98:50]

like implementing petting a cat, if you

[98:53]

will. So, let me zoom out, click the

[98:55]

green flag, and notice nothing's

[98:56]

happening yet. But notice my puzzle

[98:59]

pieces are highlighted in yellow because

[99:00]

it is in fact still running because it's

[99:02]

doing something forever. And it's

[99:04]

constantly checking if I'm touching the

[99:06]

mouse pointer. And if so,

[99:09]

it's like I just pet the cat. Now, it

[99:11]

stopped until I move the cursor again.

[99:14]

Now, it stopped. If I leave it there,

[99:16]

it's going to keep meowing because it's

[99:18]

going to be stuck in this loop forever.

[99:20]

But it's correct in so far as I'm

[99:22]

petting the cat. Let me do this though.

[99:24]

Let me make a mistake this time. Let me

[99:26]

forget about the forever and just do

[99:28]

this. And you might think this is

[99:30]

correct. Let me click the green flag

[99:32]

now. Let me pet the cat. And like

[99:35]

nothing's actually working here. Why

[99:37]

though logically?

[99:39]

Yeah.

[99:41]

>> Yeah. The program's so darn fast. It

[99:42]

already ran through the sequence. And at

[99:44]

the moment in time when I clicked the

[99:45]

rear flag, no, I was not touching the

[99:48]

mouse pointer. And so it was too late by

[99:50]

the time I actually moved the cursor

[99:51]

there. But by using the forever block,

[99:53]

which I did correctly the first time,

[99:55]

this ensures that Scratch is constantly

[99:58]

checking the answer to that question. So

[100:00]

if and when I do pet the cat, it will

[100:03]

actually

[100:04]

detect as much. All right, about a few

[100:08]

final examples before you're on your way

[100:09]

building some of your own first programs

[100:11]

with these building blocks. Let me go

[100:13]

ahead and open up a program that I wrote

[100:14]

in advance in fact about 20 years ago

[100:17]

whereby let me pull this up whereby we

[100:21]

have in this example a program I wrote

[100:24]

called Oscar time and this was the

[100:26]

result of our first assignment in this

[100:27]

class whereby when MIT was implementing

[100:30]

Scratch for the very first time we

[100:32]

needed to implement our very own Scratch

[100:34]

program as well. I'm going to go ahead

[100:36]

and full screen it here. The goal is to

[100:37]

drag as much falling trash as you can to

[100:39]

Oscar's trash can before his song ends.

[100:42]

For which one volunteer would be handy

[100:45]

here. Okay. I saw your hand go up

[100:46]

quickly in blue. Yeah. Come on up. All

[100:48]

right. So, you're playing for a stress

[100:50]

ball here if we will. At one at some

[100:52]

point, I'm going to talk over what

[100:54]

you're actually playing just so that we

[100:55]

can point out what it is we're trying to

[100:57]

glean from this program. And I'll

[100:58]

stipulate this probably took me like 8

[101:00]

12 hours. And as you'll soon see, the

[101:02]

song starts to drive you nuts after a

[101:04]

while because I was trying to

[101:05]

synchronize everything in the game to a

[101:07]

childhood song with which you might be

[101:08]

familiar. Let me go ahead and say hello

[101:10]

if you'd like to introduce yourself.

[101:12]

>> Oh. Um, hello. So, I'm Han and, uh, I'm

[101:15]

a first year student. I'm pretty excited

[101:17]

for this class.

[101:18]

>> All right. Welcome. Well, here is Oscar

[101:20]

time. If you want to go ahead and take

[101:21]

control of the keyboard, all you'll need

[101:23]

to do is drag and drop trash that falls

[101:26]

from the sky into the trash can.

[101:32]

Oh, I love trash.

[101:36]

Anything dirty or dingy.

[101:38]

>> Very nice. Your score is one.

[101:40]

>> Anything racket or rotten or rusty.

[101:44]

Score is two. I love trash.

[101:47]

>> All right.

[101:50]

Look at this. Let's see what happens.

[101:52]

>> You'll see a sneaker was perfectly

[101:54]

timed. Thank you very much with the song

[101:55]

after figuring out exactly how many

[101:57]

seconds it had to wait. Now Han can drag

[101:59]

not only the piece of trash,

[102:01]

>> but the shoe as well.

[102:06]

>> And it's around this point in the game

[102:07]

where the novelty starts to wear off

[102:08]

because it's like three more minutes of

[102:10]

this game where more and more stuff

[102:11]

starts to fall from the sky. So as Han,

[102:13]

as you continue to play, I'm going to

[102:14]

cut over here. You keep playing. Let's

[102:16]

consider how I implemented this whereby

[102:20]

we'll start at the beginning. The very

[102:21]

first thing I did when implementing

[102:22]

Oscar time honestly was the easy part.

[102:24]

Like I found a lamp post that looked a

[102:26]

little something like this and I made

[102:28]

the so-called costume for the whole

[102:30]

stage and that was it. The game didn't

[102:32]

do anything. You couldn't play anything.

[102:33]

You click the green flag, nothing

[102:34]

happened. But then I figured out how to

[102:37]

turn the scratch cat, otherwise known

[102:39]

more generally as a sprite, into a trash

[102:42]

can instead. And so the trash can,

[102:44]

meanwhile, is clearly animated because I

[102:47]

realized that, oh, I can give sprites

[102:49]

like the cat different costumes. So, I

[102:51]

can make the cat not only look like a

[102:53]

trash can, but if I want its lid to go

[102:55]

up, well, that's just another costume.

[102:57]

And if I want to see Oscar popping out,

[102:59]

that's just a third costume. And so, I

[103:01]

made my own simplistic animation. And

[103:04]

you can kind of see it. It's very

[103:05]

jittery step step by step by step by

[103:08]

creating the illusion of animation by

[103:09]

really just having a few different

[103:10]

images or costumes on Oscar. Now, I hope

[103:13]

you appreciate how much effort went

[103:14]

involved into timing each of these

[103:16]

pieces of trash with the specific

[103:17]

mention of that type of piece of trash

[103:19]

in the music. Okay. 20 years later,

[103:21]

still clinging. So, you're doing

[103:23]

amazing, by the way. How do we get the

[103:25]

trash to fall in the first place? Well,

[103:26]

at the very beginning of the game, the

[103:28]

trash just started falling from some

[103:29]

random location. What does it mean for

[103:31]

trash to fall from the sky?

[103:33]

>> Oh, big climax here.

[103:38]

>> There you go. Trash on the ground. You

[103:39]

can pick up.

[103:41]

[Applause]

[103:42]

[Music]

[103:43]

There we go. And your final score is

[103:48]

a big round of applause if we could for

[103:54]

Thank you. So just to be clear now,

[103:57]

let's decompose this fairly involved

[103:59]

program that took me a lot of hours to

[104:01]

make into its component parts. So this

[104:03]

is just a sprite. And I figured out

[104:05]

eventually how to change its costume,

[104:06]

change its costume, change its costume

[104:08]

to simulate some kind of animation. And

[104:10]

I also realized that, oh, I don't need

[104:12]

to just have one sprite or one cat or

[104:13]

trash can. You can create a second

[104:15]

sprite, a third sprite, and many more.

[104:17]

So, I just told the sprite to go to a

[104:19]

random location at Y equals 180 and X

[104:23]

equals something. I think I restricted X

[104:25]

to be in this region, which is why the

[104:26]

trash never falls from over here. I just

[104:28]

did a little bit of math based on that

[104:29]

cartisian plane that we saw a slide of

[104:31]

earlier. And then I probably had a loop

[104:34]

that told the trash to move a pixel,

[104:35]

move a pixel, move a pixel down, down,

[104:38]

down, down until it eventually hits the

[104:39]

bottom and therefore just stops. So we

[104:41]

can actually see this step by step. And

[104:43]

this is representative of how even for

[104:45]

something like your first problem said

[104:47]

in CS50 and with Scratch specifically,

[104:49]

you might build some of the same. So,

[104:52]

I'm going to go back into uh CS50 Studio

[104:55]

for today, which is linked on the

[104:56]

courses website, which has a few

[104:58]

different versions of this and other

[105:00]

programs called Oscar 0ero through Oscar

[105:02]

4, where zero is the simplest. And

[105:04]

truly, I meant it when I look inside

[105:06]

this program to see my code. Like, this

[105:08]

was it. There was no code because all I

[105:11]

did was put the sprite on the screen and

[105:13]

change it from a cat to a trash can. And

[105:14]

I added a cost uh a costume for the

[105:17]

stage, so to speak, so that the lamp

[105:19]

post would be fixated there. If I then

[105:21]

go to the next version of code, version

[105:23]

one, so to speak, then I had code that

[105:25]

did this. Now, notice there's a few

[105:28]

things going on here. At bottom left,

[105:30]

you'll see of course the trash can and

[105:32]

then at top right the trash. Here are

[105:34]

the corresponding sprites down here. So,

[105:36]

when Oscar is clicked on here, the trash

[105:38]

can, you see the code I wrote, the

[105:40]

puzzle pieces I dragged for Oscar. And

[105:42]

in a moment, when we click on trash,

[105:44]

you'll see the code I wrote or the

[105:46]

puzzle pieces I wrote dragged and

[105:47]

dropped for the trash piece

[105:49]

specifically. So, what does Oscar do?

[105:52]

Well, I first switch his costume to

[105:54]

Oscar 1, which I assume is this, the

[105:56]

closed trash can. Then, forever Oscar

[105:59]

does the following. If Oscar's touching

[106:01]

the mouse pointer, then change the

[106:04]

costume to Oscar 2. Otherwise, that is

[106:07]

if not touching the mouse pointer,

[106:09]

change the costume to Oscar 1. Well,

[106:10]

what's the implication? Anytime I move

[106:13]

the cursor over the trash can, the lid

[106:15]

just pops up, which was exactly the

[106:16]

animation I wanted to achieve.

[106:19]

Meanwhile, if we do this and click the

[106:21]

green flag, you can see that in action,

[106:23]

even for this simple version. If I move

[106:25]

the cursor over Oscar, we have the

[106:28]

beginnings of a game, even though

[106:29]

there's no score, there's no music or

[106:31]

anything else, but I've solved one of my

[106:33]

problems. Meanwhile, if I click on the

[106:35]

trash piece here, and then you'll see no

[106:37]

code has been written for it yet. So, we

[106:40]

move on to Oscar version two and see

[106:42]

inside it. And Oscar version two, when I

[106:44]

click on trash, ah, now there's some

[106:46]

juicy stuff happening here. And in fact,

[106:49]

this trash sprite has two programs or

[106:52]

scripts associated with it. And that's

[106:53]

fine. Each of them starts with when

[106:55]

green flag clicked, which means the

[106:56]

piece of trash will do two things at

[106:59]

once essentially in parallel. The first

[107:01]

thing it will do is we'll set drag mode

[107:02]

to dragable. And that's just a scratch

[107:04]

thing that lets you actually move the

[107:05]

sprites by clicking on them, making them

[107:07]

dragable. Then it goes to a random X

[107:09]

location between 0 and 240. So yeah,

[107:12]

that must be what I did from the middle

[107:14]

all the way to the right. And I set Y

[107:16]

always to 180, which is why the trash

[107:18]

always comes from the sky from the very

[107:20]

top. Then I said forever change your Y

[107:23]

by -1. And here's where it's useful to

[107:25]

know what 180 is, 240 is, and so forth.

[107:27]

Because if I want the trash to go down,

[107:29]

so to speak, that's changing its Y by a

[107:32]

pixel by a pixel by a pixel. And

[107:34]

thankfully MIT implemented it such that

[107:36]

if the trash tries to go off the screen,

[107:39]

it will just stop automatically, even if

[107:41]

it's inside of a forever block, lest you

[107:42]

lose control over the sprites

[107:44]

altogether. But in parallel, what's

[107:46]

happening is this. Also, when the green

[107:48]

flag is clicked, uh the trash piece is

[107:50]

doing this too forever. If touching

[107:53]

Oscar, what's it doing in blue here?

[107:58]

Sort of teleporting away. Now, to your

[108:01]

eye, hopefully it looks like it's going

[108:03]

into the trash can. But what does that

[108:05]

mean to go into the trash can? Well, I

[108:06]

just put it back into the sky as though

[108:08]

a new piece of trash is falling. So even

[108:10]

though you saw one piece of trash, 2,

[108:13]

three, four, and so forth, it's the same

[108:15]

sprite just acting that out again and

[108:17]

again. So here, if I click play on this

[108:20]

program, you'll see that it starts

[108:22]

falling one pixel at a time. Because

[108:25]

it's draggable, I can sort of pull it

[108:27]

away and move it over to the trash can

[108:29]

like that. And as soon as I do, it seems

[108:31]

to go in, but really it just teleported

[108:34]

to a different X location still at Y=

[108:37]

180. Again, it's not much of a game yet.

[108:38]

There's no score. There's no music or

[108:40]

anything, but let's go to Oscar 3 now.

[108:42]

And in Oscar 3, if we scroll over to the

[108:45]

trash, even more is happening here. In

[108:48]

so far as I realized, you know what?

[108:49]

There was kind of a inefficiency before.

[108:52]

Previously, I had these two programs or

[108:55]

scripts synonym whereby they both went

[108:57]

to the top by going to 0 to 240 for X

[109:01]

and then 180 for Y. And if you noticed,

[109:04]

I used that here and I used that down

[109:06]

here in both programs. Now that too is

[109:08]

kind of stupid because I literally

[109:09]

copied and pasted the same code. So if I

[109:11]

ever want to change that design I have

[109:13]

to change it in two places and I already

[109:14]

proposed that we frown upon that. So

[109:16]

what did I do in this version? I just

[109:18]

created my own block and I decided to

[109:20]

call my own function go to top. What

[109:22]

does it mean to go to the top? Pick a

[109:24]

random x between those values and fixate

[109:27]

on y= 180 initially. Now in both of

[109:31]

those programs which are otherwise

[109:32]

identical I just say what I mean. Go to

[109:34]

top. Go to top. And if I really wanted

[109:36]

to, I could drag this out of the way and

[109:38]

never think about it again because now

[109:39]

that functionality exists. So correct,

[109:42]

but arguably better designed. I've now

[109:45]

factored out commonality so as to use

[109:47]

and reuse my code as well. So let's go

[109:50]

up to Oscar version 4 now. And in Oscar

[109:53]

time version 4, the trash can does a

[109:56]

little something more whereby what have

[109:59]

I added to this mix even though we

[110:01]

haven't dragged this puzzle piece

[110:02]

together before?

[110:05]

Yeah. Yeah. What's new?

[110:07]

>> Yeah. So, it turns out on the left here,

[110:09]

there's a variables category, which is

[110:11]

goes beyond the answer variable that we

[110:13]

just automatically get from the ask

[110:15]

block. You can create your own variables

[110:17]

X, Y, Z. But in computer, in

[110:20]

programming, it's best to name things

[110:21]

not silly simple words like X, Y, and Z,

[110:23]

but full-fledged words that say what

[110:25]

they are, like score. So, I'm setting a

[110:27]

score variable to zero. And then any

[110:30]

time the trash is touching Oscar before

[110:32]

it teleports away to the top, I change

[110:34]

the score by one. That is increment the

[110:37]

score by one. And what Scratch does

[110:38]

automatically for me is it puts a little

[110:40]

billboard up here showing me the current

[110:43]

score. So if I now play this game once

[110:47]

more, the score is going to start at

[110:48]

zero. But if I drag this trash over here

[110:51]

and even let it fall in, as soon as it

[110:53]

touches, the score goes to one. And now

[110:55]

if I click and drag again, the score is

[110:57]

going to as soon as it touches Oscar

[110:59]

going to go to two and so forth. And you

[111:01]

saw in the final flour with Han playing

[111:03]

that once you had the sound and other

[111:05]

pieces of trash, which are just really

[111:07]

other sprites and I just had wait like a

[111:09]

minute, wait two minutes so that the

[111:11]

trumpet would fall at the right time.

[111:13]

I've broken down a fairly involved

[111:15]

program into these basic building

[111:17]

blocks. And when you too write your own

[111:19]

program, that's exactly how you should

[111:20]

approach it. Even if you have these

[111:22]

grand aspirations to do this or that,

[111:24]

start by the simple problems and figure

[111:26]

out what bites can I uh bite off in

[111:29]

order to make progress, baby steps, if

[111:31]

you will, to the final solution. Well,

[111:34]

let's look at one other set of examples

[111:36]

before we have one final volunteer to

[111:37]

come up. And as you'll soon see, it's

[111:39]

tradition in CS50 to end the first class

[111:41]

with cake. So, in a moment, cake will be

[111:43]

served out in the transcept. And please

[111:45]

feel free to come up and say hi and ask

[111:46]

questions if you'd like to. Let me go

[111:48]

ahead and open up though a series of

[111:50]

building blocks here via which we can

[111:52]

make so-called Ivy's hardest game which

[111:54]

is one implemented by one of your

[111:56]

predecessors a former classmate from

[111:59]

CS50. So here we have a whole bunch of

[112:01]

puzzle pieces written by your classmates

[112:03]

but let me go ahead and zoom in on this

[112:04]

screen. You'll see that this harbored

[112:06]

crest is my sprite. So it's not a cat,

[112:08]

it's not a trash can, it's a harbored

[112:10]

crest and it exists in a very simple

[112:12]

two-dimensional world with two walls

[112:14]

next to it. If I click on the green

[112:16]

flag, notice that with my hands here, I

[112:19]

can go up, I can go down, I can go left,

[112:22]

and I can go right. But if I try going

[112:23]

too far right, I get stuck on the wall.

[112:26]

If I go too far left, I get stuck on the

[112:29]

wall. Well, it's the sort of the

[112:30]

beginning of any animation or game. But

[112:32]

how do I do this? Well, let me go up

[112:34]

here and propose that the first thing

[112:36]

the harbored sprite is doing is it's

[112:38]

going to the middle 0 comma 0 and it's

[112:40]

then forever listening for the keyboard

[112:43]

and feeling for walls. Now, those are

[112:46]

functions I implemented myself to kind

[112:48]

of describe what I wanted the program to

[112:50]

do. And let's do the shorter one first.

[112:52]

What does it mean to feel for the walls?

[112:54]

Just to ask the question, if you're

[112:56]

touching the left wall, change your x by

[112:58]

one. If you're touching the right wall,

[113:01]

change your x by negative one.

[113:04]

Why have I defined touching walls in

[113:08]

this weirdly mathematical way? Yeah.

[113:12]

>> Sure. Yeah.

[113:13]

>> And basically like counteracts the

[113:15]

movement. Otherwise, you're like not

[113:19]

>> exactly because if I've gone so far

[113:21]

right that I'm touching the right wall,

[113:23]

well, I'm already kind of on top of the

[113:24]

wall a little bit. So, I effectively

[113:26]

want the sprite to bounce off of it. And

[113:29]

the easiest way to do that is just to

[113:30]

say back up one pixel as though you

[113:31]

can't go any further. And same for the

[113:33]

left wall. Meanwhile, let me scroll over

[113:35]

to the second script or program that's

[113:38]

running in parallel. It's a little

[113:39]

longer, but it's not more complicated.

[113:41]

What does it mean to listen for

[113:42]

keyboard? Well, just check. If the key

[113:45]

up arrow is pressed, change Y by one.

[113:49]

Arrow go up. Else if the key down arrow

[113:51]

is pressed, then change Y by negative 1.

[113:53]

Key right arrow is pressed, change X by

[113:55]

one, and so forth. So again, this is

[113:56]

where the math and the numbers are

[113:58]

useful because it gives you a world in

[113:59]

which to live up, down, left, right

[114:02]

deconstructed into some simple

[114:04]

arithmetic values. All right, so the net

[114:06]

result is that we have a crest living in

[114:09]

this world. Well, let's add a bit of

[114:11]

competition here. And then the second

[114:12]

version of this game, let me go ahead

[114:14]

and full screen it again. Click play.

[114:16]

And now we'll see sort of an enemy

[114:18]

bouncing back and forth autonomously. So

[114:20]

there's no one playing except me. I'm

[114:22]

controlling Harvard. Yale is bouncing on

[114:24]

its own. And nothing bad's going to

[114:26]

happen if it hits me. But it does seem

[114:28]

to be autonomous. So, how is this

[114:30]

working? Well, if it's doing this

[114:31]

forever, there's probably a forever loop

[114:33]

involved. So, let's see inside here.

[114:35]

Let's click not on Harvard, but on the

[114:37]

Yale sprite. And sure enough, if we

[114:40]

focus on this for a moment, we'll see

[114:42]

that the first thing Yale does is go to

[114:43]

0, 0. It points in direction 90°, which

[114:46]

just gives you a sense of whether you're

[114:47]

facing left or right or wherever. And

[114:49]

then it forever does the following. if

[114:51]

it's touching the left wall or touching

[114:53]

the right wall. I was a little clever

[114:55]

this time, if I may. I just kind of turn

[114:57]

around 180 degrees, which effectively

[114:59]

bounces me back in the opposite

[115:01]

direction. Otherwise, I go ahead and no

[115:04]

matter what just move one step, and this

[115:05]

is why Yale is always moving back and

[115:07]

forth. So, a quick question. If I wanted

[115:09]

to speed up Yale and make this beginning

[115:11]

of a game harder, what would I do?

[115:14]

Yeah.

[115:17]

>> Yeah. So, let's have move like 10 steps

[115:19]

at a time, right? This looks like a much

[115:20]

harder game, if you will, like level 10

[115:22]

now because it's just moving so much

[115:24]

faster. All right. Well, let's try a

[115:26]

third version of this that adds another

[115:27]

ingredient. Let me full screen this and

[115:29]

click play. And now you'll see the even

[115:31]

smarter MIT homing in on me by following

[115:36]

my actual movements. So, this is sort of

[115:38]

like boss level material now. And it's

[115:42]

just going to follow me. So, how is this

[115:43]

working? Well, it's kind of a common

[115:45]

game paradigm. But what does this mean?

[115:47]

Well, let's see inside here. Let's click

[115:49]

on MIT sprite. It's pretty darn easy.

[115:52]

Go to some random position just to make

[115:54]

it a little interesting. Let MIT always

[115:56]

start in the center and then forever

[115:58]

point towards the Harvard logo outline,

[116:00]

which is the name the former student

[116:02]

gave to the costume that the sprite is

[116:04]

wearing that looks like a Harvard crest

[116:05]

and then move one step. So coral layer

[116:07]

of the previous question, how do we make

[116:09]

the game harder and MIT even faster?

[116:12]

Well, we can change this to be like 10

[116:14]

steps. And now you'll see MIT is a

[116:17]

little twitchy because

[116:19]

this is kind of a visual bug. Let me

[116:21]

make it full screen.

[116:24]

Why is this visual glitch happening?

[116:27]

It's literally doing what I told it to

[116:29]

do. It just looks stupid. Yeah.

[116:35]

Say again.

[116:37]

>> Yeah. It's moving so fast that it's sort

[116:39]

of going 10 pixels this way, but then I

[116:41]

kind of it kind of overshot me. So then

[116:43]

it's doubling back to follow me again.

[116:44]

and it's doubling back this way. And

[116:46]

because these are such big footsteps, if

[116:48]

you will, it just has this visual effect

[116:49]

of twitching back and forth. So, we

[116:51]

might have to throttle that back a bit

[116:52]

and make it five or two or three instead

[116:54]

of 10 because that's clearly not

[116:56]

desirable gaming behavior here. All

[116:58]

right. Well, let's go ahead and do this.

[117:00]

Let's put them all together just as your

[117:01]

former classmate did when submitting

[117:03]

this actual homework. Uh, the game will

[117:05]

conclude hopefully in an amazing climax

[117:07]

where you've won the game. So, we need

[117:08]

someone ideally with really good hand

[117:10]

eye coordination to play this final game

[117:13]

here. Yeah, your hand went up first, I

[117:15]

think. Okay, come on up. Big round of

[117:16]

applause because this is a lot of

[117:17]

pressure to end.

[117:24]

All right. So, if you win the game, cake

[117:26]

will be served. If you don't win the

[117:29]

game, there will be no cake. Okay. Okay.

[117:31]

But introduce yourself in the meantime.

[117:33]

>> Hi, I'm Jenny Pan, freshman at Hollis

[117:36]

and I'm actually a CS major or

[117:39]

concentration.

[117:40]

>> Nice to meet you. Head to the keyboard

[117:41]

here. This now is the combination of all

[117:44]

of those building blocks and even more

[117:46]

aka Ivy's hardest game. You will be in

[117:48]

control just as I would of the harbored

[117:50]

crest. And the goal is to make it to the

[117:51]

exit which is this gentleman on the

[117:53]

right here. And you'll see there's

[117:54]

multiple levels where it's each level

[117:56]

gets a little harder. All right. Here we

[117:58]

go.

[118:00]

>> Can't touch this.

[118:03]

>> Can't touch this.

[118:05]

[Music]

[118:06]

>> Very good.

[118:07]

>> Can't touch this.

[118:09]

>> Nicely done. Can't touch this.

[118:11]

>> So, the loop has been added for Yale.

[118:17]

>> Good. Two YLes now.

[118:21]

[Music]

[118:25]

>> All right. Three YLes now.

[118:28]

[Music]

[118:30]

>> Nice.

[118:33]

>> Here comes MIT.

[118:38]

Very

[118:40]

good. Yeah.

[118:43]

>> Two MITs

[118:48]

out of your seat and get like

[118:53]

a little more like that.

[118:56]

[Music]

[118:57]

>> Nice. Yes.

[119:15]

Yes. Now Princeton.

[119:20]

>> Another Princeton.

[119:29]

>> Second to last level.

[119:37]

Can't touch this.

[119:38]

>> Okay.

[119:40]

>> Yes. Last level.

[119:44]

[Applause]

[119:54]

>> Stop time. Go go go go. You can't prove

[119:58]

this. You put me on your hands in the So

[120:02]

close. Keep going. Keep going.

[120:05]

[Music]

[120:10]

>> Yes.

[120:12]

Congratulations.

[120:16]

All right. This is CS50. Cake is now

[120:19]

served.

[120:20]

[Applause]

[120:21]

[Music]

[120:37]

[Music]

Download Subtitles

These subtitles were extracted using the Free YouTube Subtitle Downloader by LunaNotes.

Download more subtitles

Related Videos

Download Subtitles for Harvard CS50 2026 Computer Science Course

Download Subtitles for Harvard CS50 2026 Computer Science Course

Enhance your learning experience with downloadable subtitles for the Harvard CS50 2026 full computer science course. Easily follow along with lectures, improve comprehension, and access the content offline anytime. Perfect for students and enthusiasts aiming to master computer science concepts.

Download Java Full Course Subtitles for Free (2025)

Download Java Full Course Subtitles for Free (2025)

Enhance your learning experience with downloadable subtitles for the Java Full Course 2025. Access accurate captions to follow along easily, improve comprehension, and review key concepts at your own pace.

Download Subtitles for CLAUDE CODE Full Course 2026

Download Subtitles for CLAUDE CODE Full Course 2026

Enhance your learning experience with downloadable subtitles for the CLAUDE CODE FULL COURSE 4 HOURS: Build & Sell (2026). These captions help you follow along easily, improve comprehension, and revisit key concepts anytime. Perfect for learners who want clear, accessible content at their own pace.

Download Subtitles for 2022 ICT Mentorship Episode 2 Video

Download Subtitles for 2022 ICT Mentorship Episode 2 Video

Enhance your understanding of the 2022 ICT Mentorship Episode 2 by downloading accurate subtitles. Subtitles make it easier to follow technical discussions and ensure you don’t miss any important insights. Perfect for learners who prefer reading along or need accessibility support.

Download Subtitles for Adobe Illustrator Beginners FREE Course

Download Subtitles for Adobe Illustrator Beginners FREE Course

Enhance your learning experience with accessible subtitles for the Adobe Illustrator for Beginners FREE Course. Download captions to follow along easily, improve comprehension, and master the software at your own pace.

Most Viewed

ดาวน์โหลดซับไตเติ้ล DMD LAND 3 The Final Land Day 1

ดาวน์โหลดซับไตเติ้ล DMD LAND 3 The Final Land Day 1

ดาวน์โหลดซับไตเติ้ลสำหรับวิดีโอ DMD LAND 3 The Final Land Day 1 เพื่อช่วยให้เข้าใจเนื้อหาได้ง่ายขึ้น และเพิ่มความสะดวกในการติดตามทุกช่วงเวลา เหมาะสำหรับผู้ชมที่ต้องการความชัดเจนและเข้าถึงข้อมูลอย่างครบถ้วน

Descarga Subtítulos para NARCISISMO | 6 DE COPAS - Episodio 63

Descarga Subtítulos para NARCISISMO | 6 DE COPAS - Episodio 63

Accede fácilmente a los subtítulos del episodio 63 de '6 DE COPAS', centrado en el narcisismo. Descargar estos subtítulos te ayudará a entender mejor el contenido y mejorar la experiencia de visualización.

Untertitel für 'Nicos Weg' Deutsch lernen A1 Film herunterladen

Untertitel für 'Nicos Weg' Deutsch lernen A1 Film herunterladen

Laden Sie die Untertitel für den gesamten Film 'Nicos Weg' herunter, um Ihr Deutschlernen auf A1 Niveau zu unterstützen. Untertitel helfen Ihnen, Wortschatz und Aussprache besser zu verstehen und verbessern das Hörverständnis effektiv.

Subtítulos para TIPOS DE APEGO | 6 DE COPAS Episodio 56

Subtítulos para TIPOS DE APEGO | 6 DE COPAS Episodio 56

Descarga los subtítulos para el episodio 56 de la tercera temporada de 6 DE COPAS, centrado en los tipos de apego. Mejora tu comprensión y disfruta del contenido en detalle con nuestros subtítulos precisos y accesibles.

Download Subtitles for Your Favorite Videos Easily

Download Subtitles for Your Favorite Videos Easily

Enhance your video watching experience by downloading accurate subtitles and captions. Enjoy better understanding, accessibility, and language support for all your favorite videos.

Buy us a coffee

If you found these subtitles useful, consider buying us a coffee. It would help us a lot!

Let's Try!

Start Taking Better Notes Today with LunaNotes!