Post

CS50x 01. Scratch

This is the summary of CS50x course.

CS50x 01. Scratch

This is the summary of CS50x course.

Computer Science and Problem Solving


  • computer programming is solving a problem
  • input -> black box -> output
  • We could use a system called unary (also called base-1) to count one finger at a time.
  • Computers today count using a system called binary from the term binary digit that we get a familiar term called bit (zero or one: on or off).
  • Computers use base-2 to count. This can be pictured as follows:
    2^2  2^1  2^0
    4    2    1
    
  • Computers generally use eight bits (also known as a byte) to represent a number. For example, 00000101 is the number 5 in binary. 11111111 represents the number 255. (128/64/32/16/8/4/2/1)

ASCII


  • American Standard Code for Information Interchange
  • Letters are represented using ones and zeros, just as numbers.
  • The ASCII standard was created to map specific letters to specific numbers.
    H  I  !
    72 73 33
    
  • More about ASCII
  • Since binary can only count up to 255 we are limited to the number of characters represented by ASCII

Unicode


  • The Unicode standard expanded the number of bits that can be transmitted and understood by computers. Unicode includes not only special characters, but emoji as well. 🤣😒
  • While the pattern of zeros and one is standardized within Unicode, each device manufacturer may display each emoji slightly differently than another manufacturer.
  • More and more features are being added to the Unicode standard to represent further characters and emoji.
  • More about Unicode, emoji.

RGB


  • Red, Green and Blue (called RGB) is a combination of three numbers.
  • Yellow = R:72, G:73, B:33
  • Three three bytes required to represent various colors of red, blue, and green make up each pixel (or dot) of color in any digital image.
  • Images are simply combinations of RGB values.

Algorithms


  • An algorithm is a step-by-step set of instructions to solve a problem.
  • Programmers translate text-based, human instructions into code.

Pesudocode


  • This process of converting instructions into code is called pseudocode.
  • Pseudocode is a human-readable version of your code.
  • Pseudocode is such an important skill for at least two reasons.
    • When you pseudocode before you create formal code, it allows you to think through the logic of your problem in advance.
    • When you pseudocode, you can later provide this information to others that are seeking to understand your coding decisions and how your code works.
      1  Pick up phone book
      2  Open to middle of phone book
      3  Look at page
      4  If person is on page
      5      Call person
      6  Else if person is earlier in book
      7      Open to middle of left half of book
      8      Go back to line 3
      9  Else if person is later in book
      10     Open to middle of right half of book
      11     Go back to line 3
      12 Else
      13     Quit
      
  • Unique features
    • Some of these lines begin with verbs like pick up, open, look at. Later, we will call these functions.
    • Some lines include statements like if or else if. These are called conditionals.
    • How there are expressions that can be stated as ture or false. We call these boolean expressions.
    • How there are statements like “go back to line 3.” We call these loops.

Artificial Intelligence


  • Look at the following pseudocode:
    If student says hello
      Say hello
    Else if student says goodbye
      Say goodbye 
    Else if student asks how you are
      Say well
    Else if student asks why 111 in binary is 7 in decimal
    ...
    
  • Rather than programming conversational AI like the above, AI programmers train large language models (LLMs) on large datasets.
This post is licensed under CC BY 4.0 by the author.