Font size
WorksheetsCSP CMU Unit 2 - Student Created Questions
Total questions: 62
Worksheet time: 27mins
What do you call the inputs of a fuction while defining it?
Arguments
Function call
Parameters
Label
Which AP Vocab term is defined as the inputed variables of a procedure?
Parameters
Arguments
Body
Calling
def drawOval(size, color):
Oval(200,300,size,size,fill=color)
In the code above what is the function name?
drawOval
(size,color)
def
(200,300,size,size,fill=color)
How do you run a function named foo with no parameters in python?
foo()
foo(a)
foo(a,b)
foo
Why should your parameter names be concise and descriptive?
So that you and others who review your code can understand what it does
for fun
because it is the law
python will give you an error if you do not.
What is a function?
(select all correct answers)
A function is a named group of programming instructions that may have parameters and return values
A function is input variables of a procedure
A function groups together a sequence of statements that we can run when we want
Functions specify the values of the parameters when a procedure is called
What does a function do?
A. Explains the information inside the parenthesis when coding a shape.
B. Groups together a sequence of statements that can run on command
C. Acts as the pseudocode to make it easier to identify errors in the code
What is a named group of programming instructions that may have input variables and return values?
a. parameter
b. argument
c. function
d. definition
Which of the following are the input variables when you define a procedure?
parameters
arguments
functions
test cases
Where will we find a test case in our code?
At the top of the program
on lines that start with hashtags (#)
any time after the function that we are testing is defined
Anywhere in our code
What are the parameters in this code?
drawSquare
width, height, size, color
50,50,100,'red'
b and c
What is the function name of this:
def drawTurtle(color):
A. def
B. drawTurtle
C. color
Which value represents the radius of a star?
Star(5*, 5, 5, 5)
Star(5, 5*, 5, 5)
Star(5, 5, 5*, 5)
Star(5, 5, 5, 5*)
What is the most accurate definition of debugging?
1) To remove a/multiple bug(s) within your code
2) To add a bug to your code
3) To fix a syntax error
4) To fix a logical error
Why do we use functions in coding?
(select all correct answers)
functions can help us reduce the size of our code
functions always makes our code more complex
functions allow us to reuse code and break down our logic into smaller parts
functions help us to identify bugs in our code
What keyword must we use as the first word when we create a function?
func
go
run
def
What symbol do you use to multiply?
A. X
B. \
C. *
D. !
In order to create a function, you must use which of the following terms?
A: Def
B: Define
C: def
D: function
What will be the center of the following shape?
Circle(50 + 50 * 2, 300 / 3 + 100, 50)
(150,200)
(200,200)
(150,100)
(200,250)
Which function statement is correct?
def onMousePress(X, Y):
Circle(X,Y,10, fill='red')
def onMousePress():
Circle(50,40,10, fill='red')
def onMousePress:
Circle(50,40,10, fill='red')
def onMousePress(X,Y)
Circle(X,Y,10,fill='red')
If you forget the colon after the parenthesis in your function definition
what kind of error will you receive?
Function with no parameters
Logical
Stack Trace error
Syntax
What happens when you define a function with no parameters?
You will not receive an error because functions do not have to have parameters.
You will receive a syntax error stating that the parameters are missing.
You will receive a runtime error when the code tries to run the function with no parameters.
You will receive a logical error stating that you have a mismatch of parameters.
In every function, the code must start with....
Def
<functionName>
def
#
True or False? Functions must include a parameter.
True
False
Which symbol indicates division?
/
%
*
^
Which fact about parameters is false?
a) Parameters are optional
b) parameters are input variables of a procedure
c) parameters are the same thing as an argument
d) parameters must have a matching argument when the function is called
in the code "def drawCircle(radius, color):" what is the function name
a. drawCircle
b. radius, color
c. def
d. def drawCircle(radius, color):
What is onMouseMove?
a function that is called when the mouse is released
a function that is called that prints squares where the mouse is pressed
a function that is called when movement of the mouse is detected
a function that is called when the mouse is pressed and held as we move the mouse
Which one is the correct name of a mouse press function?
OnMousePress
mouseWasPressed
MousePress
onMousePress
Are functions and parameters case sensitive?
yes
no
sometimes
Which is the correct format for the function definition?
Def onMousePress(X, Y):
def onMousepress(X, Y):
def onMousePress(X, Y):
def onMousePress(X.Y):
what is the definition of a argument
a global variable that can be called anywhere in the program
variable used in the body of a procedure
the inputted values of the parameter when a procedure is called
How do you use the inspector when using a onMousePress or onMouseRelease function?
1. by hovering over the shapes
2. by looking at the console
3. by pressing down the space bar
4. by pressing the control/ctrl button and hovering over the shapes
Which of the following draws a circle where you click your mouse?
(ignore incorrect indenting)
a. def mouseWasPressed(x, y): Circle(x, y, 20)
b. def onMousePress(mouseX, mouseY):
Circle(mouseX, mouseY, 20)
c. def onMousePress(mouseX, mouseY):
Circle(X, Y, 20)
Which expression could be used to move a shape upwards
when using the function onMousePress?
(x, y+number)
(x, y-number)
c. (x+number, y)
d. (x-number, y)
Fill-in-the-Blank: Arguments must ___ be passed in the same order of parameters.
A. Always
B. Never
C. Sometimes
Which of the following activates something on when you click your mouse
onMouseClick
onMouseDrag
onMouseHold
onMousePress
What can an expression include?
value
Variable
Operator
A procedure call that returns a value
All of the above
A function is the same thing as a procedure.
True
False
What are the arguments in this code
drawSquare
width, height, size, color
50,50,100,'red'
Rect(width,height,size,size,fill=color)
Packets are _____.
Small chunks of information that have been carefully formed from larger chunks of information.
Small packages.
Physical boxes delivered from one computer to another.
None of the above.
A number assigned to any item that is connected to the Internet.
DNS Address
HTTP Address
TCP
IP Address
An easy-to-remember address for calling a web page (like www.code.org).
TCP
HTTP
URL
IP
An easy-to-remember address for calling a web page (like www.code.org).
TCP
HTTP
URL
IP
Having multiple backups to ensure reliability during cases of high usage or failure is __________.
Protocol
Network Redundancy
ASCII
Router
A set of rules governing the exchange or transmission of data between devices.
Protocol
Transfer
Pattern
Phone Call
A way of representing information using only two options.
Binary
Decimal
Hexadecimal
Octal
8 bits
Byte
Nibble
Kilobyte
Megabyte
Error from attempting to represent a number that is too large.
Overflow Error
Roundoff Error
Logic Error
ASCII
This color model uses varying intensities of (R)ed, (G)reen, and (B)lue light added together to reproduce a broad array of colors.
RGB
Hex
ITP
LOC
A process for reducing the number of bits needed to represent something without losing any information. This data compression algorithm allows the original data to be perfectly reconstructed from the compressed data. This process is reversible.
Lossless
Lossy
Tailored
Parallel
A process for reducing the number of bits needed to represent something in which some information is lost or thrown away. This data compression method uses inexact approximations, discarding some data to represent the content. Most commonly seen in image formats like .jpg. This process is not reversible.
Lossless
Lossy
Tailored
Parallel
It is the exclusive legal right that a creator has to reproduce, publish, sell, or distribute his/her intellectual property (literary, musical, or artistic work).
Intellectual Property
Open Source
Copyright
Creative Commons
how many binary bits are required to store the decimal number 27?
4 bits
5 bits
6 bits
7 bits
An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences?
2 more items can be uniquely identified.
10 more items can be uniquely identified.
2 times as many items can be uniquely identified.
10 times as many items can be uniquely identified.
What is the best explanation for why digital data is represented in computers in binary?
The binary number system is the only system flexible enough to allow for representing data other than numbers
As a consequence of history: early pioneers of computing were making secret codes in binary, and this simply evolved into modern computing
It's impossible to build a computing machine that uses anything other than binary
It's easier, cheaper, and more reliable to build machines that only have to distinguish between two binary states
The binary number 1001 is equal to what in decimal?
1,001
17
8
9
With 8 bits of data, what is the largest decimal number that can be represented in binary?
256
1111 1111
255
1000 0000
A computer uses 3 bits of data to represent a number. What is the smallest number that would cause an overflow error in this situation?
4
7
8
9
An artist makes an RGB raster image in which each pixel color is encoded with 12-bits --- 4 bits each for red, green and blue.Which of the following correctly shows the hexadecimal value for Red as a 12-bit representation.
F00
00F
FF00
FF0000
How many bits are needed to represent 8 colors?
8 bits
24 bits
1 hex digit
3 bits
Consider the following three binary numbers:
01010
010000
1110
Which of the following lists the numbers in order from least to greatest?
010000
1110
01010
01010
1110
010000
01010
010000
1110
1110
01010
010000
