Code world 101
Coding is the art of using robots to solve problems.
Today we are going to train computers to do our bidding!
What can code do?
Code has impacted our world so heavily, that it's difficult to remember what it was like without them.
Let's take a look at what the world looked like before code.
A world long forgotten...
Twenty years ago, magazines were all the rage. And it was wonderful!
Whether you liked gardening, video games, or celebrity gossip, the industry's best editors and writers would write fresh content and mail it to you every month.
It was the best way to get the latest news and updates.
Until the internet came and destroyed the industry...
How to use code to engineer addiction
The internet solved the problem of distributing data. Now we can blast a message to the universe from anywhere in the world.
We don't need writers to create content.
The world will write for us.
We don't need editors to cultivate the best content.
The world will edit for us.
Social media tracks every behavior as users watch recommended videos. Then, with the information the app tracks, it maps out your personality — highlighting emotions such as sadness, happiness, and apprehension and other hobbies.
They use this information to cultivate an endless stream of content that you want to look at. Something human beings would never be able to do.
Achievement unlocked: Coders have engineered addiction.
With great power comes great...
Computers have become so powerful that people have begun to question its ethics.
Are algorithms manipulating the masses?
Are algorithms too effective? Meaning, are we stuck in an echo chamber?
Is social media causing depression?
Should AI be allowed to generate hate speech?
Code has become so powerful, that we can no longer just ask if we "could", we need to ask if we "should". These questions are what the coders of tomorrow must struggle with.
Note: The Spiderman statue on the right does not exist. That picture was generated by AI using the prompt "Spiderman in Ancient Rome".
Why learn coding?
The power to change the world is why companies are desperate for coders. Once you cross a certain threshold, you don't look for jobs, the jobs look for you.
Here are just some of the benefits to coding:
Not physical. Easier on the body.
Don't like a software? Make your own.
Origins. The Ancient Roman statue that influenced Stan Lee to create Spiderman.
Airbnb HQ. Imagine working here.
When it comes to writing code, there are 4 basic lines of code.
Today we are going to learn the first 2.
The coder's weapon
IDEs are like Microsoft Word for coders. It's what we use to write code. Today we are going to use Replit.
If you did not create an account yet, do that now.
Replit Live Demo
How to create a Replit.
How executing a program is like double-clicking an app.
Step #1: It speaks!
We want computers to do work for us, but we have to start small.
Like a monkey on his first step in evolution, the first thing we need to do is get computers to talk.
Copy and paste this code into your Replit.
The text in between the quotations is what gets printed! This data type is called a String.
[Definition] String - text in a series of characters
Add the second line of code to your page. This shows you how we add code line by line.
Your turn! So far we got the computer to print 2 lines of text.
Now add the 3rd!
Print a fish!
Step #2: Creating memory
Now that our computers can talk to us, we need them to remember stuff. Hope you remember your algebra math, because we using variables!
Disclaimer: Don't worry if you aren't good in math. Despite the myth, you don't need to be good at math to do coding. You only need to know the basics.
Copy and paste this code into your Replit. The code below has two print() statements. One where "name" has quotes around it and one that doesn't.
Predict what each print() statement will display.
name = "Michael Jackson"
Answer: When there's no quotation marks, then we are printing a variable. For the code above, that is the String "Michael Jackson". When there are quotation marks, we are literally printing the word "name".
Now, we are going to work with numbers. Copy and paste this code into your Replit.
goals = 24
Notice with numbers, we don't have quotation marks around it. Quotation marks are for Strings. Numbers don't need it.
Fix the bug! Why doesn't this code work? Answer is below:
points = 24
Answer: Variable names are case-sensitive. They need to match exactly! Update the code so that it works!
Paste this code into Replit. Print the variable points to see the total. Answer is below:
goals = 42
assists = 13
points = goals + assists
Answer: To print variable points, add the last line.
goals = 42
assists = 13
points = goals + assists
We can even use variables to combine Strings! Print the variable compound_word.
first_word = "black"
second_word = "board"
compound_word = first_word + second_word
Add these two words together. It should print "greenhouse".
first_word = "green"
second_word = "house"
Calculate how many days in 12 years. It should print 4380.
year = 12
Calculate how many inches in 5 feet. It should print 60.
Fix the bug! Help us fix this code so that it prints 3.375.
distance_to_vegas = 270
average_speed = 80
total_time = distance / speed
Extra credit: Starting from the code below, calculate how many hours are in 12 years. It should print 105120.
years = 12