FOC Quiz questions

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

What symbol do you use to do multiplication in JavaScript?

*

What symbol do you use to do division in JavaScript?

/

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

// This is a comment

How many times should you call the start function in a program?

0

How many times should the start function be defined in a program?

1

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

1

Suppose we used an Internet Addressing protocol that used 4 bits to encode a single address. How many devices would be supported on the Internet? How many unique addresses would there be?

16

An IPv4 address has 32 bits, so there are 232 (over 4 billion) possible IPv4 addresses. Since the Internet is gaining devices quickly, we will soon surpass 232 unique devices on the Internet. In anticipation of all the new Internet devices, we are in the process of switching to IPv6, which uses 128 bits for a single address. That's 96 extra bits to represent one address! Which of the following statements correctly describes how many more addresses will be possible to represent by switching from IPv4 to IPv6?

296 times as many addresses can be represented with IPv6 Answered

How many times should Karel turn left in order to turn right?

3

What will the following code print to the screen? println(2 + 2);

4

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

6

What is an avenue in a Karel world?

A column

What is the Internet Protocol (IP)?

A protocol that defines the structure of an Internet address and assigns a unique address to every device on the Internet

What is a street in a Karel world?

A row

What information is contained in a packet?

A small part of a digital message, and metadata about the message, including where it came from and where it is going Answered

What is a code comment?

A way to give notes to the reader to explain what your code is doing

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

For loop

You need to write a program that has Karel move 6 times and then put a ball. Which control structure do you need to use?

For loop

Why should a programmer indent their code?

Helps show the structure of the code Easier for other people to understand Indenting is a key part of good programming style All of the above

Why does a programmer indent their code?

Helps show the structure of the code. Easier for other people to understand. A key part of good programming style!All of the above

Which of the following is an example of a 'runtime error'? I. Karel crashing into a wallII. Leaving a semicolon off the end of a commandIII. Using the wrong syntax in an if/else statementIV. Not closing all open brackets

I

What is wrong with this for loop? for (var i = 0, i < 10, i + 1) { move(); }

I and II

Consider the following network diagram: Each box represents a device connected to the network, each line represents a direct connection between two devices. Which of the following statements are true about this network: I - The network is fault tolerant. If one connection fails, any two devices can still communicate.II - Computers C and E need to first communicate with at least one other device in order to communicate with each other.

I only

Which of the below are examples of control structures? (I) if (II) if/else (III) while (IV) for

I, II, III, and IV

Which of the following statements are true about the Internet? I - The Internet connects devices and networks all over the worldII - The Internet helps people collaborate to solve problemsIII - The Internet helps people communicateIV - There are no negative consequences of the Internet, it is purely positive

I, II, and III

Which of the following are true about Internet routing? I - For any two points on the Internet, there exists only one path between the two pointsII - Routing on the Internet is fault tolerant and redundant

II only

You need to write a program that has Karel move if the front is clear, but if it isn't clear, Karel will do nothing. Which control structure do you need to use?

If Statement

You need to write a program that has Karel put down a tennis ball if Karel is not able to move forward in the direction they are currently facing. Which control structure do you need to use?

If Statement

You need to write a program where Karel will take a ball if there is a ball present, otherwise Karel should put down a ball. Which control structure do you need to use?

If/Else statement

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

Karel ends one spot above a tennis ball facing East.

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

The go function has been defined twice

Which of the following is NOT a benefit of pair-programming?

Code takes 15% less time to write than with a solo programmer.

What do we use control structures for in JavaScript?

Control the flow of the program; how the commands execute.

How can we teach Karel new commands?

Define a new function

Which of the following best explains what happens when a new device is connected to the Internet?

An Internet Protocol (IP) address is assigned to the device.

How is the bandwidth of a network measured?

Bitrate. Higher bitrate means higher bandwidth.

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

Both readInt and readFloat are for numbers. Answered

Why do we use functions in Karel programs?

Break down our program into smaller parts Avoid repeating code Make our program more readable All of the above

Why do we use functions in programming?

Break down our program into smaller parts Avoid repeating code Make our program more readable All of the above

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

Called 3 times, defined 1 time

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

Karel moves until it is on a ball

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

Karel will crash into a wall

If the following program is supposed to put down three tennis balls, where is the logic error? 1 function start() { 2 placeThreeBalls() 3 } 4 5 function placeThreeBall() { 6 for (var i = 0; i <= 3; i++) { 7 putBall(); 8 } 9 }

