Font size
WorksheetsUnit 3 Lessons 1-9 (APCSP Code.org)
Total questions: 88
Worksheet time: 2hrs 44mins
1. What does a “FOR LOOP” do? What is the variable, “I”, used for?
a. FOR LOOP repeats a function for a set number of times; I is the number of times repeated
b. I is a parameter of the function, and for only performs an action if certain circumstances are met
c. The FOR LOOP is a function and I the absolute value of the function
d. The FOR LOOP controls the order functions are called on outside of the for loop; I is the number of functions it controls
1. When is a good time to use a parameter?
Choice A: When you need to repeat the same line of code multiple times without re-writing it each time
Choice B: When you need to change the height, length, or size of something you are coding
Both A and B
Neither A nor B
moveForward() is an example of this:
Parameter
Function
Conditional
Library
This is a type of code that allows you to repeat a certain code over and over again without having to manually put it in.
Function
Parameter
Loop
API
A collection of commands made available to a programmer:
Algorithm
Manual
API
AIG
A particular kind of looping construct provided in many languages. Typically, it defines a counting variable that is checked and incremented on each iteration in order to loop a specific number of times.
NOW LOOP
IF LOOP
FOR LOOP
IF/NOW LOOP
A collection of commands / functions, typically with a shared purpose:
Documents
File
Library
Folders
An extra piece of information that you pass to the function to customize it for a specific need:
Packets
Parameter
Chunk
Data
This is known as a precise sequence of instructions for processes that can be executed by a computer and are implemented using programming languages.
Function
Parameter
Algorithm
Command
In the first lesson of the unit, you came up with a clear and precise set of instructions for building a Lego arrangement. These instructions that you were trying to create would be considered an example of an algorithm.
True
False
Which of the following is FALSE regarding algorithms?
Option 1: Different algorithms can be developed to solve the same problem
Option 2: Different code can never be written to implement the same algorithm
Both Option 1 and 2 are true
Both Option 1 and 2 are false
Every algorithm can be constructed on using:
Sequencing
Selection
Iteration
Questions
Which of the following is NOT an example of a high-level language?
JavaScript
Human Machine Language
Java
C++
Which of the following is FALSE on why programming languages have functions?
Enables programmers to write code in larger, more logical chunks
Enables programmers to write code in smaller, less logical chunks
Enables programmers to reuse code segments
Streamlines code into shorter, but more readable (understandable) sequences
When your programming is achieving some desired outcome while minimizing wasted effort or resources, we would say that its:
Top Notch
Comparable
Efficient
Problematic
Looking at the coding that takes place above, why are these functions an example of abstraction?
Creating the code above helps you think of your code at a higher level, making sure you don't get lost in all the little details
You are able to "box up" and name the code necessary to draw the rectangle
Once the function has been tested and it works, you don't have to worry about the details of how it works anymore
All of these choices are true
In creating the snowflake you see above, which of the following function names would probably NOT be used in your code?
drawSnowflake()
drawBranch()
drawCross()
Any of these three (functions can be named however you want)
Which of the following functions are named properly and as such, would more than likely be acceptable for your code?
MyAmazingFunction()
#my1AmazingFunction()
1AmazingFunction()
my1AmazingFunction()
Which of the following is FALSE regarding functions?
Function definitions should appear at the bottom of the program
Using an underscore in a function name is acceptable
Most function names cannot begin with a symbol or number
Called functions should appear at the bottom of your program
An example and appropriate use of camel casing in your function names would be FunctionName()
True
False
Looking at Lines 3 and 5 above, the "IF" statements in these particular parts of the algorithm are constructed with:
Selection
Iteration
Sequencing
Placing Lines 1-9 of your algorithm in a particular order shows which of the following is important?
Sequencing
Selection
Iteration
Looking at the image above, looping (through iteration) can be seen in which of the following lines of this algorithm?
Line 2
Line 7
Line 3
Line 9
You've learned that programmers obviously don't memorize all of a particular programming language. Which of the following is FALSE on how programmers use all of a particular language?
Programmers might read new code in helping to write old code
Through the use of references built into the program programmers are using (such as ABI)
Asking other programmers for help
Through the use of online or print resources
Which of the following are FALSE regarding creating comments in your coding?
These blocks of code do not change your program
They allow you to share your coding with other programmers
Allows you to create notes about the current code that you may want either you or another programmer to look at in the future
You should always start off a comment with backslashes \\
Which of the following would NOT be an example of a parameter you could insert into one of your functions?
Width of a pen you are using
Value of Red, Green, or Blue in RGB
Using "Show" or "Hide" with your Pen
Number of degrees with a left arc
Which of the following is CORRECT in the way the parameters should be separated for the arcLeft() command?
arcLeft(360;50)
arcLeft(360,50)
arcLeft(360/50)
arcLeft(360.50)
When using the penRGB(r,g,b,a) command, what is the highest value you can use for either red, green, or blue?
64
144
255
256
When using the penRGB(r,g,b,a) command, what type of parameter does "a" represent?
The color black
Opacity
Pen weight
Amount of dashes in a line
In order to draw the square you see above without using moveForward() and turnLeft(), use the moveTo() command.
True
False
When would you use loops over functions in your code?
A: When you need repetitious behaviors to solve some sort of problem
B: When you want to manually call functions many times in a row
Both A and B
Neither A nor B
Which of the following is FALSE regarding the above image?
A Loop was used here because an action takes place over and over again without a predetermined ending
A ForLoop was used here because there is a predetermined beginning, ending, and increment
Ambiguities in natural language necessitate the creation of a more precise language - a programming language- for controlling computers
True
False
Compared to the number of words in a natural language, the number of defined words in a programming language is very small.
True
False
There are many possible ways to interpret an instruction written in a programming language.
True
False
Which of the following is not true about functions?
Functions are reusable programming abstractions
Functions can reduce complexity of writing and maintaining programs
Functions cannot make calls to other functions within the same program
Once defined, a function can be called many times from different parts of the program.
Which of the following would be a well-named function IF we are following all important naming conventions?
#drawStar()
Drawstar()
DrawStar()
drawStar()
Two functions in a single program can have different names but contain identical code.
True
False
Which of the following will call the function drawStar?
drawStar;
function drawStar( ){
for (var i = 0; i < 5; i++{
moveForward(100);
turnLeft(36);
}
}
function drawStar;
drawStar( );
To use turtle drawing to form the letters of the word "GAMETIME" you would be better off to write
A loop
Function(s)
To create a turtle drawing of a octagon (eight-sided shape), it would be most efficient to write
A loop
A function
To use turtle drawing to draw 100 tiny dots in a line, it would be best to use
A loop
A function
Using turtle drawing to create a circle of any size at a given point on the screen, it would be best to write
a Loop
a Function
Why are parameters useful when programming?
Parameters change the order of operations within a function.
Parameters help teams of programmers because they define the problems they are trying to solve.
Parameters allow for more flexible, generalized behaviors in functions.
Parameters determine the number of times a function will run.
When programmers work together, what is an example of an abstraction in programming that can promote collaboration?
Team members can rely on one another to explain their code.
Programmers can write functions without needing ot know what they do or how they should work.
Programmers can use functions created by others, relying on the functionality without knowing details of how the function works
In order for programmers to work together, they must be in the same room.
Which of the following best describes one of the benefits of using an iterative and incremental process of
program development?
It allows programmers to implement algorithmic solutions to otherwise unsolvable problems.
It eliminates the need for programmers to test completed programs.
It enables programmers to create programs that use the lowest-level abstractions available.
It helps programmers identify errors as components are added to a working program.
What do parameters used in a procedure provide?
A way to get values into the procedure, making the code more flexible
A way to return values calculated in the procedure back to the calling program
A way to call a procedure from within another procedure
A way to connect an API to the procedure
A collection of commands made available to a programmer
ASCII
Heuristic
API
DNS
An extra piece of information passed to a function to customize it for a specific need
Parameter
Library
Function
Block
The action of doing something over and over again.
Sequencing
Loop
Agregation
Iteration
What is displayed as a result of running the program?
Foxtrot
Hotel
November
Yankee
Which of the following best characterizes a high-level programming language?
A language comprised entirely of hardware logic gates
A language in which each instruction corresponds directly to an instruction in a computer’s machine code
A language that is easy for a computer to interpret but difficult for humans to interpret
A language that uses multiple abstractions to manage complexity
A student wants to create an algorithm that can determine, given any program and program input, whether or not the program will go into an infinite loop for that input. The problem the student is attempting to solve is considered an undecidable problem. Which of the following is true?
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm can only be implemented in a low-level programming language.
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm requires simultaneous execution on multiple CPUs.
It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm will not run in reasonable time.
It is not possible to create an algorithm that will solve the problem for all programs and inputs.
PROCEDURE MoveTriangle (numMoves, numTurns)Which of the following instructions will get the red triangle to the gray square?
{
REPEAT numMoves TIMES
{
MOVE_FORWARD()
}
REPEAT numTurns TIMES
{
TURN_RIGHT()
}
}
MoveTriangle (1, 1) MoveTriangle (1, 1) MoveTriangle (3, 1) MoveTriangle (3, 0)
MoveTriangle (4, 1)
MoveTriangle (4, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 1)
MoveTriangle (3, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 3)
MoveTriangle (3, 0)
Starting in the bottom left corner facing right, where will the robot end up after the following code is called with: controlRobot([2, 1, 3, 6])?
The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing right. Which of the following code segments will move the robot to the gray square?
A problem solving approach (also known as stepwise design) in which you break down a system to gain insight into the sub-systems that make it up.
Top Down Design
Function
Variable
Why are these icons a good use of abstraction?
They tell us what they mean without needing to use the name
They are difficult to understand
They don't explain what they are
