Apply Today to our Software Engineering Program & check out our scholarships!

Back-End Try Coding: Pre-work

Back to Curriculum Index

Introduction

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.

πŸ‘©πŸ½β€πŸ’» Materials: It is ideal that you work through this on a laptop or desktop computer. Everything can be done inside a browser with an internet connection.

πŸš€ 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.

Screenshot of code in previous example, inside the replit platform

πŸ‘‰πŸ½ 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.

πŸ–πŸΌ If you need help or want to feel confident in your work, here is a working solution.

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:

first_name = "Maya"
puts first_name
puts first_name
puts first_name

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.

Screenshot of code in previous example, inside the replit platform


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!

πŸ–πŸΎ If you need help or want to feel confident in your work, here is a working solution.

If the desired result is not printing to the console, or, if you are seeing an error message, here are some go-to strategies to problem solve:

If repl is working very slowly, try to refresh the page. It works best in the Chrome browser.

Make sure you are using double quotes.

Check the spelling and capitalization of your variables. The variable names must be exact matches!

Submission

To Do

You did it πŸŽ‰ We hope you had some fun learning about the building blocks of Ruby - this is a great foundation!

Please complete the form below so we have a sense of where you are with the material so far and can customize the workshop to your needs.