Activecode Exercises

Answer the following Activecode questions to assess what you have learned in this chapter.

Construct a block of code that prints: “Lions &” one the first line, “Tigers & Bears!” on the second line, and “Oh my!” on the FOURTH line.

Below is one way to write the code to print one separate lines.

Construct a block of code that swaps the value of integers x and y, which have values 3 and 6, respectively.

Below is one way to write the code to declare and swap these variables.

Dan Humphrey is a 3.98 student at Constance High School. His crush’s first initial is S. Construct a program that assigns the variables name, GPA, and crush, in that order. Output the variables to the terminal to check your code.

Below is one way to write the code to assign the variables.

You decide to make homemade Mac ‘n’ Cheese for you and your roomates. Whoever wrote the recipe wanted to make things hard for you by stating that it calls for 1% of a gallon of milk. Construct a block of code that converts this to tablespoons. Use the variable name ‘tbsp’ for the final tablespoons conversion.

Below is one way to write the code to convert units to tablespoons.

Construct a block of code that takes the ‘volume’ of the rectangular prism defined by length, width, and height and prints the result to the terminal. The volume of a rectangular prism is given by Volume = length * width * height. Use a length of 2, width of 3, and height of 4.

Below is one way to write the code to define variables, find volume and print results to the terminal.

Construct a block of code that changes the value of the variable a from the character ‘a’ to the character ‘z’. Remember that number values can be used with characters and operations.

Below is one way to write the code to change the value of the character variable.

Construct a block of code that outputs the volume of a cylinder with a radius of 3 and a height of 4. The formula for volume of a cylinder is V = (pi)(r^2)(h). Use 3.14 for pi.

Below is one way to write the code to output the volume of the cylinder.

Construct a block of code that assigns the string “MATH” to a variable and prints “My favorite class is MATH” on the same line.

Below is one way to write the code to output the string.

It’s Black Friday and the Nintendo Switch you’be been saving up for is marked down to 60% of its original price! Construct a block of code that calculates and outputs the variable moneySaved, which is how much money you’d be saving if the system originally costed $359.99?

Below is one way to write the code to calculate your savings.

Your family just bought a dog and everyone has been fighting over what to name it. It went from Champ to Copper to Higgins, and after a few days of being Higgins, everyone agreed on Buddy. Construct a block of code that illustrates this concept.

Below is one way to write the code to illustrate the dog’s name change process.

You have attempted of activities on this page