Computer programming lesson 3 quiz

Ace your homework & exams now with Quizwiz!

Describe working with boolean blocks.

A Boolean block has angled sides. This particular code block returns a value of true if the user has completed the action or false if they have not. Because of it's angled sides, a boolean block can only be embedded inside code blocks that contain an input area whose sides are also angled. Boolean is a term used to identify data that has one of two values: either true or false. To take advantage of a boolean block, you need to embed it into another code block that is designed to work with it.

What is a note with the Scratch board and LEGO WeDo Robotics kit?

A Scratch Board, also known as a PicoBoard, is a special piece of hardware that you can purchase from www.sparkfun.com and attach to your computer. Once it's attached, you can use the sensor board to collect and process environment- and user-provided input. You learn how to programmatically interact with and control Scratch Boards in Appendix C, "Interacting with the Real World," on the companion website. The LEGO WeDo Robotics kit is a construction set for young people that helps them learn the basic principles of robotic development. Using this kit, you can create robots and other sorts of creations equipped with a motor and sensors and then bring them to life by programming them with Scratch 2.0

Describe working with hat blocks.

A hat block is a code block with a rounded or curved top and a bump at the bottom, visually indicating that it can be snapped only on top of other stack blocks. They provide the ability to create event-drive scripts, which are ones that automatically execute when a specified event occurs. An example of an event is when the user clicks on the green Flag, then any script underneath is automatically executed. Script execution can also be triggered when the user clicks on a sprite. You can set this up by adding the code block "when this sprite clicked". Every sprite in an application can potentially have its own scripts. You can automate the execution of any or all of the scripts using hat blocks. In addition to sprite, the stage can have scripts.

Describe working with reporter blocks.

A reporter block is a code block that has rounded sides and is specifically designed as a mechanism for provided input for other code blocks to process. They have rounded side, so they can only fit into certain code blocks with rounded input fields.

Describe working with C blocks.

C blocks are shaped like and named after the letter C. C blocks are used to set up a loop of blocks within scripts that repeatedly execute for as long as a tested condition evaluates as true. Scratch has 5 different C blocks, all of which are control blocks. The "repeat until" block repeatedly executes any code blocks that you choose to embed inside it until a tested condition evaluates true.

Describe working with cap blocks.

Cap blocks halt the execution of scripts. They have a notch on top and a flat bottom, which signifies the end of a script. As such, you can't attach other blocks to the bottom of a cap block. An example is the stop all block.

List and describe the pen blocks

Clear- erases or clears away anything drawn by the pen or stamped from the stage Stamp- draws or stamps the image of a sprite onto the stage Pen down- places the pen in a down position, allowing drawing operations to occur as the pen is moved around the stage Pen up- disables the drawing operations by lifting the pen Set pen color to __(drop down)- specifies the color to be used when drawing Change pen color by __- changes the color used when drawing by a specified amount Set pen color to __- specifies the color to be used when drawing based on a numeric range in which 0 is red and 100 equal blue Change pen shade __- modifies the shading used when drawing by a specified amount Set pen shade to __-specifies the shade to be used when drawing based on a numeric range in which 0 is darkest possible shading 100 represents the maximum possible amount of light Change pen size __- modifies the thickness of the pen based on a numeric increment Set pen size to __- specifies the thickness or width of the pen used when drawing

Describe control

Control blocks, colored gold, are used to stop script execution, pause script execution, and conditionally execute other code blocks based on whether a tested condition evaluates as true. There are also control that let you setup loops to repeatedly execute collections of embedded code blocks. Scratch 2.0 provides several new code blocks that support the creation and management of clones. A clone is a temporary copy of a sprite that can be used to add instances of sprites to scratch projects when they execute.

Describe data blocks.

