Section 1

Preview this deck

Which of the following is the proper format for an HTML tag?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (98)

Section 1

(50 cards)

Which of the following is the proper format for an HTML tag?

Front

<h1>Content Affected by Tag</h1>

Back

Suppose you have the following CSS rules: p { color: green; } .fire { color: red; } #title { color: blue; } What font color will the following HTML element have after being styled by the given CSS: <p class="title">My First Paragraph</p>

Front

green

Back

In the following code below from the Cleanup Karel example, what is the purpose of If Statement #2? // This program has Karel walk down the // row and clean up all of the tennis balls // on the way. function start() { while (frontIsClear()) { // If statement #1 if (ballsPresent()) { takeBall(); } move(); } // If statement #2 if (ballsPresent()) { takeBall(); } }

Front

To pick up the ball that is in the last spot, if there is one

Back

How many total times will Karel move in this program? function start() { move(); for (var i = 0; i < 5; i++) { move(); putBall(); } }

Front

6

Back

In this code, how many times is the dance function called and how many times is it defined? function start() { move(); dance(); move(); move(); turnLeft(); dance(); dance(); } function dance() { turnLeft(); move(); turnLeft(); turnLeft(); move(); turnLeft(); }

Front

Called 3 times, defined 1 time

Back

What makes the following command an invalid Karel command? turnleft();

Front

The l should be a capital L

Back

Suppose you have the following CSS rules: p { color: green; } .fire { color: red; } #title { color: blue; } What font color will the following HTML element have after being styled by the given CSS: <p class="fire" id="title">Hello World!</p>

Front

blue

Back

What function do you need to call to get the width of the screen?

Front

getWidth()

Back

Which of the following is not a valid condition to go in an if statement for Karel?

Front

turnLeft()

Back

What function do you need to call to ask the user of the program to enter text?

Front

readLine

Back

What is the proper format for a single line comment in Karel?

Front

// This is a comment

Back

Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs? move(); putball(); move(); move(); move(); move(); move();

Front

This code won't run because of a syntax error

Back

Which of the following is the proper HTML code to display an image on your webpage?

Front

<img src="https://upload.wikimedia.org/wikipedia/commons/6/62/Big_and_little_dog.jpg">

Back

What's wrong with this code? function start() { move(); go(); go(); } function go() { move(); move(); } function go() { move(); move(); }

Front

The go function has been defined twice

Back

How can we teach Karel new commands?

Front

Define a new function

Back

Super Karel starts at Street 1, Avenue 1, facing East in a 5x5 world. What will happen after this code runs? move(); move(); turnRight(); move();

Front

Karel will crash into a wall

Back

What symbol do you use to do multiplication in JavaScript?

Front

*

Back

Why do we use functions in Karel programs?

Front

All of the above

Back

Karel starts at Street 1 and Avenue 1, facing East. After calling the stairStep function twice, where will Karel be and what direction will Karel be facing? (assume this is a SuperKarel program and the world is 10x10 in size) function stairStep() { move(); turnLeft(); move(); turnRight(); }

Front

Street 3, Avenue 3, Facing East

Back

What is the purpose of using a for loop in code?

Front

To repeat something a fixed number of times

Back

Suppose you are making a music streaming website and you want to make a page that displays a user's music library. Which of the following is the proper HTML code to create the following table:

Front

<table border="1"> <tr> <th>Title</th> <th>Artist</th> <th>Length</th> </tr> <tr> <td>CD Jam</td> <td>Rooney Pitchford</td> <td>3:55</td> </tr> <tr> <td>Memory</td> <td>Tom Misch</td> <td>5:41</td> </tr> </table>

Back

What is the domain of this URL: www.example.com/home.html

Front

www.example.com

Back

CSS rules have a selector that defines which HTML elements the rule applies to. We've learned about the following CSS Selectors: Select by tag name Select by class name Select by id name Which of the following ranks the selectors from highest precedence to lowest precedence?

Front

Select by id name, select by class name, select by tag name

Back

Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?

Front

For loop

Back

Which of the following is a valid CSS rule?

Front

h1 { color: blue; }

Back

Suppose you have the following CSS rules: p { color: green; } .fire { color: red; } #title { color: blue; } What font color will the following HTML element have after being styled by the given CSS: <h1 class="fire">Welcome!</h1>

Front

red

Back

What does the mystery function do? function mystery() { while (noBallsPresent()) { move(); } }

Front

Karel moves until it is on a ball

Back

What is generated from the following HTML code: <h1>Hello</h1> <h3>Hello</h3> <h6>Hello</h6>

Front

Hello (Large) Hello (Medium) Hello (small)

Back

If Karel starts at Street 1 and Avenue 1, facing East, where will Karel be, and what direction will Karel be facing after running the following code? (Assume the world is 10x10 in size) move(); turnLeft(); putBall(); turnLeft(); turnLeft(); turnLeft(); move(); turnLeft();

Front

Street 1, Avenue 3, Facing North

Back

Which of the following statements are true about styling your web pages with CSS: I. Styling with CSS is more scalable than using style= on each HTML tag that you want to style II. You can create styles with CSS that are not possible using style= on an HTML tag

