We are excited you will be joining us for an upcoming Try Coding workshop. If youβve found yourself on this page and are not yet signed up for one, you can sign up here!
Completing this pre-work will set you up for success in our virtual classroom - making sure that everyone feels comfortable with the tools we will use and a bit of foundational knowledge.
β°Time: Most participants share that this work took them between 25-35 minutes to complete.
πGoal: Work through the materials so you are prepared to engage at your workshop. Then, complete the submission form at the bottom of this page in order to get the zoom link for your scheduled workshop!
Set Up
To Do
repl.it provides an online platform that allows us to write code and see the results almost immediately - all inside of one browser tab! There are many other similar (and awesome) tools available; we feel this is the best choice for the Try Coding workshops.
π¬ Please watch this short screencast (no sound) for an introduction on how to navigate repl.it:
β Since we'll be using repl.it during the workshop, please create a free account with them at this time. Then, create a repl as shown in the video. You don't need to type any code in it just yet.
Learn: Part 1
To Do
Ruby is a Back-End programming language. It was written with a focus on simplicity and productivity, so is a great language for beginners!
Programming languages need a way to classify the various types of data they work with. Ruby works with the 3 data types defined below:
String
A String is a series of characters (alpha, numeric, or symbol) between quotation marks.
"Hello, World!"
"12345"
Integer
An Integer is a number without decimals. Basic math operations can be performed on them.
137
3 + 7
Boolean
A Boolean refers to a value that is either true or false. You can think of it as an on/off switch.
true
false
Ruby provides a command that allows us to print out the data we are working with the the console. It's a tool for learning and troubleshooting, but isn't usually included in the final code of an app. Click here to see the code and output.
ππ½ This may not feel very exciting now, but it will be a useful tool as we move forward!
You Try
In your repl.it, "puts" several values out to the console. Run the file and observe the output.
Now, instead of using the puts command, use print. Observe the difference in the output.
Since puts and print are both for learning and troubleshooting, you should use the one you prefer! You may choose one over the other in different situations. There is no "best practice", but it's good to know that both exist.
Learn: Part 2
To Do
We can use variables to store and reference information within a Ruby program. We can think about it as a storage bin in the garage - the contents inside of the bin are what we care about storing, and the label on the outside is how we can quickly identify it.
The syntax for declaring variables and assigning a value to them is as follows:
first_name = "Maya"
age = 34
is_signed_in = true
After declaring a variable, we can reference the variable name as many time as we want/need to:
Note that the variable first_name uses an underscore character to separate the two words. This is called snake case π and is a Ruby convention.
Many times, information within a program will change, so we will need to re-assign the value of a variable. The screenshot below was taken after this repl.it file was run.
String Interpolation
String Interpolation allows us to create more dynamic and customized information for our users. Instead of telling you exactly what it does and how it works, we're only providing the syntax. You may be able to predict what the code will do just by reading through it. In the next activity, you will use that syntax and be able to see the result for yourself!
first_name = "Maya"
age = 34
puts "Hello! My name is #{first_name} and I am #{age} years old."
You Try
In the same repl file you were working in earlier, declare two variables.
Then, puts or print a sentence that uses those two variables with String Interpolation!