Data blocks come in two subcategories: those that deal with variables and those used to create and manage lists. Variable blocks store and retrieve string and numeric values. You need to use variables to store data as your applicatoin execute. Scratch 2.0 supports a new type of variable known as a cloud variable, which stores variables on Scratch server in the Internet cloud, allowing you save and retrieve data that can be accessed by all actively executing copies of the project. This facilitates the creation of project that do things like maintain a list of player high scores. You can use variables in conjunction with conditional programming logic to control the execution of other code blocks. You can use variables to control the repreated execution of code blocks embedded within code block loops. Variables blocks are colored orange. You can create and name custom variable blocks and assign them a starting value. You can also modify their values during script execution. Other code blocks can retrieve variable values and use them as input. List blocks store and retrieve lists of associated data. They are colored dark orange. A list is made up of one or more items, which work like variables except that when there is lots of data being stored, it is easier to work with lists to store and manage the data as a group rather than try to manage data collections as individual items. Lists are sometimes referred to as single-dimensional arrays in other programming languages.

Describe event blocks

Event blocks, which are brown, initiate the execution of scripts and send message to other sprites, allowing sprites to synchronize their execution. Scratch provides 8 different event blocks. Event blocks that initiate script execution are hat blocks whereas the blocks that send messages are stack blocks

List and describe the data blocks.

High score- a monitor block that retrieves the value assigned to a variable Set __ to __- assigns a value to numeric variable Change __ by __- modifies the value assigned to a numeric value stored in a variable by the specified amount Show variable __- displays a variable's stage monitor Hide variable __- hides a variable's stage monitor Top scores- a monitor block that retrieves a list's contents add __ to __- adds an item to the end of a list delete __ of __- removes an item from a list insert __ at __ of __-adds an item to a list at the specified location replace item __ of __ with __- replaces an item in a list based on the item's position within the list item __ of __- retrieves an item based on its specified position within a list Length of __- returns a value of indicating how many items are stored in a list __ contains __- a condition that can be used to determine if a specified value is stored in a list Show list __- displays a list monitor on the stage Hide list ___ hides a list monitor, preventing its display on the stage.

Describe changing an object's appearance

Looks blocks modify sprite and backdrop appearance and display text within pop-up bubbles; they are colored purple. There are looks blocks that let you modify sprite costumes and colors and others that let you modify a sprite's size and control whether a sprite is visible on the stage.

Describe default values

Many Scratch 2.0 code blocks display a default value. Every block that process argument data has an assigned default value, even those that don't display that value. You can change code block default values if necessary, although in many cases, there's no need to do so. Code blocks that present/process Boolean arguments don't display a default value. They have a default value of false.

Describe arguments.

Many code blocks accept input called arguments. There are blocks that accept and process argument data, instructing them how far to move or rotate a sprite, and other look blocks that change the size of a sprite based on a numeric argument. There's 6 different types of arguments: numeric, string, drop-down, boolean, color and one more. Code blocks with an oval or hexagon shape can receive argument data from other code blocks. You can then drag and drop oval shaped blocks onto code blocks that present/contain an oval or rectangular input field. The value of the embedded code block is passed as an argument to the code block that contains them.

Describe the more blocks category.

More blocks facilitates the creation of custom user-defined code blocks, which function as custom procedures within projects. Procedures based on more blocks can receive and process data passed to them as arguments and reduce the size and complexity of scripts in projects by allowing commonly performed programming logic to be grouped in a procedure that can be called on to execute whenever necessary. There's 2 subcategories: one that facilitates the development of projects that interact with Scratch sensor boards, and another that lets you develop program code that works with the LEGO WeDo Robotics Kit. By default, neither of these subcategories is displayed. To make them visible, you must shift-click on the program editor's Edit menu. When you do, a number of hidden menu items is displayed. To enable the display of either the Sensor board blocks or LEGO WeDo blocks, all you have to do is click on the appropriate menu items to enable their display on the more blocks list. The hidden menu items include: undelete, small stage layout, turbo mode, Sensor board blocks, LEGO WeDo blocks, export translation strings: commands, export translation strings: UI, export help screen names, edit block colors, Medialib-media, medialib- sprites, an dmedialib-check JSON file

Describe motion blocks

Motion blocks, colored blue, control a sprite's placement on the stage. There are blocks that let you set the direction a sprite moves and there are blocks that move sprites. There are also motion blocks that report on a sprite's location and direction.

List the motion blocks and describe them.

