1D

Part 1D: Quorum Computer Language (2)

This part will cover two more Quorum commands. Then all the commands you have learned so far will be used in a computational thinking exercise. The link to the PDF containing the text file of commands is below:

Quorum Commands Section 1 Part D – PDF

 A) COMMAND: input

It would be helpful to have a way to input data to the computer. To do this, we use a function called input, which is a mini program that is built into Quorum. For built-in functions like “input”, the computer goes to a Quorum library to learn what to do.
Chris describes this in the following 1:04 video:

Let’s try this example, typing it exactly as below. You may use any open Quorum Box, or the link to the Quorum Box listed below. Arrange the windows for your vision. Delete previous code if needed.

Link to a Quorum Box

     text telescope = input(“What telescope would you like to use?”)

The right side tells the computer to go to the Quorum library and use the mini function for input. This mini function then tells the computer to display, in a pop-up window, a box for the user to type their answer to  whatever asked. The left side tells the computer to store whatever the user types in the input box to a text variable named telescope.

What command should come next in order to see or hear what the user typed? Add that command to the Quorum Box.
When you run your program in Quorum, you can input your answer with any of the actual Skynet telescopes discussed previously.
***************************

Now it’s your turn to come up with an input statement.

  • Change the first line to a different question within the quotes.
  • Change the variable name ‘telescope’ to whatever makes sense.

*** When you change the name of the variable, what else will you have to change in the rest of the code?

TEXT STRINGS

Above, you simply had the computer output the variable name ‘telescope’. We can make this more user friendly by stringing words and variable names together in an output statement like you did in the Go Code game.
Type into the Quorum Box the same input statement you used above about telescopes:

      text telescope = input(“What telescope would you like to use?”)

Then output (or say) a text statement that starts with something like “You have chosen”
Use a + sign after the text in quotes to include the variable name.
Select RUN when you are satisfied.

 B) COMMAND: cast

Chris describes the cast command in this 2:16 video

 

Sometimes we will want the computer to interpret the input text as a number instead of text. To do this we use a command called “cast”. It will change one variable type into another. Type the statement below into a Quorum Box to familiarize yourself with the format. You will be using this command several more times in upcoming parts.

      number seconds = cast(number, input(“How long would you like to set the exposure for?”))

This can be translated (or read as): The text input for the question is “cast”(or changed) to a number variable called “seconds”. Notice there are two sets of parentheses.

Come up with a numeric question for a user to input, for example, “How old are you?”, and cast the user’s input into a number or integer.

Then output (or say) a user friendly statement that includes the numeric answer.

 C) Using Computational Thinking

Tyler, our asteroid astronomer, discusses the meaning of computational thinking.

 

The following computational thinking exercise uses the Quorum commands you have learned so far: output, say, input, and cast. You will also use what you have learned about the four types of data variables, the operations on these variables, and your knowledge of how to string text and variables together into user friendly output statements.

EXERCISE:

A study done in 1996 by P.A. Bland, estimated 18,000 to 84,000 meteorites larger than 10 grams (about the weight of ten paperclips) strike the earth each year. This means there are many meteorites that make it to the surface of the Earth each night!
Using a Quorum Box do the following exercise:
1. What are the chances one of these meteorites would strike the roof of your house?

  • Find a partner or two and decide on how to formulate the problem in a way you can use a computer to solve it.

2. Make it user friendly with good input statements and output statements. You will need to decide on what variables will be needed and how to use them.

3. As an added challenge, make this program work for these asteroids striking any planet or moon in the solar system.

**Teachers/Leaders: You can find help and example scripts for different levels of learners for this exercise here:

Script Resource

Answer the following questions in your journal:

a) How many variables of each type did you use?
b) What was the hardest part of this coding problem?
c) What did you need to change to make it work for anything in the solar system?
***************************