Unit 2 Test

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Primitive data types

Data types that are built-in.

Selection

Deciding which part of an algorithm to run based on whether a condition is true or false.

Application Program Interface (API)

Documents what a programmer needs to know about using a library: it's a description of each procedure's purpose, inputs, and outputs (but not its algorithms).

Constructor

It constructs one example of the data structure. By naming the pieces of the structure, the ______ makes it certain that every time you use it, you build the structure in the right order.

What does this block do? (Combine list using list)

It takes two inputs: a list and an operation with two inputs, and it reports the result of combining all the elements in the input list using the input operation.

Which of the following expressions will report true?

(V and X) and (not (V and X)

There's no built in ≤ block in Snap!. Suppose we wanted to build one. Which two of the following Boolean expressions are equivalent to the expression ( num<_23)?

(num<23) and (num=23) not (num>22)

What value will this script report? Set m to 9 Set k to 5 Set m to (m+1) Set k to (k-m) Report k

-5

What is the value of (11 MOD 2+3)

1

What will the sprite say if you run the same function with the input 1? Mystery function Input # If (Input<5) Repeat until (Input=5) say Input for 1 secs set Input to (Input+1) Report finished

1 2 3 4

What value will this code display? a ← 3 b ← a a ← 4 DISPLAY(b)

3

What will be displayed as a result of running the code segment given? inputList ← [3, -1, 2, 10, -5] FOR EACH item IN inputList { IF(item > 0 AND item * item > 4) { DISPLAY(item) } }

3, 10

What will be returned if the code above is run? PROCEDURE Mystery(numberList, targetNumber) { counter ← 0 FOR EACH number IN numberList { IF(number > targetNumber) { counter ← counter + 1 } } RETURN(counter) } myMathGrades ← [100, 80, 90, 80, 60, 100, 50, 100] Mystery(myMathGrades, 60)

6

Variable

A box that can hold one value at a time, such as one word, one costume, or one list.

Software Library

A collection of procedures that can be used in programs.

Abstract data types

A custom data type that's meaningful to your program. It's not built into the language; you develop it as you code.

It says to make a global variable. This is not a script variable. What is the difference in the two variables?

A global variable is a variable that is usable by all scripts in the program and script variables are a kind of local variable; they work only within the script where they're created.

Predicate

A hexagon-shaped reporter that asks a true/false question.

Sublist

A list as an item of another list.

Boolean Value

A value named after George Boole,who invented the branch of mathematics dealing with Boolean operations (such as and, or, and not).

Global Variable

A variable that is usable by all scripts in the program.

Bug

An error in the code that makes the program behave differently than expected.

Nested Conditional Statement

An if or if else statement inside the else part of another if else statement.

Element

Another name for an item in a list. (If the same value is in the list twice, that counts as two different elements.) Each ______ has a unique index (position) in the list.

Which inputs to mystery function will report "finished"? Mystery function Input # If (Input<5) Repeat until (Input=5) say Input for 1 secs set Input to (Input+1) Report finished

Any integer

Local Variable

Can be set or used only in the environment in which it is defined. This term includes inputs to procedures and variables created by the for or script variables block.

Traversing

Looking at each item of the list.

When will "Error. Invalid entry." be displayed? PROCEDURE greaterThanOrEqualTo(a, b) IF(a > b) { RETURN(true) } ELSE { RETURN(a = b) } DISPLAY("Error. Invalid entry.") }

Never

Initializing

Setting the starting value of a variable is known as ______ the variable.

What palette contains the "mouse down?" block?

The Sensing palette.

Data Abstraction

The creation and use of abstract data types in a program.

Conditionals

The if and if-else blocks are called this because they control the code based on a true-or-false condition.

Domain

The input type of a function is the type of data that it accepts as input.

Range

The output type of a function is the type of data that it reports as output.

Index

The position number is called the ______ of the item in the list.

What will happen if you run the same function with the input 9? Mystery function Input # If (Input<5) Repeat until (Input=5) say Input for 1 secs set Input to (Input+1) Report finished

The sprite will say nothing, and the block will report "finished."

Selectors

They each select one piece of the data structure.

Composition

Using the result from item as the input to address from contact.

Data type

What kind of data something is (number, text string, list, etc.).

Imagine you make a variable capitals and use set to give this list of lists a name: Choose all that apply

all but first of item last of capitals item 1 of item 1 of capitals item 1 of capitals

Which of the scripts below will produce the following sprite behavior? (When you run the script, though, it actually says Abraham Lincoln only once.) Choose all that apply

for each item of list Abraham Lincoln say item for 1 secs say item 1 of list Abraham George Barack for 1 secs say item 1 of list Lincoln Bush Obama for 1 secs

Algorithms that look the same may have different results. The following incomplete code fragment was designed to test if number is odd: IF (MISSING CONDITION) { DISPLAY "It is odd." } Which of the following can be used in place of the MISSING CONDITION?

number MOD 2=1


Kaugnay na mga set ng pag-aaral

Logistics Midterm Study Questions Mahesh

View Set

Other Federal and State Regulations

View Set

Cognitive Science Chapter 12 & 13

View Set

Trådløs kommunikasjon naturfag

View Set

owners + masters [frederick douglass]

View Set

Class 2 (sem 2) - Digestive system (part 2)

View Set