Computer Programming Semester 1 Exam

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

In the following code, we define two variables, xPos and yPos, and use them to draw a rectangle: var xPos = 10; var yPos = 5; rect(xPos, yPos, 10, 10); At what x position is the rectangle drawn?

10

In the following code, we define two variables, w and h, and use them to draw an ellipse and a rectangle: var w = 20; var h = 15; rect(10, 10, w, h); ellipse(10, 10, w, h); How tall is each one of the shapes?

15

Imagine the following program that draws two rectangles, where the variables width1 and width2 keep track of the widths of the two rectangles, and width2 is dependent on width1: var width1 = 12; var width2 = 2 * width1 + 5; rect(50, 50, width1, 10); rect(50, 80, width2, 10); If we change the initial value of width1 to 6, what will be the numeric value of the expression stored in width2?

17

In the following code, we define a variable and use it to draw a rectangle: var rectWidth = 20; rect(10, 10, rectWidth, rectWidth); How wide is the rectangle?

20

In this program, the value of b is dependent upon the value of a and the value of c is dependent upon the value of b. The println() statement prints the result of the expression that is passed to it: var a = 25; var b = a / 5; var c = b + 30; println(b + c); What will the above program print?

40

After running this code: var x = 5; What is the value of x?

5

In the following code, we define a variable and draw three shapes - a rectangle and two ellipses: var xPos = 55; rect(10, 20, 30, 40); ellipse(xPos, 20, 15, 30); ellipse(xPos, 10, 20, 30); At what x position are the ellipses drawn?

55

Let's say we have a program that draws a simple face and body with ellipses. It uses two variables, one for body size and one for face size: var bodySize = 100; var faceSize = 50; ellipse(200, 200, bodySize, bodySize); ellipse(200, 150, faceSize, faceSize); If we want to make faceSize dependent on bodySize, so that faceSize is always one-half bodySize, what expression should the faceSize variable store instead?

faceSize = bodySize/2

This program draws a rectangle based on the variables w (for width) and h (for height): var w = 10; var h = 50; rect(200, 200, w, h); Let's say we want to make h dependent on w, so that if we ever change the value of w, the value of h will change proportionately, so that h is always 5 times as large as w. What expression should h hold?

h=5w

Let's say we have a program that draws an ice cream cone (a triangle) with two scoops of ice cream (two ellipses) on top of it. The second scoop is slightly smaller than the first, and we have two variables, scoop1 and scoop2, to keep track of the scoop sizes: var scoop1 = 40; var scoop2 = 30; triangle(200, 250, 180, 200, 220, 200); ellipse(200, 180, scoop1, scoop1); ellipse(200, 145, scoop2, scoop2); If we want to make scoop2 dependent on scoop1, so that scoop2 is always 10 pixels smaller than scoop1, what expression should we store in the scoop2 variable?

scoop1 - 10

The following program draws two boxes, a big one and a small one. The variables big and small keep track of the sizes of the two boxes: var big = 100; var small = 10; rect(100, 100, big, big); rect(100, 100, small, small); We want to make small dependent upon big, so that they keep the same proportion when we change them - small should always be 1\10​​ the size of big. What expression should small store?

small = big / 10


Set pelajaran terkait

Elimination PrepU N400 Fall 2021

View Set

Sorting Algorithms - Selection, Bubble, Insertion

View Set

Caught-In or -Between Hazards (OSHA-10)

View Set

SG 24; vascular surgery, SG 23; shock, Chest tubes, SG 22; pituitary, SG 21; thoracic, SG 20 - PTSD, anger, substance abuse, SG 19 - Adrenal, SG 18 - cardiac surgeries, SG 17 - MI, SG 16 cardiac disorders, SG 15 suicide, mass disasters, SG 14 pancrea...

View Set

chapter 4, 5 & 6 quizzes combined

View Set

Chapter 9.4 (U.S History) "Progressivism Under Taft"

View Set

BTS 147 Ch 7 - Presentations Using Tables and Pie Charts

View Set