Juan RamírezLearningES
CS50x · Week 0Harvard University9 parts

The first CS50 lecture in nine short parts. Touch everything.

A summary of CS50x Week 0 (Scratch): how computers represent numbers, text, colours and media in binary, what an algorithm is, pseudocode, abstraction and Scratch. Written the way I understood it, with something to try for every idea.

CS50x · Week 001 / 09

AI, and why the basics still matter

Key ideaCS50 doesn’t teach you to type code, it teaches you to think. AI helps, but you’re still the pilot.

  • Malan builds a chatbot in about ten lines of Python on top of an API: a service another company runs, that you write your own code on.
  • The user prompt is what the person types. The system prompt is the fixed instruction behind it. Same question, different answer.
  • Calculators exist and it’s still worth knowing how to add. Same with AI and code.
  • Rubber duck debugging: explain your problem out loud, even to a duck, and you often find the bug yourself.
System prompt vs user promptTry it
  1. System

    (empty)

  2. User

    What is CS50?

  3. Assistant

    CS50 is Harvard’s introduction to computer science, taught by David J. Malan. It starts with Scratch, then moves through C, Python, SQL and web development.

Hand-written replies to show the idea. Nothing here calls a real AI.

CS50x · Week 002 / 09

What computer science actually is

Key ideaIt’s the study of information: how to represent it, and how to process it to solve problems.

  • Every problem has the same shape: input → an algorithm (the black box) → output.
  • Computational thinking is using that idea on real-life problems, not only on computers.
  • Before solving anything we have to agree on how to represent inputs and outputs. Spoiler: zeros and ones.
Input → black box → outputTry it
Input50
Algorithm?
Output110010

Run it, then peek inside. The algorithm is just the steps in the middle.

CS50x · Week 003 / 09

Binary: counting with light bulbs

Key ideaA computer only knows on (1) and off (0). Give each position a different weight and you can count surprisingly high.

  • Decimal uses columns of 1, 10, 100. Binary uses columns of 1, 2, 4, 8… each one doubles.
  • A bit is one binary digit. A byte is 8 bits: 256 patterns, from 0 to 255.
  • Inside the chip the bulbs are transistors: billions of tiny switches.
  • 32 bits count to about 4 billion. Most computers today use 64.
One byte, eight bulbsTry it
Binary
01001000
Decimal
72
As ASCII
H

Tap a bulb to flip that bit. Add up the numbers above the lit ones and you get the decimal.

CS50x · Week 004 / 09

Text is numbers we agreed on

Key ideaEvery letter is just a number everybody agreed on. A is 65, B is 66, and so on.

  • Texting “HI!” sends 3 bytes: 72, 73 and 33. That map from letters to numbers is ASCII.
  • Lowercase is uppercase + 32. Flip one single bit and A becomes a.
  • ASCII only fits English. Unicode goes up to 32 bits, so it covers every language and emoji. 😂 is number 128,514.
  • Is 65 the letter A or the number 65? It depends on context: the program decides how to read it.
Letters into bytesTry it
H72
I73
!33

Type anything. The 32 column is the only difference between upper and lower case.

CS50x · Week 005 / 09

Colour, images, video and sound

Key ideaMedia is numbers stacked in layers: colour → pixel → image → video.

  • RGB: how much red, green and blue, each from 0 to 255. One byte each, three bytes per colour.
  • A pixel is one dot with its own colour. Millions of them are why a photo weighs megabytes.
  • Video is many images per second, like a flipbook. Music can be stored as notes: pitch, length, volume.
Three bytes, one colourTry it
RGB
72 · 73 · 33
Read as text
H I !

72, 73, 33 is “HI!” in a text message and this olive in a photo editor. Same bytes, different context.

CS50x · Week 006 / 09

Algorithms: the phone book

Key ideaAn algorithm is a list of steps that solves a problem. Working isn’t enough: it should also be fast.

  • Page by page works, but 1,000 pages can take 1,000 steps.
  • Two pages at a time is twice as fast. If you overshoot the name, go back one page.
  • Splitting the book in half every time takes about 10 steps for 1,000 pages. Double the book and it costs one more step. That’s log₂ n.
Three ways to find a nameTry it
Page by page0 steps
Two at a time0 steps
Split in half0 steps

page 620 / 1,000

Worst case · n
1,000
Worst case · n / 2
500
Worst case · log₂ n
10

All three get there. Switch to 2,000 pages: splitting in half needs just one more step.

CS50x · Week 007 / 09

Pseudocode and the four building blocks

Key ideaAlmost every program is built from functions, conditionals, boolean expressions and loops.

  • Functions are the verbs: open, look, call.
  • Conditionals are forks in the road. Boolean expressions are the yes/no questions that pick the path.
  • Loops repeat steps (“go back to line 3”). This one ends because the book keeps shrinking.
  • The last “else” is the edge case: what if the person isn’t there? Forgetting cases like that is how programs freeze.
Run the pseudocodeTry it
  1. 1Pick up the phone book
  2. 2Open to the middle
  3. 3Look at the page
  4. 4If the person is on the page
  5. 5 Call the person
  6. 6Else if the person is earlier in the book
  7. 7 Open to the middle of the left half
  8. 8 Go back to line 3
  9. 9Else if the person is later in the book
  10. 10 Open to the middle of the right half
  11. 11 Go back to line 3
  12. 12Else
  13. 13 Quit
0 lines run

Step one line at a time. Look for Zoe: she isn’t in the book, so the last “else” saves the program.

CS50x · Week 008 / 09

Abstraction: from transistors to Python

Key ideaEach layer hides the complexity of the one below it. We build on what someone else already solved.

  • Companies like Intel and AMD decide which bit patterns mean add, store or print.
  • A compiler translates one language into another, for example C into machine code.
  • The chatbot from part 1 is the same idea: someone else did the hard part, you write ten lines on top.
Peel the layersTry it
  1. 01Pythonprint("hello, world")You write this.

Every layer does the same job as the one above, with more detail and less help.

CS50x · Week 009 / 09

Scratch: programming with blocks

Key ideaScratch, from MIT, has the same ideas as C or Python, without worrying about commas and braces.

  • Events start things (“when green flag clicked”). Arguments go into a function, a return value comes back out, and a side effect is what you see or hear.
  • Copy and paste is a warning sign: one “repeat 3” is better design than three identical blocks.
  • “Forever” + “if”: without the loop, the cat checks once whether you’re petting it, and the moment is gone.
  • Big projects are built in small steps. Start with the smallest version that works.
Copy and paste vs a loopTry it

Copied · 4 blocks

when green flag clickedsay Meowsay Meowsay Meow

Loop · 3 blocks

when green flag clickedrepeat 3say Meow
…
when green flag clickedforeverif touching mousesay Purr!

Move the slider. The copied version keeps growing, the loop stays at three blocks.

End of chapterCS50x · Week 0

Copy this summary and paste it into your own Claude. It comes with a prompt and the official transcript, so you can ask anything and get quizzed on it.