Line 6

Will the following program move Karel one space, pick up three tennis balls, then move forward and put down three tennis balls? function start() { move(); tennisBalls(); move(); tennisBalls(); } function tennisBalls() { for(var i = 0; i < 3; i ++) { if(noBallsPresent()){ putBall(); } else { takeBall(); } } }

No, because the tennisBalls() function has an incorrect if/else statement. Answered

A city government is attempting to reduce the digital divide between groups with differing access to computing and the Internet. Which of the following actions is LEAST likely to be effective in this purpose?

Putting helpful tips for operating computers on the city government website

If Karel is facing North and the code turnLeft(); turnLeft(); runs; which direction is Karel facing now?

South

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

Street 1, Avenue 3, Facing North

If Karel starts at Street 1 and Avenue 3 facing East, what street (row) and avenue (column) will Karel be on after this code runs? move(); move(); move(); turnLeft(); move();

Street 2 and Avenue 6

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

Street 3, Avenue 3, Facing East

Which of the following is a benefit of the fault-tolerant nature of Internet routing?

The ability to provide data transmission even when some connections between routers have failed

What is the bitrate of a system?

The amount of data (in bits) that can be sent in a fixed amount of time

Two computers are built by different manufacturers. One is running a Web server and the other is running a Web browser. Which of the following best describes whether these two computers can communicate with each other across the Internet?

The computers can communicate directly because Internet communication uses standard protocols that are used by all computers on the Internet. Answered

A user enters a Web address in a browser, and a request for a file is sent to a Web server. Which of the following best describes how the file is sent back to the user?

The file is broken into packets and sent over a network. The packets must be reassembled by the user's computer when they are received. If any packets are missing, the browser re-requests the missing packets.

Why is the following command an invalid Karel command? turnleft();

The l should be a capital L

What is the latency of a system?

The time it takes for a bit to travel from sender to receiver

What is the role of the driver in a pair-programming setting?

They control the mouse and keyboard

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

This code won't run because of a syntax error

What is the purpose of the Digital Millennium Copyright Act?

To criminalize the act of circumventing, or getting around, access controls that block access to copyrighted works.

Why do we use if statements in JavaScript?

To do something only if a condition is true

Why do we use if/else statements in JavaScript?

To either do something if a condition is true or do something else

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

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

Why do we use while loops in JavaScript?

To repeat some code while a condition is true

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

To repeat something a fixed number of times

What is the function of the Domain Name System (DNS)?

To translate domain names into IP addresses

What is top down design?

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.

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

Use a for loop to repeat the move command

You need to write a program that has Karel take all the tennis balls where Karel is standing if there are any there. Karel should end up with no tennis balls on that spot. Which control structure do you need to use?

While Loop

According to the Domain Name System (DNS), which of the following is a subdomain of the domain example.com?

about.example.com

According to the domain name system (DNS), which of the following is a subdomain of the domain example.com?

about.example.com

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

ballsPresent()

Is the following statement true, or false: Everyone in the world has internet access.

false

What is the best way for Karel to move 10 times?

for (var i = 0; i < 10; i++) { move(); }

Which function will teach Karel how to spin in a circle one time?

function spin() { turnLeft(); turnLeft(); turnLeft(); turnLeft(); } B

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

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

What can be used to teach Karel to turn right?

functions

What does an if/else statement look like in JavaScript?

if (condition) { //code } else { //code } D

Which general if statement definition is written correctly?

if(condition) { //code } B

The following code contains an error. What line is it on? 1 function start() { 2 move(); 3 move(); 4 turnRight(); 5 putball(); 6 move(); 7 } 8 9 function turnRight() { 10 turnLeft(); 11 turnLeft(); 12 turnLeft(); 13 }

line 5

Which of the following commands is a valid Karel command?

move();

Which of these is a valid Karel command?

move();

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

println

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

readLine

What commands does SuperKarel know that regular Karel does not?

turnAround() and turnRight()

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

turnLeft()

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

var

Which general while loop definition is written correctly?

while (condition) { //code } D


Set pelajaran terkait

Module 3 PrepU Question Collection Assignment

View Set

Top Reasons for Business Failure

View Set

SBAC Week 5 Geometry Vocabulary Circles

View Set

Chapter 6: Asians/Asian Americans

View Set

MA Office Financial Management, Billing, Insurance

View Set