Move __ steps- moves a sprite forward or backwards a specified number of steps Turn right __ degrees- rotates a sprite a specified number of degrees in a clockwise direction. Turn left __ degrees- rotates a sprite a specified number of degrees in a counterclockwise direction. Point in direction __- points a sprite toward a specified direction (0 up, 90 right, -90 left, 180 down) point towards __- points a sprite toward either the mouse pointer or a specified sprite. Go to x: __ y:__ - moves a sprite to a specified set of coordinates on the stage. Go to ____- moves a sprite to either the location of the mouse pointer or another sprite. Glide __ secs to x: __ y:__-moves the sprite to the specified coordinate position over a certain number of seconds. Change x by __- changes the position of a sprite one the x-axis by a specified number of pixels. Set x to __- changes a sprite's location on the X-axis to a specified value Change y by __- changes the position of a sprite on the Y-axis by a specified number of pixels set y to __- changes a sprite's location on the Y-axis to a specified value If on edge, bounce- changes a sprite's direction when it makes contact with one of the edges of the stage Set rotation style __ - sets a sprite's rotation style to left-right to rotate it horizontally, all around to flip it vertically, or don't rotate to make it face one direction. x position: a monitor block that retrieves a value representing a sprite's coordinate on the X-axis y position: a monitor block that retrieves a value representing a sprite's coordinate on the Y-axis direction: a monitor block that retrieves a value representing a sprite's current direction

Describe operator blocks

Operator blocks perform arithmetic operations, generate random numbers, and compare numeric values to determine their relationship to one another. They are green. There are operator blocks that can be used to round numeric values and to execute a host of mathematical functions like determining the absolute value or the square root of a number.

Describe pen blocks

Pen blocks, colored mint green, draw any combination of shapes and lines using a virtual pen. There are pen blocks that let you enable and disable drawing, set color and pen size, and apply shading.

List and describe the sound blocks

Play sound __- plays the specified sound file while allowing the script file in which it is inserted to keep executing Play sound __ until done- plays the specified sound file, pausing script execution until the sound file has finished playing Stop all sounds- halts the playback of any sound files currently being played Play drum __ for __ beats- plays a drum sound selected from the block's pull-down menu a specified number of seconds rest for __ beats- pauses the sound of playback for a specified number of beats play note __ for __ beats- plays a musical note selected from the block's pull-down menu a specified number of beats Set instrument to __- specifies the instrument to be used when playing musical notes change volume by __- changes a sprite's volume by a specified value set volume to __%- sets a sprite's sound volume to a specified percentage level volume- a monitor block that retrieves a numeric value representing a sprite's sound volume change tempo by __- alters a sprite's tempo by a specified number of beats per minute set tempo to __bpm- assigns the number of beats per minute to be used as a sprite's tempo tempo- a monitor block that retrieves a numeric value representing a sprite's tempo

List and describe the more blocks.

Restart_Game- a custom block or procedure created by clicking on the Make a Block button located on the more blocks palette, generating a dialog where the block is named and any arguments defined. The result is a define block with the procedure inside. Define __- a hat block used to define a custom block sensor __- a monitor block that retrieves a boolean value of true or false depending on whether a specified sensor is being pressed on a sensor board attached to the computer When __- a specialized code block used to start the execution of a script when a specified event occurs on a sensor board attached to the computer slide __- a monitor block that retrieves the value being reported by one of the sensors on a Scratch sensor board Turn motor on for __ secs- a specialized code block used to interact with a LEGO WeDo Robotics kit and turn its motor for a specified number of seconds. Turn motor on- a specialized code block used to interact with a LEGO WeDo Robotics kit and turn on its motor Turn motor off- a specialized code block used to interact with a LEGO WeDo Robotics kit and turn off its motor Set motor power __- a specialized code block used to interact with a LEGO WeDo Robotics kit and set its motor power Set motor direction __- a specialized code block used to interact with a LEGO WeDo Robotics kit and set its motor direction When distance <__- a specialized code block used to interact with a LEGO WeDo Robotics kit and start the execution of a script when distance is less than a specified value When tilt = __- a specialized code block used to interact with a LEGO WeDo Robotics kit and start the execution of a script when the tilt equals a specified value distance- a monitor block that is a specialized code block used to interact with a LEGO WeDo Robotics kit and retrieve a value reporting the distance sensor value tilt- a monitor block that is a specialized code block used to interact with a LEGO WeDo Robotics kit and retrieve the tilt of a robot.

