CS50's Undersanding Technology Documentation
CS50's Undersanding Technology Documentation
Understanding Technology
CS50’s
2024-2025
1|Page
Incognito Mode......................................................................................................... 39
Authentication........................................................................................................... 39
Passwords................................................................................................................. 39
Password Resetting................................................................................................... 40
Using The Same Password........................................................................................ 41
Password Managers.................................................................................................. 41
Two Factor Authentication........................................................................................ 41
Network security....................................................................................................... 42
VPN........................................................................................................................... 43
Firewall..................................................................................................................... 43
Encryption................................................................................................................. 43
Public Key Cryptography........................................................................................... 44
Phishing.................................................................................................................... 45
Malware.................................................................................................................... 46
Trust.......................................................................................................................... 46
Web Browser............................................................................................................. 47
Web Server............................................................................................................... 47
HTTP.......................................................................................................................... 47
HTTP Status Codes.................................................................................................... 48
HTML........................................................................................................................ 48
Atom.......................................................................................................................... 50
Links.......................................................................................................................... 50
Images........................................................................................................................ 51
Paragraphs.................................................................................................................. 52
Headings...................................................................................................................... 52
Lists........................................................................................................................... 52
Tables......................................................................................................................... 53
Implementing Google................................................................................................ 54
Forms........................................................................................................................ 55
css0.html.................................................................................................................. 56
DOM.......................................................................................................................... 57
css1.html.................................................................................................................. 57
css2.html.................................................................................................................. 58
css3.html.................................................................................................................. 59
css4.html.................................................................................................................. 60
2|Page
Closing Thoughts...................................................................................................... 62
Introduction.............................................................................................................. 63
Software.................................................................................................................... 63
Finding Mike Smith.................................................................................................... 63
Phonebook Algorithm................................................................................................ 64
Pseudocode............................................................................................................... 64
Programming Constructs.......................................................................................... 64
C............................................................................................................................... 65
C++............................................................................................................................ 65
Python....................................................................................................................... 65
Other Programming Language.................................................................................. 66
Introducing Scratch................................................................................................... 66
hello, world in Scratch............................................................................................... 67
Scratch Interface....................................................................................................... 69
Sounds...................................................................................................................... 71
Loops........................................................................................................................ 71
Animation.................................................................................................................. 72
Breaking Down Problems.......................................................................................... 74
pet the cat................................................................................................................ 74
don’t pet the cat....................................................................................................... 75
counting sheep......................................................................................................... 75
cough0...................................................................................................................... 76
cough1...................................................................................................................... 77
Cough2...................................................................................................................... 78
Threads..................................................................................................................... 80
Events....................................................................................................................... 82
Closing Thoughts...................................................................................................... 84
3|Page
Introduction
This course is for students who don’t (yet) consider themselves computer
persons. Designed for students who work with technology every day but
don’t necessarily understand how it all works underneath the hood or
how to solve problems when something goes wrong, this course fills in
the gaps, empowering students to use and troubleshoot technology more
effectively. Through lectures on hardware, the Internet, multimedia,
security, programming, and web development as well as through readings
on current events, this course equips students for today’s technology and
prepares them Watch Lecture for tomorrow’s as well.
Hardware
internet
multimedia
security
web development
programming
Methodology
4|Page
Watch Lecture
Recap Session
Complete Assignment
Evaluation:
Each student by the end of this course must be passed in 3 exams, one exam
per two modules.
Then, students who passed all exams will get a certificate of attendance from
ITI
1- Hardware
5|Page
Binary
We use computers everyday
100 10 1
1 2 3
Inside a computer, the binary 000 would represent 0, just like in our human world!
4 2 1
0 0 0
20 = 1, 21 = 2, 22 = 4, 23 = 8, etc.
o The difference between decimal numbers and binary numbers is changing the base
6|Page
o For the binary number 000, we have 4 x 0 + 2 x 0 + 1 x 0 = 0 + 0 + 0 = 0!
4 2 1
0 0 1
o We have 4 x 0 + 2 x 0 + 1 x 1 = 0 + 0 + 1 = 1
4 2 1
0 1 0
o This gives us 4 x 0 + 2 x 1 + 1 x 0 = 0 + 2 + 0 = 2
4 2 1
0 1 1
o As we need a 2 and a 1
o Thus, 4 x 0 + 2 x 1 + 1 x 1 = 0 + 2 + 1 = 3
4 2 1
1 0 0
What about 7?
4 2 1
1 1 1
o Which yields 4 x 1 + 2 x 1 + 1 x 1 = 4 + 2 + 1 = 7
What about 8?
7|Page
We run into this in the real world too if we need a four-digit number vs a 3-
digit number
Start with the 1s, 10s, 100s place and add the 1000s
8 4 2 1
1 0 0 0
8x1+4x0+2x0+1x0=8
Even though computers only use binary, they can count as high as humans can!
This is because it’s easier to represent two states in the physical world
0 is off
1 is on
Turned on represents 1
Using these transistors we can store values, store data, compute, and do everything we can
with computers
8|Page
65 -> A, 66 -> B, 67 -> C, etc.
o Programs like notepad, textedit, and MicroSoft Word decide weather to display
patterns of bits as letters or words
Computers only store 0s and 1s, but the programs interpret those bits in a
certain way
o ASCII is limited
o UNICODE is a bigger set of characters that includes written languages other than
English and even emoji!
9|Page
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
0 1 0 0 1 0 0 0 0 1 0 0 1 0 0 1
1 x 64 + 1 x 8 1 x 64 + 1 x 8 + 1 x 1
72 73
H I
CPU
If you have heard that your computer has “Intel Inside,” it has an Intel processor in it
o The backside of the processor has pins that connect into the motherboard
o Cores are the devices inside the CPU that can preform mathematical operations,
load info from memory, save info to memory, etc.
10 | P a g e
CPUs now also support hyper-threading
o Where a single core will present itself as multiple cores to a computer’s operating
system
Systems on a Chip (SoaC) are when a CPU and more are all interconnected at once rather
than attached to a motherboard
o Raspberry Pi
o Files and programs are loaded onto these chips when ran
o Fast memory
11 | P a g e
CPU chart shows when peak usage occurs
GHz is the number of operations a CPU can perform per second (in billions)
Logical processors in this case is 4, which means both cores support hyper-
threading
Hard Drives
When you turn a computer off, you need a place to store data
12 | P a g e
o RAM may store 1 GB, 2 GB, 4 GB, through 16 GB or so
The reading heads move back and forth reading data from the device
Uses tiny magnetic particles where north pole orientation represents 1 and
south pole orientation represents 0
To store data in a hard drive, RAM sends data and instructions to the HDD
Some signals spin the platters, others move the read/write heads
13 | P a g e
Pulses sent to the read/write head turn on a magnet which creates a field that
changes the polarity of a tiny portion of the metal platter’s surface
o To read, the particles on the disk use their charge to move the read/write head.
o Anytime you have a physical device that moves over a period of time, things go
wrong
Flash Memory
Solid state disk (SSD)
o Smaller (3.5 inch width for HDD vs 2.5 inch width for SSD)
o No moving particles
14 | P a g e
o Much faster than HDD
Hybrid Drives
o Portable
15 | P a g e
Theoretically, the CPU never has to wait for data to crunch
o The shop owner then leaves the counter to grab the candy before returning moments
later
Not super efficient to walk all the way to the store room to grab candy
o Instead, the shop owner leaves the counter to ready a cache of candy before the
customers arrive
16 | P a g e
Display Connectors
Can plug in a whole range of peripheral devices including printers, keyboards, mice,
scanners, etc.
17 | P a g e
o Hard drives can connect via USB
Even if a hard drive is fast, if the USB is slow, the transfer of data will be
slow
Wireless
Wifi is wireless internet
Bluetooth allows devices such as wireless keyboards and headphones to connect to your
computer
o Limited range
When you hit power on your computer, the OS is loaded into RAM
o Special software designed to talk to certain model of printer, camera, scanner, etc.
When an OS doesn’t recognize a device, perhaps because it’s too new, you can download
new device drives from the device manufacturer
o Future-proofing structure
It’s this intersection of hardware and software that makes computers powerful!
18 | P a g e
2- Internet
Introduction
We use the internet daily and have constant access and connectivity
Home network
IP
Every computer on the internet has an IP (Internet Protocol) address
19 | P a g e
o Like postal addresses, they uniquely identify computers on the internet
The home router supports DHCP and assigns IP addresses to your devices
DNS
We access websites using domain names (Facebook.com, Google.com, etc.), but it turns
out that these sites too have IP addresses
DNS (Domain Name System) servers convert domain names into IP addresses
Packets
Computers communicate by sending packets, which are like virtual envelopes sent between
computers
However, for the recipient of the request, we don’t know the IP address for Google
If the ISP’s DNS server doesn’t know a website’s IP address, it has been
configured to ask another DNS server
20 | P a g e
There exist root servers that know where to look to for an IP address if it
exists
o If the cat image is too large for a single envelope, sending it in one packet could
take up internet traffic
o To solve this, Google will divide the cat image into smaller fragments
TCP/IP
IP goes beyond addresses
o If missing a packet, you can logically infer which packet you’re missing based on
the ones received
TCP (Transmission Control Protocol) ensures packets can get to their destination
21 | P a g e
When missing a packet, a computer can make a request for the missing
packet
To make sure Google knows we’re requesting a webpage and not an email
or other service
Ports
Per TCP, the world has standardized numbers that represent different services
If 5.6.7.8 is Google’s IP address, 5.6.7.8;80 (port 80) lets use know that we want a webpage
o Google will send the request to their web server via http
Many websites use secure connections with SSL or HTTPS, which uses the port 443
Protocols
Protocols are just sets of rules
o Humans use these all the time, such as the protocol for meeting people: handshakes
When a request is made to Google for an image, HTTP tells Google how to respond
appropriately
UDP
User Datagram Protocol
Packets can be dropped for the sake of keeping the conversation flowing
o Used anytime you want to keep data coming without waiting for a buffer to fill
22 | P a g e
IPs in More Detail
IP addresses are limited
23 | P a g e
o Only with special configuration can someone talk to your computer
o Your personal device is not a server, so people should not need to access them
directly
o Even email is stored on a server such as Gmail and your device makes a request to
that server to access that email
On windows:
24 | P a g e
o Shows DNS servers as well
Routers
Routers have bunches if wires coming and going out of them
o They have a big table with IP addresses and where data should be routed to get to that
destination
When multiple packets are sent, like cat.jpg from Google, they can each take a
different path, still getting to their destination eventually
25 | P a g e
Sometimes the internet is busy and the quickest path changes
Traceroute
How long does it take for this process of data transfer to take on the internet?
o 6: Northern Crossroads
8-9: Chicago
26 | P a g e
10-11: Denver
27 | P a g e
W1-Exam
1- The difference between decimal and binary numbers is changing the base?
True
False
101
100
010
1111
0000
1011
1010
4- With.... we can store values, store data, compute, and do everything with
computers
Hardware
Transistors
RAM
7, 128
8, 256
28 | P a g e
9, 512
True
False
8-..... is a Circuit board with chips(to store data) that slides into a slot on the
motherboard
ROM
RAM
NVRAM
9- Power is not needed to read or change the data from hard disk? *
True
False
10- Hybrid Drives means Some GB of solid state memory and more GB or TB of
HDD space?
True
False
29 | P a g e
11-.... is Software that ensures all devices work and can intercommunicating *
Hardware
Firmware
Operating System
12- ... is Special software designed to talk to certain model of printer, camera,
scanner, etc.
Device Driver
USB
OS
MAC
DNS
IP
14- ... is a program that sends packets to each router on a path to a destination,
reporting the time it takes to reach that router.
traceroute
ip
tcp
24
32
128
30 | P a g e
3- Multimedia
Introduction
Odds are you use it every day, but what is it?
Audio
Computers are good at recording, playing back, and generating audio
Uses different file formats
o File formats are just a way of storing 0s and 1s on disk so that certain
software knows how to interpret it
MIDI
o Way of storing musical notes for certain songs
o Can do this for different instruments
Programs can render the notes for these instruments
GarageBand
o Included with macOS
31 | P a g e
Humans typically like to hear music preformed and recorded by humans
o File formats for recorded music include:
AAC
MIDI
MP3
WAV
WAV is an early sound format, but still used
o Uncompressed data storage allowing high quality
MP3
o File format for audio that uses compression
Significantly reduce how many bits are necessary to store a song
Discards 0s and 1s that humans can’t necessarily hear
True audiophiles may disagree
Trade off between optimizing storage space and sacrificing quality
This compression is said to be lossy
Losing the quality in the compression process
AAC
o Similar to MP3
o May see when you download a song from iTunes
Streaming services such as Spotify don’t transfer a file to you but rather stream bits
of information to you
How do we think about the quality of these formats?
o Sampling frequency
Number of times per seconds we take a digital snapshot of what a
person would hear
o Bit depth
Number of bits used for these individual snapshots
o Sampling frequency x bit depth = number of bits necessary to store one
second of music
o Audio file formats allow you to modify what these parameters are
32 | P a g e
Graphics
A graphic, what we see with multimedia, is really just a bunch of pixels both horizontal and
vertical
o All file formats are rectangular in nature, though transparent pixels can make
images look to take on other shapes
o In the simplest form, each of the dots or pixels is a bunch of 0s and 1s
33 | P a g e
When we talk about image formats, we typically don’t talk in terms of binary but rather
something called hexadecimal (base-16, contains 16 digits)
o 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
o 0 is the smallest number we can represent in single digit
o f is the largest number (value of 15) we can represent in a single digit
Consider the 8 bits: 1111 1111
o Each hexadecimal digit represents four bits
o One hexadecimal digit can represent the first four bits, another can represent the
second four
Represent something with eight symbols using only two!
o 1111 is the decimal number 15, which is f
o Therefore, 1111 1111 in hexadecimal is ff
Red can thus be represented in hexadecimal as ff 00 00
Green can be represented in hexadecimal as 00 ff 00
Blue can be represented in hexadecimal as 00 00 ff
A lot of graphical editing software such as Photoshop use hexadecimal to represent colors
Bitmap Format
34 | P a g e
o Notice the pixelation
Much like with audio, so too in the world of images do you have discretion over how many
bits to use
o How many bits to represent each pixel’s color?
o Resolution is another factor
An image that is only 100 pixels scaled up only duplicates the existing
limited information, resulting in a blotchy image
Would be better to start with image that has a higher resolution (more
pixels)
A lot of repeated colors, so it seems silly to represent each color with the same number of
bits
Image Compression
Graphical file formats can often be compressed
Can be done lossy or losslessly
o With audio, we threw away audio information that the human ear can’t necessarily
hear
This is lossy compression; throwing information away
o Using fewer bits to represent the same information is lossless compression
Lossless compression
35 | P a g e
There is a lot of repeated blue in the first image
o Using the same 24 bits to represent each pixel!
The second image is compressed and not what a user would see
o The first column contains the color that the rest of the row (scan line) should have
Image contains instructions on how to repeat the color in a particular row
o When a color is encountered that isn’t in the first column (the apple in this case),
the instructions would list the colors for each non-repeated pixel
o This uses less bits but makes the original information recoverable
Lossy compression
This is a .jpg photograph that is somewhat compressed, but not easy to tell
Let’s say we want to compress this image further so that we can share it without going over
a social media platform’s limit
It contains more complicated patterns of colors, so let’s try a lossy compression resulting in
the following:
36 | P a g e
Lossy compression means that I won’t be able to get that original image back
o The compression throws away bits of information
“Does the sky really need this many shades of blue?”
“Does this leaf really need this many shades of green”
Replaces bits with only a few colors giving an approximation
I will not be able to know how clear the sky used to be from this
information
Image File Formats
BMP
o Originally used by Windows
o Not super common these days
GIF
o Low quality images
Only supports 8-bit color
o Often used for memes
Can be animated
Like a video file with only a few images
37 | P a g e
JPEG
o Supports 24-bit color
o Losslessly compresses
Can minimize amount of compression to create high quality photos
PNG
o High quality graphics
o Supports 24-bit color
All these formats ultimately have an limited amount of information
o Ultimate just store pixels and colors of when the image was taken
Video Compression
You can think of a video format as similar to a flip book
Video formats are just a bunch of images shown quickly in succession to create the illusion
of motion
o Not necessarily all information stored as png, jpg, gif, or even images
o Algorithms and mathematics can help go from one frame to another
Opportunities for compression
o Can leverage same image compression techniques for each frame (intra-frame
coding)
o Background of multiple frames can contain redundant information
38 | P a g e
o Compare current frame and next frame of video and determine what has changed
Store these differences
Key frames store a snapshot of time to remember what the video looks like
In each subsequent frame remember what has changed
Using algorithms and math, background is drawn
Key frames are stored multiple times to guarantee that frames can be
recovered
Video File Formats
In the world of video, there are more solutions on how to store information
Video file formats are containers
o Containers are digital container in which you can put multiple types of data
o Can include a video track, audio track, a secondary audio track (for different
languages), closed captions, …
AVI
o Commonly used in Windows
DivX
Matroska
o Open source container meant to be more versatile
MP4
o Pretty much universal in all browsers
QuickTime
o Commonly used in MacOS
Codecs
o Ways of storing and encoding information
o For video:
H.264
MPEG-4 Part-2
39 | P a g e
o For audio:
Can be stand alone files or tracks in a container!
AAC
MP3
3D Video
Increasingly, 3D formats are becoming more common
More file formats are still on the horizon, but ultimately all of them boil down to storing 0s
and 1s and why!
40 | P a g e
4- Security
Introduction
Our data is under constant threat, but how can we defend ourselves?
Privacy
Keeping people away from things you don’t want them to see
Computers are among the lease secure devices you own
o Data or files are stored on them as 0s and 1s
Can be financial info, photos, etc.
Deleting Files
What does it mean to delete a file off of a hard drive?
o Visually, it disappears from a desktop or folder
Files are stored on a computer as 0s and 1s
Some space needs to be allocated for the file
The operating system has a file that keeps track of files an their location on disk
Graphically, when a file is deleted, it moves to the trash (or recycle bin)
o It can still be easily revived from here, until you empty the trash
However, an operating system doesn’t actually delete it from the hard drive
o It simply forgets the location and existence of the file!
o One can theoretically recover data by looking for familiar patterns of bits
So how do we delete more securely?
o Re-saving a file with overridden information actually could not override the old bits
but rather create more 0s and 1s stored on a hard drive!
o Special software can wipe data off of a hard drive
Who do computers have this obvious flaw with deleting?
o What if we accidentally delete a file?
This structure allows for recovery
o Wiping data also takes a lot of time, so it’s much faster to just forget locations of
data
Cookies
A feature supported by HTTP
Little values a web server puts on a user’s browser
Used to remember if a user has visited a website before
o Allows you to not have to log in every time you visit or refresh a page
When you log into a web server, a cookie is planted on your browser
41 | P a g e
o Stored in a database
o Browser will send value to web server to remind of previous login
When we make a request we send:
GET / HTTP/1.1
Host: example.com
We receive:
HTTP/1.1 200 OK
Set-Cookie: session=29823bf3-075a-433a-8754-707d05c418ab
Incognito Mode
Can open up a typically different colored browser window
Use if you want history automatically removed
Useful when building a website as sometimes you want a browser to forget old iterations of
your website build
Authentication
All of this assumes you log in
If you don’t use a passcode to protect your device, anyone can pretend to be you
o What if you lose your phone or device?
Passwords
On a phone could only be a few digits
o Not super secure
With numbers, each space has 10 options
10 x 10 x 10 x 10 = 10,000 possibilities
42 | P a g e
0000-9999
On many smartphones, you will have to wait for an amount of time if you have entered a
bad passcode
o Slows down the process of someone guessing
Add more digits or letters of the alphabet
Using a-z, A-Z, 0-9
__ __ __ __
Each space now has 62 options (26 + 26 + 10)
62 x 62 x 62 x 62 = 14,776,336 possibilities
Maybe you’re super secure and you have a 20-char password
o You could forget it
o Annoying to type in repetitively
No one fits all
o Short = bad, longer = good
o Don’t use popular words and phrases
Hackers will look for words or common phrases
Most common Passwords
1. 123456
2. 123456789
3. qwerty
4. 12345678
5. 111111
6. 1234567890
7. 1234567
8. password
9. 123123
10. 987654321
Hackers have dictionaries of bad passwords that they can search through and try
Random passwords
o Usually have to confirm so it can be hard to replicate
Using numbers to represent letter is common
o 1 for l
o 4 for A
It’s suggested you mix uppercase, lowercase, and and throw in numbers
o Good to use misspellengs
Don’t put your post-it with your password on your monitor!
Constant password changes can be a net negative
o Can encourage easier passwords to help with memorization
43 | P a g e
Password Resetting
What if you forget your password?
o Often can click on a link to reset your password
Asks you to type email address or username
o Typically, you get an email with a link
Hopefully this goes back to the same website!
It likely has a random value in the URL
o Once back at the website, you update your password
The website has a database
o It generated a random number and stored it with a note indicating password
recovery
o The website assumes that anyone who has access to this value and to the user’s
email is you
Typically, tech staff can’t tell you what your password is
o Odds are your password is encrypted (scrambled) or, more technically, hashed in
their database
Getting a password in email means that the password are not hashed or encrypted!
o Also, sending a password over email opens that email to interception
o This is a red flag if a website does this
44 | P a g e
Two Factor Authentications
First factor is a password
o Historically, something “only” the user knows
o Can be guessed
Second factor should be fundamentally different
o Should be something you have
An RSA device displays a unique value that is synced with a server
Network security
So many of our current networks are wireless
o You probably been conditioned to look for free wifi
Sometimes still might not connect for various reasons
If the wireless connection has not padlock (no password to log in) the connection is not
secure
o You may still visit https or secure websites
o However, everything you do on http sites can be seen
What to do?
o Don’t use that network
o Use a VPN (Virtual Private Network)
Connection to internet is Encrypted
45 | P a g e
With an unsecured connection, anyone can access your data
VPN
First establish encrypted connection to a server and let this server communicate for you
o The connection between the VPN server and website can still be insecure!
Because we are encrypting data through an algorithm, using a VPN can slow down speed
Firewall
A physical firewall is a wall between connected buildings that prevents the spread of fire
In the world of computer science, a firewall is software that looks at IP addresses and helps
keep bad guys out and user data inside
Helps prevent people from accessing your computer
Encryption
Suppose I want to send a secret message for “HI”
o HI ➟ IJ
o Change each letter by 1
o The recipient needs to know how it changed to revert
Plaintext ➟ Cyphertext ➟ Plaintext
o HI ➟ IJ ➟ HI
This is called a caesar cypher
o Rotational cyphers are not that secure
Can be guessed easily
Not used for internet encryption
o For this to work, recipient needs the key
To know the key, we need to agree in advance
Can’t send it encrypted as well as they need the key!
46 | P a g e
Public Key Cryptography
The last example with a caesar cypher is secret-key cryptography
o Only one key
In public key cryptography there are two keys, one public and one private
o Mathematical relationship between them
o Use public key to encrypt, private key to Decrypt
o Bob’s private key can undo the effects of his public key
o When Bob responds…
47 | P a g e
Phishing
These kind of attacks have become so prevent that the following has been posted around
Harvard’s campus
48 | P a g e
Malware
Malicious software can also be sent via email
Windows is particularly vulnerable
Software can be injected into your browser and your computer to erase your hard drive,
make your computer send spam, or hold your data hostage
Some malware encrypts your data and asks for large sums of money to get the key to
decrypt it
o Key could not even work!
o This is called ransomware
Malware can ultimately do anything on your computer
Trust
At the end of the day, all of security and privacy boils down to trust
o People around you
o Algorithms/software
o Manufacturers
We’ve downloaded software with trust that it will only do what it claims
o Word could log your key strokes
o Chrome could monitor you even when not on Google’s website
o Snapchat could not delete posts after being seen
There have been cases where software was written to cover tracks of being monitored!
Who’s to say the software we’re using is actually doing what we say?
It’s east to curl up into a ball and worry, but we need to decide who to trust
Security measures make it more difficult for someone to be malicious, but ultimately they
can’t guarantee privacy
You have to decide what data you’re comfortable with storing, what you view on the
internet, who to trust, and how much to trust them
49 | P a g e
W2-Exam
1- A bunch of pixels can be presented in.... *
Horizontal
Vertical
Both
AAC
MIDI
MP3
WAV
White
Black
Green
White
Black
Green
50 | P a g e
6- Blue can be represented in hexadecimal as....
00 ff 00
ff 00 00
00 00 ff
PNG
JPEG
GIF
ROM
Trash
Hard dis
True
False
10- In public key cryptography there is one key called "public key"?
True
False
Phishing
Firmware
Social Engineering
51 | P a g e
12- ... is software that store all usernames and passwords in an encrypted way. *
Password manager
USB
Public key
13- ...... is used to establish encrypted connection to a server and let this server
communicate for you.
Mac
VPN
VNP
14-... is a software/hardware that looks at IP addresses and helps keep bad guys out
and user data inside
Phishing
Malware
Firewall
15-..... Is a Software can be injected into your browser and your computer to erase
your hard drive
Phishing
Malware
Firewall
52 | P a g e
5- Web Development
Web Browser
Web browsers are found on phones, computers, and game consoles
They have a space to enter a URL (Uniform Resource Locator)
o Prefixed by http:// or https://
When typing in a URL, you’re sending a request from your device to some remote server
o The server looks at your request and figures out how to respond
o Like when we previous requested cat images!
Web Server
A computer that has a CPU, RAM, and a hard drive
Rack servers
o Sized so they can be stacked
Odds are your company has many of these if they have a web server
HTTP
We send requests to web servers
o This literally means that everything was okay with the request
53 | P a g e
HTTP Status Codes
Code Status Meaning
200 OK Everything is OK
500 Internal Service Error Not your fault; The server erred
HTML
In addition to the HTTP headers that include status codes, the bits representing an image or
website will be sent to you
o Allows you to format, but doesn’t have control flow such as loops and conditions
<!DOCTYPE html>
<html lang="en">
<head>
<title>hello, world</title>
</head>
54 | P a g e
<body>
hello, world
</body>
</html
This is html for a webpage that says “hello, world”
o Editors like Atom and Sublime Text exist to help write HTML
Ultimately, all you need is a computer, a keyboard, and some way of typing
out text!
<!DOCTYPE html>
<html lang="en">
<head></head>
Atom
TextEdit is not designed for web page development
55 | P a g e
Free alternatives made for web development exist
editors
o To help colleagues who look at your code know your intentions of the code
Links
Links can make our pages more dynamic by linking to other pages
<!DOCTYPE html>
<html lang="en">
<head>
<title>link</title>
</head>
<body>
Visit <a href="http://www.harvard.edu/">Harvard</a>.
</body>
</html>
56 | P a g e
Blue, underlined text traditionally represents a link on a webpage
The bottom left corner on Chrome shows the destination of a link when you hover over the
text
Images
The web is filled with images
<img/> is the image tag
<!DOCTYPE html>
<html lang="en">
<head>
<title>image</title>
</head>
<body>
<img alt="Grumpy Cat" src="cat.jpg"/>
</body>
</html>
The alt (alternative text) attribute is what displays if the page can’t be seen
Paragraphs
Even if you add spaces to format paragraphs, HTML will render without them!
When looking at your webpage you can “view page source” on your browser to see the
original HTML with your spaces, but the webpage still doesn’t have these spaces
Headings
57 | P a g e
<h1></h1> are the heading 1 tags
These make the font larger for usage similar to marking chapters in a book
Lists
Unordered lists
o <ul></ul>
<!DOCTYPE html>
<html lang="en">
<head>
<title>unordered list</title>
</head>
<body>
<ul>
<li> foo </li>
<li> bar </li>
<li> baz </li>
</ul>
</body>
</html>
Ordered lists
o Use numbers
o <ol></ol>
<!DOCTYPE html>
<html lang="en">
<head>
<title>ordered list</title>
</head>
<body>
<ol>
<li>foo</li>
<li>bar</li>
58 | P a g e
<li>baz</li>
</ol>
</body>
</html>
Tables
<table></table> are table tags that create a table
<!DOCTYPE html>
<html lang="en">
<head>
<title>table</title>
</head>
<body>
<table>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>*</td>
<td>0</td>
<td>#</td>
</tr>
</table>
</body>
</html>
59 | P a g e
Implementing Google
When you type google.com your browser adds “https://www.” to the beginning of the URL
curl is a command ran in the terminal that behaves much like a browser
returned
http://www.google.com
Includes status codes and other info humans normally don’t see
60 | P a g e
o curl http://www.google.com returns a webpage that includes HTML and
JavaScript
Forms
<form></form> are form tags that take attributes for an action and a method
o https://www.google.com/search?q=cats
css0.html
Let’s make our webpages more pretty
61 | P a g e
CSS (Cascading Style Sheets) allows us to style our webpages
<!DOCTYPE html>
<html lang="en">
<head>
<title>css0</title>
</head>
<body>
<header style="font-size: large; text-align: center;">
John Harvard
</header>
<main style="font-size: medium; text-align: center;">
Welcome to my home page!
</main>
<footer style="font-size: small; text-align: center;">
Copyright &%169; John Harvard
</footer>
</body>
</html>
Here, inside body, we have three tags: <header></header>, <main></main>,
and <footer></footer>
CSS supports small, medium, large, and exact sizes such as 16px
DOM
62 | P a g e
CSS supports the notion of a
hierarchy
When a browser receives a webpage, it builds a tree-like data structure in your computer’s
RAM
Thus, in this case header, main, and footer are all child nodes of of the parent node body
css1.html
We can put the text-align: center; attribute on the body element so it will pass it on to its
children (header, main, and footer)
<!DOCTYPE html>
<html lang="en">
<head>
<title>css1</title>
</head>
<body style="text-align: center;">
<header style="font-size: large;">
John Harvard
</header>
<main style="font-size: medium;">
Welcome to my home page!
</main>
<footer style="font-size: small;">
Copyright &%169; John Harvard
</footer>
</body>
</html>
63 | P a g e
This is better design as we can change all the text alignment at once
css2.html
Combining HTML and CSS is generally frowned upon
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.centered
{
text-align: center;
}
.large
{
font-size: large;
}
.medium
{
font-size: medium;
}
.small
{
font-size: small;
}
</style>
<title>css2</title>
</head>
<body class="centered">
<header class="large">
John Harvard
</header>
<main class="medium">
Welcome to my home page!
</main>
64 | P a g e
<footer class="small">
Copyright &%169; John Harvard
</footer>
</body>
</html>
Anything with this class with have the style attribute text-align: center;
css3.html
We can even get rid of class attributes to further separate style from content
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body
{
text-align: center;
}
header
{
font-size: large;
}
main
{
font-size: medium;
}
footer
{
font-size: small;
}
</style>
<title>css3</title>
</head>
<body>
65 | P a g e
<header>
John Harvard
</header>
<main>
Welcome to my home page!
</main>
<footer>
Copyright &%169; John Harvard
</footer>
</body>
</html>
We can also give the tags CSS directly
css4.html
What if we remove the style altogether and store it elsewhere?
<!DOCTYPE html>
<html lang="en">
<head>
<link href="css4.css" rel="stylesheet"/>
<title>css4</title>
</head>
<body>
<header>
John Harvard
</header>
<main>
Welcome to my home page!
</main>
<footer>
Copyright &%169; John Harvard
</footer>
</body>
</html>
We have boiled the html down to its essence
Note the <link/> tag with a href attribute of css4.css and a rel (relationship) attribute
of stylesheet
o This says “Hey Browser! Please link my stylesheet css4.css to this page!”
66 | P a g e
In the same directory, we will have this stylesheet
body
{
text-align: center;
}
header
{
font-size: large;
}
main
{
font-size: medium;
}
footer
{
font-size: small;
}
Closing Thoughts
Web development is about writing code
You can use these building blocks to further learn about web development on your own!
o A webpage is nothing more than a text file written in HTML, CSS, and maybe some
JavaScript
67 | P a g e
All your files will go in a folder on the server so that the webpage
can be accessed on the internet
You can also buy a domain name and configure it to point to the web host
These building blocks are what allow you to put your content on the internet!
6- Programming
Introduction
David plays a game called Oscartime that was the first Scratch program he created
68 | P a g e
Scratch is a graphical programming language created by MIT’s Lifelong Kindergarten
Group
The language not only helps get kids excited about programming, but it’s also very
instructive
Software
Programing is ultimately about making software
We could start at the first page, move to the next, and so on until we find him
However, this alone is not correct as we could miss Mike Smith if his name
is sandwiched between two pages
We could fix this by checking the previous page if we go past where Mike
Smith should be
More likely, we’d probably go to the middle of the phonebook and find ourselves in the
“M” section
o After removing the other half, we are left with half of the book, representing the
same problem we started with fundamentally
69 | P a g e
We can keep repeating this process until we’re down to one page with
Mike’s number on it
Phonebook Algorithm
1 pick up phone book
2 open to middle of phone book
3 look at names
4 if Smith is among names
5 call Mike
6 else if Smith is earlier in book
7 open to middle of left half of book
8 go back to step 3
9 else if Smith is later in book
10 open to middle of right half of book
11 go back to step 3
12 else
13 quit
Pseudocode
This example algorithm is code, not written in a programming language, but rather English
This is called Pseudocode
o Code-like syntax written in English
o Numbered lines to maintain order and reference lines
o pick up, open to, look at, call, open, and go back are functions
o if, if else, and else are conditions
o Smith is among names, Smith is earlier in book, and Smith is later in book are
Boolean expressions
Can be either true or false
If these are true, the indented code below is executed
o Both line 8 and 11 say to go back to step 3
This creates a loop
Doing the sane thing again and again
Programming Constructs
These constructs of loops, Boolean expressions, functions, and conditions as well as others
such as variables, threads, events, and more are common across all programming languages
C
70 | P a g e
C is one of the oldest programming languages that someone might still write in
#include <stdio.h>
int main(void)
{
printf("hello, world/n");
}
Some of this syntax may look cryptic, but you can likely guess what it does
o It prints “hello, world” to the screen
o The other details can be learned
Just like with written human languages that are foreign, you just haven’t
learned the patterns yet
Many programming languages have similarities, so it becomes easier to learn new ones
with knowledge under your belt
Ultimately, programming is about writhing software to control hardware to solve a problem
However, computers only understand binary (0’s and 1’s)
o Source code what we humans write and it can be converted into machine code (0’s
and 1’s)
This is achieved by using a program called a compiler
This allows a human to write the code and a machine to read and run it
C++
#include <iostream>
int main()
{
std::out << "hello, world" << std::endl;
}
This program written in C++ still prints “hello, world”
Many programming languages do the same things differently
o We can solve the same problem using any different number of languages
o It could be easier to use one programming language for a specific problem
Different languages were invented to tackle different kinds of problems
Python
print("hello, world")
71 | P a g e
o A special program called an interpreter converts the source code into an
intermediate language called byte code
Which is not machine code (0’s and 1’s)
2 0 LOAD_GLOBAL 0 (print)
3 LOAD_CONST 1 ('hello, world')
6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
9 POP_TOP
10 LOAD_CONST 0 (None)
13 RETURN_VALUE
o The interpreter reads this one line at a time
The takeaway from this is that there different ways of doing the same thing in many
different languages
o And languages get used in different ways!
o Sometimes you need to compile code, sometimes you need to interpret code
At the end of the day, the consumer interacts with the software in the same way
o They don’t need to know what language it’s written in as long is it run on their
computer
Programs are often packaged differently for different operating systems
class Hello
{
public static void main(String [] args)
{
System.out.println("hello, world");
}
}
Ruby
Lisp
JavaScript
console.log("hello, world")
Introducing Scratch
Each of these languages have a lot more features, but they have commonalities
o Functions, loops, conditions, Boolean expressions, variables, threads, etc.
To focus on these ideas in a graphical manner, we’ll explore Scratch
In the earlier Oscartime example, trash was moving down the screen
o A screen is just a grid of pixels
72 | P a g e
o To make animation, we move an image on it slightly
If done quickly, it looks like movement
To make the trash stop at the bottom of the screen, we use some Boolean expression and
condition
o “If you’re touching the bottom of the screen, stop moving”
o Or “Only if you’re not touching the bottom of the screen, keep moving”
When trash is put in the can, the lid lifts and Oscar counts the pieces of trash disposed of
o The sprite for Oscar is using a variable
Initialized (set initially) to 0
Increments (adds 1 to the variable) for each piece of trash
o A condition is also used here
“If a piece of trash is added, then increment the variable for trash pieces”
The music was playing in some kind of loop
Even though this program is complex enough to take 8 hours to make, it’s ultimately built
with the same fundamental building blocks of conditions, loops, etc.
hello, world in Scratch
73 | P a g e
This says “hello, world” forever
74 | P a g e
This is an example of how to specify things conditionally
Scratch allow you to programing by piecing together puzzle pieces with shapes that imply
what to do
Scratch Interface
Scratch is not only a language but a programming environment as well
75 | P a g e
On the left is Scratch the cat in a 2D world with height and width
o Can change background and more sprites to this world
The blank slate on the right is where we can drag and drop the puzzle pieces and connect
them in order to instruct Scratch to do things
when green flag clicked is equivalent to the start of your program
o The green flag button starts, the red stop sign button ends
When we drag blocks together, the edge of the block glows white to signify they connect
The hello, world Scratch program won’t stop until we click the red stop sign as we never
told Scratch to stop in the script
76 | P a g e
Sounds
We can also add sounds
Loops
If we want Scratch to do something repeatedly, we can use loops
fit
77 | P a g e
The sound repeats so quickly they
overlap
This one plays the sound until done before the next cycle in the loop
Animation
I want the cat to move back and forth forever
This moves the Scratch the cat forward (to the right) until he hits the edge
78 | P a g e
Scratch will now rotate 180° if touching the edge of the screen
Another bug!
We can record custom sounds under the sounds tab and add it
79 | P a g e
Breaking Down Problems
Its much easier to write complex programs if you start out by breaking them down into
their component parts
When this program starts, nothing happens until the mouse pointer touches the cat, in
which the cat meows
80 | P a g e
don’t pet the cat
Will play a lion’s roar if the mouse pointer touches the cat, but will meow and wait 2
seconds if not
counting sheep
It will forever say counter for 1 second, wait one second, then increment the counter
81 | P a g e
Ultimately, this will count forever
cough0
We can create our own puzzle pieces
82 | P a g e
cough1
We can improve this with loops
Better design as we can change what the cat is saying or the wait time in one place
Cough2
What if I just want a puzzle piece to make any sprite cough?
83 | P a g e
o We’ve defined a new block called cough
For example, the say block takes in an argument of “hello, world” or some
other phrase
The evolution of this program is an example of what it’s like to program and solve
problems
84 | P a g e
Threads
In Scratch, we can have multiple sprites, each with their own scripts
bird:
85 | P a g e
o Will keep moving around if not touching the cat
o Forever checks if touching the bird and moves towards the bird
If touching the bird, a lion’s roar will play and the script will stop
If we increase the movement speed of the bird to 6 steps, it still gets caught
If we increase the movement speed of the cat to 10 steps, the bird stands no chance!
Events
A computer can do multiple things at a time due to multithreading
o Now that computers have multiple cores, they can literally do two things at once
o However, computers are so fast that even if two things are technically not
happening at the same time, we can’t notice the difference
86 | P a g e
This sprite (an orange puppet) will forever check for the spacebar being pressed
o If this happens, the sprite will say “Marco!” for 2 seconds and broadcast event
When the green flag is clicked, the orange puppet will wait for the spacebar and then tell
the other sprite when to say “Polo!”
This idea allows two sprites to interact in such a way that one sprite does something only if
the other does something first
87 | P a g e
Closing Thoughts
Programmers in the real world don’t typically program by dragging and dropping code
blocks
o Functional programming
Even in all these different ways of programming, we are still utilizing the same basic
building blocks we’ve explored in Scratch
Forever loops make the trash fall, an if conditions to raise the lid of the
trash, etc.
o https://en.wikipedia.org/wiki/List_of_programming_languages
o A programmer typically has one or a few languages that the reach for to tackle a
problem
They are easier to learn than spoken or written languages as the ideas persist
88 | P a g e
W3-Exam
89 | P a g e