Front

I only

Back

Suppose you have written a web page using HTML and CSS and it is hosted at the URL yourdomain.com/home.html Which of the following statements is true about which devices can view your website?

Front

Any browser on any device will be able to view your webpage, because all browsers and devices on the Internet agree to use the same protocols for sending, receiving, and viewing webpages.

Back

What is top down design?

Front

Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.

Back

o ask the user of the program for a number, which function should you use?

Front

Both readInt and readFloat are for numbers.

Back

Which of the following classifies as metadata about a webpage?

Front

The title of the webpage

Back

What symbol do you use to do division in JavaScript?

Front

/

Back

What is the result of the following HTML code: <ol> <li>Bread</li> <li>Milk</li> <li>Eggs</li> </ol>

Front

1. Bread 2. Milk 3. Eggs

Back

What are the coordinates of the top right corner of the screen?

Front

getWidth(), 0

Back

What will the following code print to the screen?

Front

4

Back

What condition should be used in this while loop to get Karel to pick up all the tennis balls on the current location? while (________) { takeBall(); }

Front

ballsPresent()

Back

What keyword do you need to use to define a variable in JavaScript?

Front

var

Back

Which of the following commands is a valid Karel command?

Front

move();

Back

In the following code, what would be a good Postcondition to write? /* Precondition: Karel is on a spot with a tennis ball facing East * Postcondition: ... */ function getOnTop() { turnLeft(); move(); turnRight(); }

Front

Karel ends one spot above a tennis ball facing East.

Back

How can we improve the following program? function start() { move(); move(); move(); move(); move(); move(); move(); move(); move(); }

Front

Use a for loop to repeat the move command

Back

Say Karel is on a location with one tennis ball. After the following code runs, how many tennis balls will there be at that location? for (var i = 0; i < 3; i++) { if (ballsPresent()) { takeBall(); } else { putBall(); putBall(); } }

Front

1

Back

Which of the following is the correct way to define a turnRight function in Karel?

Front

function turnRight() { turnLeft(); turnLeft(); turnLeft(); }

Back

What is the proper function to call to print to the screen?

Front

println

Back

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);

Front

The radius of the circle

Back

Why does a programmer indent their code?

Front

All of the above

Back

Which of the following best describes the difference between the domain and path of a URL?

Front

The domain specifies where the browser's request should be sent. The path specifies exactly what file is being requested.

Back

What is wrong with this for loop? for (var i = 0, i < 10, i + 1) { move(); } A. The for loop uses commas instead of semicolons B. It should say i++ instead of i + 1

Front

A and B

Back

Section 2

(48 cards)

What symbol represents the or operator in JavaScript?

Front

||

Back

What is printed by the following program? function product(x, y){ return x * y; } function difference(x, y){ return x - y; } function start(){ var x = 2; var y = 5; var value1 = product(x, y); var value2 = difference(y, x); var result = difference(value1, value2); println(result); }

Front

7

Back

"It's a bird! It's a plane! No, it's Superman!" We want to write a function isSuperman that takes in two parameters isBird and isPlane and returns true if it is in fact Superman, and false otherwise. If it's not a bird and it's not a plane, it must be Superman. Which of the following functions is the correct implementation of isSuperman?

Front

function isSuperman(isBird, isPlane){ return !isBird && !isPlane; }

Back

What is the output of the following program?

Front

10

Back

Which of the following is correct loop and a half structure?

Front