List and describe the looks blocks.

Say __ for __ seconds- displays a text message in a speech bubble for a specified number of seconds Say __- displays a text message in a speech bubble or removes the display of a speech bubble when no text is specified Think __ for __ secs- displays a text message in a thought bubble for a specified number of seconds Think __- displays a text message in a thought bubble or removes the display of a thought bubble when no text is specified Show- tells Scratch to display a sprite Hide- suppresses the display of a sprite on the stage, preventing it from interacting with other sprites switch costume to __- changes a sprite's costume, modifying its appearance Next costume- changes a sprite's costume to the next costume in the sprite's costume list, jumping back to the beginning of the list when the end of the list is reached Switch backdrop to __- alters the stage's appearance by assigning it a different backdrop. Switch backdrop to __ and wait- waits until all hat blocks have executed and then alters the stage's appearance by assigning it a different backdrop Next backdrop- changes the stage's backdrop to the next backdrop in the backdrop list Change __ effect by __- modifies a sprite's appearance by applying a modifying a special effect (color, fisheye, whirl, pixelate, mosaic, brightness, or ghost) by a specified numeric value Set __ effect to __- applies a special effect to a sprite by a specified numeric value clear graphic effects- restores a sprite to its normal appearance, removing any special effects that may have been applied Change size by __- modifies the size of a sprite by a specified numeric amount Set size to __%- sets a sprite's size to a percentage of its original size go to front- places a sprite on top of other sprites, placing it on the top layer and ensuring its display go back __ layers- moves a sprite back a specified number of layers, allowing other sprites to be displayed on top of it costume #- a monitor block that retrieves a numeric value representing a sprite's current costume number backdrop #- a monitor block that retrieves a numeric value representing the stage's current backdrop number backdrop name- a monitor block that retrieves the name of stage's current backdrop from the backdrop list size- a monitor block that retrieves a percentage value representing a sprite's current size when compared to its original size

What are the 6 basic types of scratch blocks?

Scratch applications are made up of sprites that interact with one another and the user. Sprites are controlled and animated by scripts, and can have any number of scripts, each of which is assigned to perform a specific task or action. Scripts are made up of one or more code block. In total, there's 148 blocks, each of which fufill a specific purpose. They can be classified into 6 categories: stack, hat, reporter, boolean, C, and cap blocks.

Describe keeping an eye out with monitors.

Scratch displays a small check box to the left of certain code blocks in the blocks palette. The check box indicates that the code block is capable of displaying a monitor on the stage. Clicking on the checkbox displays the monitor and clearing it hides it. A monitor displays the value of a variable, list, or Boolean on the stage. When the check is clicked, a gray monitor automatically appears on the stage. The color shown behind the value reported mirrors the color of the monitor's associated block. By default, monitors are displaying in normal readout mode. You can modify the way a monitor looks by Shift-clicking the R key and clicking on the monitor and then selected Large Readout from the pop-up menu that appears. As a result, the appearance of the monitor will change, displaying it's value in a larger font. You can also toggle between monitor formats by double-clicking on the monitor. Numeric variable-based monitors support a third format, which includes a slider display option. Unlike values displayed in normal readout and large readout, you can manually change the value assigned to a value using the slide view of a monitor by dragging the slider to the left or right. You can also specify and min and max range for a slider by Shift-clicking the R key and selected Set Slide Min and Max from the list of options that appears. This opens the slide range window. List-based monitors are also supported, which allow you to display the contents of a list. You can populate list-based monitors with data programmatically or key data into them directly by clicking on an open row in the list and typing in a value. You can also resize list-based monitors by right clicking on the small handle located on the lower right side of the monitor and dragging into or out from the monitor. You can manually add new rows to a list by clicking on the plus icon located on the lower-left side of the monitor. If a list has more rows than can be displayed within the monitor, a scrollbar is displayed, allowing you to scroll up and down the list.

