CS50 Week 0 — Computational Thinking

Computer Science students usually start counting from 0.

TermDefinition
Base-2 / BinaryOperating at 2 states
BitBinary Digit (0 or 1)
TransistorsMillions of light bulbs that can be off and on
TernarySome 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).

DecCharDecCharDecCharDecCharDecCharDecCharDecCharDecChar
0NUL16DLE32SP48064@80P96`112p
1SOH17DC133!49165A81Q97a113q
2STX18DC23450266B82R98b114r
3ETX19DC335#51367C83S99c115s
4EOT20DC436$52468D84T100d116t
5ENQ21NAK37%53569E85U101e117u
6ACK22SYN38&54670F86V102f118v
7BEL23ETB3955771G87W103g119w
8BS24CAN40(56872H88X104h120x
9HT25EM41)57973I89Y105i121y
10LF26SUB42*58:74J90Z106j122z
11VT27ESC43+59;75K91[107k123{
12FF28FS44,60<76L92\108l124|
13CR29GS45-61=77M93]109m125}
14SO30RS46.62>78N94^110n126~
15SI31US47/63?79O95_111o127DEL

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?

  1. Pseudocoding before formal code lets you think through the logic of the problem in advance.
  2. 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.

  1. Visit this link, log in with your GitHub account, and click Authorize cs50.
  2. Check the box indicating that you’d like to grant course staff access to your submissions, and click Join course.
  3. Go to submit.cs50.io/upload/cs50/problems/2025/x/scratch.
  4. Click Choose File and choose your .sb3 file. 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.