Skip to content

8. Use Coding to Help Solve Problems

Playback Speed:

In this activity, you researched lots of data to make an informed decision about housing options.

You used a spreadsheet to record, organize, and graph the information you found.

Then, you used the script editor to pull a location from your spreadsheet and calculate the distance between it and a point of interest.

As you found, if a function or equation that you want to use does not already exist in Google Sheets, you can use programming to create whatever you need.

For example, maybe you want to insert a map into a Google Doc, but you don’t want to take a screenshot or save an image.

You could code a program to: Create a sidebar that appears in Google Docs; Retrieve a map from Google Maps; and Insert that map as an image inside your document.

You can write a program to automate almost any any repetitive task or to streamline a cumbersome process.

There are lots of resources online that can help you find code for programs like this.

To write your program in this activity, you used several Variables.

Computer programs use variables to store all kinds of information.

If you have taken algebra, variables function kind of like the “X” in an equation.

They are placeholders for values that may change.

In video games, variables keep track of your score.

In a parking garage, a variable stores the number of cars and displays “Full” when there are no vacant spaces.

And at the grocery store, a variable holds the total of the items you are purchasing.

Once you’ve added a variable to your code, you can reference it repeatedly.

With variables, you can use spreadsheets and computer code in similar ways.

For example, if you wanted to send a message letting everyone know their club dues balance, you could do that with functions in a spreadsheet like this one.

In this sheet, the columns store: A person’s name; An amount they owe; And the payment due date.

A spreadsheet function takes the values in those columns and creates a complete message.

You could perform the same action by coding.

This code defines variables for names; Amount owed; And payment due date.

Now, the code logs the same message as the spreadsheet.

When you have a problem to solve--like calculating values or sharing information with lots of people--remember that there are often many ways to solve it.

If a function you want is not available, figure out how to code it yourself!

Next arrow_forward