CS50 Week 0 — Computational Thinking
Computer Science students usually start counting from 0.
| Term | Definition |
|---|---|
| Base-2 / Binary | Operating at 2 states |
| Bit | Binary Digit (0 or 1) |
| Transistors | Millions of light bulbs that can be off and on |
| Ternary | Some computers use 0, 1, 2 — but it’s simpler to do a binary system |
Binary
Computers use base-2 (only 2 states) to count.
The max number a computer can count to depends on the number of bits.
If I have n bits, the max I can count to is 2^n − 1.
2^2 2^1 2^0
4 2 1
To know which number a string of bits represents, sum each bit times its place value:
(1 × 2^3) + (0 × 2^2) + (1 × 2^1) + (0 × 2^0) = 10
2^3 2^2 2^1 2^0
1 0 1 0
Computers speak in binary — a language of only 0s and 1s. Why? Because each wire or transistor can be on or off — just 2 states. This is called base-2, and it’s how all numbers, letters, and images are ultimately stored and processed. Each bit (binary digit) represents a power of 2. Combine them to count, store, and compute — starting from just 1s and 0s.
ASCII
American Standard Code for Information Interchange — 8 bits only (256 values).
| Dec | Char | Dec | Char | Dec | Char | Dec | Char | Dec | Char | Dec | Char | Dec | Char | Dec | Char |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | NUL | 16 | DLE | 32 | SP | 48 | 0 | 64 | @ | 80 | P | 96 | ` | 112 | p |
| 1 | SOH | 17 | DC1 | 33 | ! | 49 | 1 | 65 | A | 81 | Q | 97 | a | 113 | q |
| 2 | STX | 18 | DC2 | 34 | ” | 50 | 2 | 66 | B | 82 | R | 98 | b | 114 | r |
| 3 | ETX | 19 | DC3 | 35 | # | 51 | 3 | 67 | C | 83 | S | 99 | c | 115 | s |
| 4 | EOT | 20 | DC4 | 36 | $ | 52 | 4 | 68 | D | 84 | T | 100 | d | 116 | t |
| 5 | ENQ | 21 | NAK | 37 | % | 53 | 5 | 69 | E | 85 | U | 101 | e | 117 | u |
| 6 | ACK | 22 | SYN | 38 | & | 54 | 6 | 70 | F | 86 | V | 102 | f | 118 | v |
| 7 | BEL | 23 | ETB | 39 | ’ | 55 | 7 | 71 | G | 87 | W | 103 | g | 119 | w |
| 8 | BS | 24 | CAN | 40 | ( | 56 | 8 | 72 | H | 88 | X | 104 | h | 120 | x |
| 9 | HT | 25 | EM | 41 | ) | 57 | 9 | 73 | I | 89 | Y | 105 | i | 121 | y |
| 10 | LF | 26 | SUB | 42 | * | 58 | : | 74 | J | 90 | Z | 106 | j | 122 | z |
| 11 | VT | 27 | ESC | 43 | + | 59 | ; | 75 | K | 91 | [ | 107 | k | 123 | { |
| 12 | FF | 28 | FS | 44 | , | 60 | < | 76 | L | 92 | \ | 108 | l | 124 | | |
| 13 | CR | 29 | GS | 45 | - | 61 | = | 77 | M | 93 | ] | 109 | m | 125 | } |
| 14 | SO | 30 | RS | 46 | . | 62 | > | 78 | N | 94 | ^ | 110 | n | 126 | ~ |
| 15 | SI | 31 | US | 47 | / | 63 | ? | 79 | O | 95 | _ | 111 | o | 127 | DEL |
Unicode
There are so many languages today — we need MORE characters. That’s why some computers use 32-bit — that supports 4 294 967 296 combinations.
Unicode is a universal character encoding standard that assigns a unique number (called a code point) to every character in every language, including emojis and math symbols.
The code list is updated each year for new emojis, so software needs to be kept updated — otherwise the emoji (which is just a number) won’t render.
While the pattern of zeros and ones is standardised within Unicode, each device manufacturer may display each emoji slightly differently — depending on the artist.
There are so many characters today — we need more combinations. That’s why some computers use 32-bit, allowing 4.3 billion unique patterns. Unicode assigns a unique number (code point) to every character in every language — including emojis and math symbols. Emojis are just numbers. If your software isn’t updated, the emoji won’t show. And while the code is the same, how it looks depends on the device’s artist.
RGB
3 bytes — 24 bits per pixel. Each photo is made up of megabytes — due to each pixel. Videos are just sequences of images. 30 frames per second.
RGB uses 3 bytes per pixel — 24 bits total. Each pixel stores values for Red, Green, and Blue, each from 0 to 255. Combine them to create millions of colors. Images are made of millions of pixels, so even a single photo takes up megabytes. Videos? Just images played at 30+ frames per second — which adds up fast.
Algorithms
We know how computers represent:
- Letters (ASCII)
- Emojis (Unicode)
- Images (pixels, 3 bytes RGB)
- Videos (many images in sequence)
- Sound (each byte corresponds to pitch, volume, duration, etc.)
Algorithms convert an input to an output (the code understands the 0s and 1s). Learn algorithms so you can navigate big data and build well-designed, fast code.
Pseudocode
The process of writing out instructions in human-readable form before formal code is called pseudocode.
1 Pick up phone book
2 Open to middle of phone book
3 Look at page
Why bother?
- Pseudocoding before formal code lets you think through the logic of the problem in advance.
- You can later provide this to others who want to understand your coding decisions and how the code works.
Building blocks:
- Action → functions
- If / else → conditionals
- “Person exists” → boolean (true/false)
- Go back → loop
Artificial Intelligence
You can’t write out so many possible conditionals for all scenarios (e.g., a chatbot). Solution: train large language models on large data sets. LLMs look at patterns in large blocks of language. Such models attempt to create a best guess of what words come after one another or alongside one another. Neural networks — lots of neurons are fed inputs; the final neuron should give the best probable answer.
We are learning C
It’s fast and good at making devices operate quickly.
Building with Scratch — Project requirements
- Your project must use at least two sprites, at least one of which must not be a cat.
- Your project must have at least three scripts total (not necessarily three per sprite).
- Your project must use at least one conditional, at least one loop, and at least one variable.
- Your project must use at least one custom block that you have made yourself (via Make a Block), which must take at least one input.
- Your project should be more complex than most of those demonstrated in lecture (many of which, though instructive, were quite short) but it can be less complex than Oscartime and Ivy’s Hardest Game.
Once finished with your project, select File → Save now one last time. Then select File → Save to your computer and keep that file so that you can submit it. If prompted by your computer to Open or Save the file, be sure to Save it.
Submission Step 1 of 2
Submit this form.
Submission Step 2 of 2
This step assumes that you’ve downloaded your Scratch project as a file whose name ends in .sb3, and that you’ve signed up for a GitHub account, per the above form.
- Visit this link, log in with your GitHub account, and click Authorize cs50.
- Check the box indicating that you’d like to grant course staff access to your submissions, and click Join course.
- Go to submit.cs50.io/upload/cs50/problems/2025/x/scratch.
- Click Choose File and choose your
.sb3file. Click Submit.
If you encounter the error “No files in this directory are expected by cs50/problems/2025/x/scratch”, please make sure your scratch project file name indeed ends with .sb3.
Once your submission uploads, you’ll be redirected to your submission page. Click the submission link and then the check50 link to see which requirements your project met. You can resubmit as many times as you’d like (before the deadline). Note that if you upload a file whose size is larger than 10MB, check50 may struggle to process it — best to keep your file under that limit.
To view your current progress in the course, visit the course gradebook at cs50.me/cs50x.