Review the basic components of Scratch projects.

Scratch projects are composed of backdrops and sprites. Sprites interact and move about the stage under the programmatic control of scripts made up of code blocks. There are 10 categories of code block and 148 blocks in total.

Describe the 10 categories of scratch blocks.

Scratch provides access to many different code blocks, which are organized into 10 categories and made available on the blocks palette. They are: Motion- control sprite placement, direction, rotation, and movement Looks- affect sprite and backdrop appearance and can display text Sound- control the playback and volume of musical notes and audio files Pen- you can use to draw using different colors and pen sizes Data- store data used by applications when they execute Events- trigger script execution Control- repeatedly execute programming logic using loops or perform conditional logic Sensing- determine the location of the mouse pointer and its distance from other sprites and to determine whether a sprite is touching another sprite Operators- perform logical comparisons, rounding, and other arithmetic operations More blocks- custom code blocks that programmers can create as well as specialized code blocks that facilitate the use of Scratch 2.0 to programmatically interact with a PicoBoard and the LEGO WeDo Robotics kit. You can view the code blocks belonging to a given category by clicking on one of the 10 labeled button categories at the top of the blocks palette. Each category is color coded, making it easy to distinguish between code blocks from different categories.

Describe sensing blocks.

Sensing blocks, colored sky blue, determine the location of the mouse pointer, its distance from other sprites and whether a sprite is touching another sprite.

Describe sound blocks

Sound blocks, colored pink, play music and add sound effects to your Scratch application projects. There are sound blocks that let you play sound and drum beats, select different types of instrument, control playback volume and modify tempo.

Describe working with stack blocks.

The majority of Scratch code blocks are stack blocks, which are code blocks with a notch at the top and a bump at the bottom. The notches and bumps serve as visual indicators that identify how the blocks can be snapped together to create programming logic. The notch indicates that a code block can be attached to the underside of another code block. The bump allows other blocks to attach to its underside. Some stack blocks include an input area inside that allows you to specify a value by typing in a number. To modify the value assigned to a block, click on the white area within the code block and type in a new value. Some code block let you configure them by selecting a value from a pull-down list.

Describe working with blocks and stacks.

To bring backdrops and sprite to life, you must create scripts by dragging and dropping code blocks from the blocks palette and snapping them together, creating stacks. You can run scripts by double clicking on one of the blocks. You can also configure scripts to automatically execute when predefined events occur. You can drag code blocks around the script area, and when near other blocks, a white indicator bar appears to designate locations where a valid connection can be made. You can snap code blocks to the top or bottom of stacks and the middle. Sometimes you can insert them inside other code blocks. You can move code stacks by clicking on their uppermost blocks and dragging them to a new location. If you drag from the middle, only the blocks underneath will be dragged. You can copy a stack of code blocks from one sprite to another by dragging and dropping the stack onto the thumbnail of a sprite located in the sprite list.

List and describe the sensing block.

Touching __- retrieves a Boolean value of true or false depending on whether the sprite is touching a specified sprite, edge, or mouse pointer as selected from the block's pull-down menu Touching color __- retrieves a Boolean value of true or false depending on whether the sprite is touching a specified color Color __ is touching color __- retrieves a Boolean value of true or false depending on whether the first specified color inside the sprite is touching the second specified color on the backdrop or on another sprite Distance to __- retrieves a numeric value representing a sprite's distance from another sprite or from the mouse pointer Ask __ and wait- displays a question in a speech bubble and displays an entry field prompting the user to enter keyboard input that is captured and stored in a variable named answer answer- a monitor block that retrieves the value stored in a variable named answer, which is supplied by the last use of the ask and wait block key __ pressed- retrieves a value of true or false depending on whether a specified key is pressed mouse down?- retrieves a boolean value of true or false depending on whether a mouse button is pressed mouse x- retrieves the location of the mouse pointer on the X-axis mouse y- retrieves the location of the mouse pointer on the Y-axis loudness- a monitor block that retrieves a numeric value, from 1 to 100, representing the volume of the computer's microphone video __ on __- a monitor block that senses motion or direction in video supplied via a webcam Turn video __- turns video on and off Set video transparency to __%- specifies the amount of transparency of a video as a percentage value timer- a monitor block that retrieves a numeric value representing the number of seconds that the timer has run reset timer- resets the timer back to its default value of zero __ of __- retrieves the property value (x position, y position, direction, customer #, and size of volume) for the backdrop of a specified sprite current minute- a monitor block that retrieves the current year, month, date, day of week, hour, minute, or second days since 2000- retrieves the number of days since 2000 username- retrieves the name of the person viewing the Scratch project