while(true){ //code if(condition){ break; } //code }

Back

How many parameters go into the function sum, and how many return values come out of the function sum? function sum(first, second, third){ var result = first + second + third; println(first); println(second); println(third); return result; }

Front

3 parameters go in, 1 return value comes out

Back

In the following function printThreeTimes: function printThreeTimes(word){ println(word); println(word); println(word); } What is the parameter of the function?

Front

word

Back

We want to simulate constantly flipping a coin until we get 3 heads in a row. What kind of loop should we use?

Front

while loop

Back

What kind of statement allows us to run one block of code if one condition is true, and a separate block of code otherwise?

Front

if/else statement

Back

Why do we use constant variables?

Front

All of the above

Back

The following code continually asks the user for a password until they guess the correct password, then ends. But there is one problem. 1 var SECRET_PASSWORD = "karel"; 2 3 function start(){ 4 while(true){ 5 var password = readLine("Enter your password: "); 6 if(password == SECRET_PASSWORD){ 7 println("You got it!"); 8 } 9 println("Incorrect password, please try again."); 10 } 11 } Which of the following will fix this program?

Front

Add a break; statement after line 7 so that the program doesn't loop infinitely

Back

A store has 20 apples in its inventory. How can you store this information in a JavaScript variable?

Front

var numApples = 20;

Back

How many times will the following code print "hello"? for (var i = 3; i < 8; i++) { println("hello"); }

Front

5

Back

You are splitting up all of your apples equally between 3 people. Which statement below will calculate how many apples will be left over?

Front

var leftOver = numApples % 3;

Back

Which of the following is a good example of a proper constant variable name?

Front

var MAX_VALUE = 100;

Back

Which of the following returns a random number between 1 and 10?

Front

Randomizer.nextInt(1, 10)

Back

In the following code, what will be the last number to print to the screen before the program finishes? for (var i = 0; i < 10; i++) { if (i % 2 == 0) { println(i); } else { println(2 * i); } }

Front

10

Back

How can we check if a variable num is even?

Front

(num % 2 == 0) will be true

Back

What is printed by the following program? function printNumbers(two, one, zero){ println(two); println(one); println(zero); } function start(){ var zero = 0; var one = 1; var two = 2; printNumbers(zero, one, two); }

Front

0 1 2

Back

You want to read input from the user to know how many apples they would like to buy. Which statement should you use to read in a number from the user?

Front

var applesToBuy = readInt("How many apples would you like? ");

Back

In the following code: var MAX_NUMBER = 10; function sum(x, y){ var result = x + y; //Point A return result; } function start(){ var num1 = Randomizer.nextInt(0, MAX_NUMBER); var num2 = Randomizer.nextInt(0, MAX_NUMBER); println( sum(num1, num2) ); }

Front

result, x, y, and MAX_NUMBER

Back

What is the proper way to compare if two values are equal in a boolean expression in JavaScript?

Front

==

Back

What is the term for the value that signals the end of user input?

Front

sentinel

Back

The following program should draw a circle on the screen 1 function start(){ 2 var circle = new Circle(40); 3 circle.setPosition(getWidth() / 2, getHeight() / 2); 4 circle.setColor(Color.blue); 5 } But when we run this code, we don't see the circle. What is missing from our start function?

Front

We create the circle and position it correctly on the screen, but we never add it to the screen. We need to add the line add(circle); after line 4

Back

In a graphics canvas, what are the coordinates of the bottom right corner of the window?

Front

getWidth(), getHeight()

Back

How many times will the following program print "hello"? for (var i = 0; i < 5; i++) { println("hello"); }

Front

5

Back

How many times will this program print "hello"? var i = 10; while (i > 0) { println("hello"); i--; }

Front

10

Back

What is the value of the boolean variable canVote at the end of this program? var age = 17; var isCitizen = true; var canVote = age >= 18 && isCitizen;

Front

false

Back

What will be the value of sum after this code runs? var START = 1; var END = 4; function start(){ var sum = 0; for(var i = START; i <= END; i++){ sum += i; } }

Front

10

Back

After the following code runs, what is the value of isWeekend? var isSaturday = true; var isSunday = false; var isWeekend = isSaturday || isSunday;

Front

true

Back

What is printed by the following program? var numApples = 10; var numOranges = 5; if(numApples < 20 || numOranges == numApples){ println("Hello, we are open!"); } else { println("Sorry, we are closed!"); } println("Sincerely, the grocery store");

Front

Hello, we are open! Sincerely, the grocery store

Back

How many times will the following code print "hello"? for (var i = 0; i < 8; i += 2) { println("hello"); }

Front

4

Back

What is the proper operator for "not equals" in JavaScript?

Front

!=

Back

We want to position a Circle circle on our canvas to be at a random position, but we want to keep the entire shape on the screen. Which of the following will accomplish this?

Front

var x = Randomizer.nextInt(circle.getRadius(), getWidth() - circle.getRadius()); var y = Randomizer.nextInt(circle.getRadius(), getHeight() - circle.getRadius()); circle.setPosition(x, y);

Back

We want to print the phrase "CodeHS is the best" exactly 25 times. What kind of control structure should we use?

Front

for loop

Back

Why do we write functions?

Front

All of the above

Back

What is printed by the following program? var isRaining = false; var isCloudy = false; var isSunny = !isRaining && !isCloudy; var isSummer = false; var isWarm = isSunny || isSummer; println("Is it warm: " + isWarm);

Front

Is it warm: true

Back

What symbol represents the and operator in JavaScript?

Front

&&

Back

Which of the following is not a valid value for a boolean?

Front

yes

Back

How many times will this program print "hello"? var i = 50; while (i < 100) { println("hello"); }

Front

This code will loop infinitely

Back

How many times will the following program print "hello"? var i = 0; while(i < 10){ println("hello"); }

Front

This code will loop infinitely

Back

What statement can we use inside of a loop to end it?

Front

break

Back

What kind of statement allows us to run a block code only if a certain condition is true?

Front

if statement

Back

What is the last thing printed by the following program? var start = 30; var stop = 10; for(var i = start; i >= stop; i-=5){ if(i % 2 == 0){ println(i * 2); } else { println(i); } }

Front

20

Back

In the following code: var size = 20; var x = 100; var y = 200; var ball = new Circle(size); ball.setPosition(x, y); What is the meaning of the x variable?

Front

The x coordinate of the center of the circle

Back

What are the coordinates of the center of the window?

Front

getWidth() / 2, getHeight() / 2

Back

How many possible values can Randomizer.nextBoolean() return?

Front

2

Back

What is the output of the following program? function start(){ var x = 5; sumTo(x); println(x); } function sumTo(num){ var sum = 0; for(var i = 0; i <= num; i++){ sum += i; } println(sum); }

Front

15 5

Back