comp sci unit 3

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

symbol for modulus in JavaScript

%

symbol for multiplication in JavaScript

*

symbol for addition in JavaScript

+

symbol for subtraction in JavaScript

-

programs are expressed to (4)

-Express creativity -Satisfy personal curiosity -Create new knowledge -Satisfy a common need

types of variables (3)

-number (integers or floats, aka whole numbers or decimals) -boolean (true or false) -string (goes between quotes)

symbol for division in JavaScript

/

36 % 6 = ____

0

how can we tell something is a callback function (2 ways)

1. mouseClickMethod(drawCircle); the fact that there is no second set of parenthesis after the drawCircle function 2. when you name the function to define it in a separate function, and there is an e, this stands for even handler

11 % 12 = ____

11

11 % 13 = ____

11

code to make a circle (format)

Function start(){ Var circle = new Circle (radius) circle.setColor (Color.blue); circle.setPosition(xPos, yPos); add(circle); }

code to make a rectangle (format)

Function start(){ var redRect = new Rectangle(width, height); redRect.setPosition(xPos, yPos); redRect.setColor(Color.red); add(redRect); }

code to make text (format)

Var text = new Text(label); text.setPosition (xPos, yPos); add(text);

what is code

a way of converting information as symbols

Consider the following code segment. a ← 1 b ← a a ← 2 what is stored in variable b? a. 1 b. 2 c. a d. 3

a. 1

What will c evaluate to in the following code segment? a ← 17 b ← 5 c ← a MOD b a. 2 b. 3.4 c. 3 d. 5

a. 2

what will the following code segment evaluate to? a ← 9 b ← 5 c ← 4 expression = a + b * c DISPLAY(expression) a. 29 b. 56 c. 29.0 d. 56.0

a. 29

what will appear on the console after the following code segment is run? function start{ var num = 7; var pet = "cat"; println("I have" + num + pet +"s"); } a. I have7cats b. I have 7 pets c. I have 7 cats d. I have num pet s

a. I have7cats

What is a callback function? a. a function passed to an event handler that is called every time a certain event happens b. A function called at the bottom of the start function c. A function that is never called d. A function called every 20 milliseconds

a. a function passed to an event handler that is called every time a certain event happens

what function do you need to call to ask the user of the program to enter text? a. readLine b. readln c. text d. println

a. readLine

__________________ are self contained step by step set of instructions to solve a problem

algorithms

what symbol do you use to do division in JavaScript? a. % b. / c. // d. *

b. /

What will the following code segment evaluate to? a ← 10 b ← 5 c ← 2 expression = (a - b) * c DISPLAY(expression) a. 0 b. 10 c. -10 d. -5

b. 10

What will the following code segment evaluate to? a ← 10 b ← 5 c ← 2 expression = a / b * c DISPLAY(expression) a. 1 b. 4 c. 2.5 d. 25

b. 4

what will the following code print to the screen? println(2+2); a. 2 + 2 b. 4 c. 22 d. nothing

b. 4

What function do you need to call to get the width of the screen? a. width() b. getWidth() c. screenWidth() d. getScreenWidth()

b. getWidth

what is the proper function to call print to the screen? a. write b. println c. PRINT d. post

b. println it will in the code show up at: println("text here");

what keyword do you need to use to define a variable in javascript? a. variable b. var c. int d. x

b. var it will show up in the code as: var name = "Joe"; println("My name is " + name); var yourObjectHere = amount or name

What symbol do you use to do multiplication in JavaScript? a. x b. X c. * d. #

c. *

consider the following code segment a ← 10 b ← 5 c ← a + b what is stored in variable c? a. 10 b. 5 c. 15 d. 50

c. 15

Consider the code segment below. DISPLAY ("What is your name?") name ← INPUT () DISPLAY ("Hello ") DISPLAY (name) What is displayed as a result if the user inputs "Karel" to the program? a. What is your name? Karel Hello Karel b. What is your name? Karel HelloKarel c. What is your name? Karel Hello Karel d. Hello Karel

c. What is your name? Karel Hello Karel

What are the coordinates of the top right corner of the screen? a. 0, 0 b. 0, getWidth() c. getWidth(), 0 d. getWidth(), getHeight()

c. getWidth(), 0

Suppose we've written a function drawCircle that we want to call every time the mouse is clicked. How can we do this? a. mouseClickMethod(drawCircle(e)); b. if(mouseClickMethod){ drawCircle(); } c. mouseClickMethod(drawCircle); d. mouseClickMethod(drawCircle());

c. mouseClickMethod(drawCircle);

In the following code, we create a circle and add it to the screen. What is the meaning of the x variable? var x = 20; var circle = new Circle(x); add(circle); a. the color of the circle b. the diameter of the circle c. the radius of the circle d. the position of the circle

c. the radius of the circle

what is program/software

computer readable code

What will happen when the following program is run? function start(){ drawSquare(40,40,20); //sideLen, x, y } function drawSquare(sideLen, xPos){ var square = new Rectangle(sideLen, sideLen); square.setPosition (xPos,yPos); add(square); } a. A square with a side length of 40 units will be drawn on the canvas at position (40,20) b. A square with a side length of 40 units will be drawn on the canvas at position (40,0). c. A square with a side length of 20 units will be drawn on the canvas at position (0,0). d. The program won't run because there is an error in the function definition.

d. The program won't run because there is an error in the function definition.

to ask the user of the program for a number, which function should you use? a. readLine b. readInt c. readFloat d. both readInt and readFloat are for numbers

d. both readInt and readFloat are for numbers

After the following code segment is run, what will be printed on the console? function start{ var a = 2; var b = 7; var c = 5; b = a; c = a + b; println("c = " + c); } a. c=5 b. c = 9 c. c = 5 d. c = 4

d. c = 4

Which of the following is the correct JavaScript syntax for printing a line to the output screen. a. println "Hello World"; b. PRINT("Hello World"); c. println(Hello World); d. println("Hello World");

d. println("Hello World");

__________________ is always the height of the canvas

getHeight()

__________________ is always the width of the canvas

getWidth()

__________________, at a high level, implement algorithms

programs

format for inputting a variable

readLine(prompt) readInt(prompt) readFloat(prompt)

what is a modulus

to divide and take the remainder

a __________________ is like a box that can hold a value

variable

define increment and decrement and show format

x++ adds one, x-- subtract one


संबंधित स्टडी सेट्स

Ch. 12: Misc. Commercial Policies

View Set

Chapter 2 SmartBook Summer 2024 FIN 215 - V1 Financial Management

View Set

Head and Neck anatomy final exam questions

View Set

Chapter 2 - Handling & Restraint

View Set