List and describe the control blocks

Wait __ secs- pauses script execution for a specified number of seconds, after which the script resumes its execution Repeat __- repeats the execution of all the code blocks embedded inside it a specified number of times forever- repeatedly executes all the code blocks embedded inside it if __ then - executes all the code blocks embedded within the control if the specified condition evaluates as true if __ then, else__- executes the code blocks embedded in the top half of the control if the specified condition evaluates as true and executes all of the code blocks in the bottom half of the control if the condition evaluates as false wait until __- pauses script execution until a specified execution becomes true Stop __- halts all script execution within all sprites, a specified script or other scripts in a sprite When I start as a clone- triggers script execution for a clone if one is created Create clone of __- creates a temporary duplication of a specified sprite Delete this clone- deletes the current clone

List and describe the event blocks

When green flag clicked- executes the script to which it has been attached whenever the green flag button is pressed when __ key is pressed- executes the script to which it has been attached whenever a specified keyboard key is pressed When this sprite clicked- executes the script to which it has been attached whenever the user clicks on the sprite to which the script belongs When backdrop switches to __- executes the script to which it has been attached whenever a specified backdrop is switched to on the stage When __>__- executes the script to which it has been attached when the first specified value exceeds the second specified value exceeds the second specified value When I receive __- executes the scripts to which it has been attached when a specified broadcast message is received broadcast __- sends a broadcast message to all sprites without pausing script execution broadcast __ and wait- sends a broadcast message to all sprites to trigger a predefined action and then pauses script execution, waiting until all sprites have completed their assigned action before allowing the script in which the block resides to continue executing.

Describe getting help with code blocks.

You can view help information for any Scratch 2.0 code block by clicking on the question mark icon located on the Program Editor menu bar. Doing so turns the mouse pointer into a circular question mark, allowing you to then click on the code block that you want to learn about. Once you have clicked on the code block you wish to know more about, the program editor opens in the Tips window, displaying an explanation of the purpose of the code block as well as an example of its usage.

List and describe the operator blocks.

__ + __- adds two numbers and generates a result __-__- subtracts one number from another and returns the result __*__- multiplies two numbers and generates a result __/__- divides one number into another and returns the result pick random __ to __- generates a random number within the specified range __<__- returns a boolean value of true or false depending on whether one number is less than another __=__- returns a boolean value of true or false depending on whether one number is equal to another __>__- returns a boolean value of true or false depending on whether one number is greater than another __ and __- returns a boolean value of true or false depending on whether two separately evaluated conditions are both true __ or __- returns a boolean value or true or false depending on whether either of two separately evaluated conditions is true not __- reverses the boolean value from true to false or false to true join __ __- concatenates or places two strings right next to one another letter __ of __- retrieves a letter from a string based on its specified position within the string length of __- returns the numeric length of a string __ mod__- retrieves the remainder portion of a division operation between two numbers round __- returns the nearest integer value for a specified number __ of __- returns the result of the selected function (abs, sqrt, sin, cos, tan, asin, acos, atan, Ln, log, E^, and 10^) when applied to the specified number


Related study sets

Past Perfect Progressive vs. Simple Past

View Set

Abeka grade 8 science test 9 exam

View Set

Chapter 4 Choosing Brand Elements to Build Brand Equity

View Set

New Perspectives: HTML5 and CSS3, 7th Edition

View Set

034 - Chapter 34 - Global Politics (1760-1848)

View Set