Chapter 5 – Graphics and Procedures

chapter 5

Graphics and Procedures

True-False Questions

1.The Logo Programming Language is the basis for the graphics of Visual Logic.

Answer: True Level: Easy

Section: 5-1 Page: 80

2.The graphic command Turn Right D will make the pen turn right and move the distance D.

Answer: FalseLevel: Easy

Section: 5-1Page: 82

3.The graphic command Turn Left D will make the pen turn left D degrees.

Answer: TrueLevel: Easy

Section: 5-1Page: 82

4.Forward, Turn Left, and Fill Circle are examples of Multimedia commands.

Answer: FalseLevel: Easy

Section: 5-1Page: 82

5.The home position of the pen is in the center of the screen facing south.

Answer: FalseLevel: Easy

Section: 5-1Page: 80

6.Using only a loop, Turn Right, and Forward graphic command any shape can be drawn.

Answer: TrueLevel: Easy

Section: 5-1 Page: 84

7.The Go Home command causes the pen to move to the center of the screen and face 0º.

Answer: TrueLevel: Easy

Section: 5-1Page: 81

8.In the Visual Logic graphic system 90º is considered East unless the Rotate Axis command is executed.

Answer: FalseLevel: Moderate

Section:5-1Page: 80

9.The pen is set at a color of blue and a width of 1 by default.

Answer: FalseLevel: Easy

Section: 5-2Page: 85

10.The Set Color command is used to change the color of the pen.

Answer: TrueLevel: Easy

Section: 5-2Page: 85

11.The Pen Size command is used to make the pen line wider.

Answer: False Level: Moderate

Section: 5-2Page: 85

12.Both the Color Forward and Set Color commands are used to change to color of the pen.

Answer: True Level: Easy

Section: 5-2 Page: 86

13.The Set Color command will open the color dialog box.

Answer: TrueLevel: Moderate

Section: 5-2Page: 85

14.After using the Set Color command the pen will change back to the default color of black when ten other commands are executed.

Answer: FalseLevel: Hard

Section: 5-2Page: 85

15.A procedure is a set of programming instructions grouped together into a single unit.

Answer: True Level: Easy

Section: 5-3Page: 85

16.Structured design is the process of breaking a problem into smaller parts.

Answer: TrueLevel: Easy

Section: 5-3Page: 87

17.A procedure is the solution to a small part of a problem identified through the process of structured design.

Answer: TrueLevel: Moderate

Section: 5-3Page: 87

18.The Call Procedure menu option will only allow you to add a new procedure.

Answer: FalseLevel: Moderate

Section: 5-3Page: 89

19.A special process must be followed to add commands to a procedure.

Answer: FalseLevel: Easy

Section: 5-3Page: 88

20.Procedures with arguments are used to create general solutions to problems.

Answer: TrueLevel: Moderate

Section: 5-4Page: 91

21.A formal argument is the parameter as it is referred to inside the procedure.

Answer: TrueLevel: Easy

Section: 5-4Page: 91

22.The name of the actual argument must match the name of the formal argument.

Answer: FalseLevel: Easy

Section: 5-4Page: 92

23.The name of the formal argument is found in the parentheses after the procedure name in the definition of the procedure.

Answer: TrueLevel: Hard

Section: 5-4Page: 93

24.The order of the actual arguments when the procedure is called does not have to match the order of the formal arguments inside the procedure.

Answer: FalseLevel: Moderate

Section: 5-4Page: 93

25.Arguments are used to send information from the calling program to the procedure.

Answer: TrueLevel: Easy

Section: 5-4Page: 93

26.An argument in a procedure is different from a parameter in a procedure.

Answer: FalseLevel: Easy

Section: 5-4Page: 90

27.Loops cannot be placed inside a procedure.

Answer: FalseLevel: Easy

Section: 5-4 Page: 91

28.The actual argument can be edited in the Arguments dialog box.

Answer: TrueLevel: Easy

Section: 5-4Page: 92

29.The procedure name can be edited in the Arguments dialog box.

Answer: False Level: Moderate

Section: 5-4 Page: 92

30.Multiple arguments can be added to a procedure in the Procedure Edit dialog box.

Answer: TrueLevel: Easy

Section: 5-5Page: 93

31.After the Procedure Edit dialog box is closed, the developer must type in the procedure stub.

Answer: FalseLevel: Easy

Section: 5-3Page: 88

32.A recursive procedure calls two or more different procedures.

Answer: FalseLevel: Easy

Section: 5-5Page: 94

33.Good programmers create as many infinite recursions as possible.

Answer: FalseLevel: Easy

Section: 5-5Page: 94

34.When a base cast test on a parameter is false, the procedure will not call itself.

Answer: TrueLevel: Moderate

Section: 5-5Page: 94

35.A loop is like a recursive procedure because the same actions are repeated many times.

Answer: True Level: Moderate

Section: 5-5Page: 94

Multiple Choice Questions

36.Which is not a Visual Logic graphic command?

a.) Rotate Left D

b.) Forward N

c.) Set Color C

d.) Circle N

e.) Pen Up

Answer: aLevel: Moderate

Section: 5-1Page: 81

37.Which is true about the graphic positions?

a.) The home position faces south.

b.) The north, south, east and west positions can be changed with a command.

c.) The pen starts in the upper right hand corner of the screen.

d.) The home position is at the coordinates (0, 0).

e.) None of the above.

Answer: dLevel: Moderate

Section: 5-1Page: 80

38.Which three statements can be used to create any graphic shape?

a.) Loop, Forward, and Backward

b.) Input, Forward, and Backward

c.) Loop, Forward, and Turn Right

d.) Input, Forward, and Turn Right

e.) Loop, Forward, and Go Home

Answer: cLevel: Moderate

Section: 5-1 Page: 83

39.Which graphic command rotates the pen’s drawing direction without moving the pen?

a.) Forward N

b.) Turn Left D

c.) Set Direction D

d.) Both b and c.

e.) All of the above.

Answer: dLevel: Moderate

Section: 5-1Page: 81

40.Which shape can be created with just one graphic command?

a.) Circle

b.) Triangle

c.) Square

d.) Rectangle

e.) Hexagon

Answer: aLevel: Easy

Section: 5-1Page: 81

41.The default color for the graphic pen is:

a.) blue.

b.) black.

c.) green.

d.) red.

e.) There is no default color.

Answer: bLevel: Easy

Section: 5-2 Page: 85

42.Which sets of colors will the Color Forward command not cycle through?

a.) yellow-red

b.) red-blue

c.) blue-green

d.) green-red

e.) All are sets of colors for the Color Forward command.

Answer: aLevel: Moderate

Section: 5-2Page: 86

43.Which command causes the standard color dialog box to open?

a.) Go Home

b.) Set Direction

c.) Set Color

d.) Color Forward

e.) Pen Width

Answer: cLevel: Moderate

Section: 5-2 Page: 85

44.When programming instructions are grouped together into a single unit this is called a:

a.) graphic command.

b.) do loop.

c.) For loop.

d.) recursion.

e.) procedure.

Answer: eLevel: Moderate

Section: 5-3Page: 87

45.Breaking a problem into smaller parts is called:

a.) recursion.

b.) structured design.

c.) implementation.

d.) logical design.

e.) syntax.

Answer: bLevel: Moderate

Section: 5-3Page: 87

46.What happens when a procedure is called?

a.) The control of the program exits the procedure.

b.) The control of the program goes to the inside of the procedure.

c.) The control of the program returns to the calling statement.

d.) First a then b.

e.) First b then a then c.

Answer: eLevel: Moderate

Section: 5-3 Page: 87

47.Which is true about a procedure?

a.) It has at least one argument.

b.) It has at least one parameter.

c.) It has more than one argument.

d.) It has more than one parameter.

e.) Arguments and parameters are optional in procedures.

Answer: eLevel: Easy

Section: 5-4Page: 90

48.An actual argument is:

a.) a special argument that is never used in a procedure.

b.) the argument inside the procedure.

c.) the argument at the time the procedure is called.

d.) optional in a procedure with arguments.

e.) Both b and c.

Answer: cLevel: Hard

Section: 5-4Page: 91

49.The formal argument is:

a.) used inside the procedure.

b.) is defined in the Procedure Edit dialog box.

c.) is added with the New button located below the Arguments box.

d.) Both a and b.

e.) All of the above.

Answer: eLevel: Moderate

Section: 5-4Page: 91

50.The procedure name and arguments are displayed:

a.) in the procedure header element.

b.) in the procedure footer element.

c.) inside the body of the procedure.

d.) Both a and b.

e.) All of the above.

Answer: dLevel: Easy

Section: 5-4Page: 92

51.Double clicking on a procedure element will activate the:

a.) Procedure Edit dialog box.

b.) Argument dialog box.

c.) Graphic dialog box.

d.) Color dialog box.

e.) None of the above.

Answer: bLevel: Moderate

Section: 5-4Page: 92

52.A recursive procedure:

a.) will call itself.

b.) should be avoided at all costs.

c.) is the same as an infinite recursion.

d.) Both a and b.

e.) All of the above.

Answer: aLevel: Moderate

Section: 5-5Page: 92

53.The number of times a procedure is called recursively:

a.) is always zero.

b.) is always one.

c.) is at least one or more.

d.) depends on the values of the formal arguments passed to the procedure.

e.) None of the above.

Answer: dLevel: Hard

Section: 5-5Page: 92

54.Infinite recursions:

a.) are useful for breaking a problem into simple components.

b.) make the program easier to understand.

c.) are prevented by checking a parameter against a base case.

d.) will prevent the program from malfunctioning.

e.) None of the above.

Answer: cLevel: Hard

Section: 5-5 Page: 92

Fill in the Blank Questions

55.The ___Logo___ programming language is the basis for the Visual Logic Graphic system.

Level: Moderate

Section: 5-1 Page: 80

56.The direction ___north___ is the default drawing direction when the graphic system starts.

Level: Easy

Section: 5-1Page: 82

57.The orientation of 180º corresponds to the direction ___south___.

Level: Easy

Section: 5-1Page: 80

58.A simple program to draw any equally sided shape can be written with just a ___Loop___, ___Turn Right___, and ___Forward___ statement.

Level: Moderate

Section: 5-1Page: 84

59.The ___Set Direction___ graphic command will rotate the drawing direction to a new orientation.

Level: Moderate

Section: 5-1Page: 81

60.The ___Set Color___ graphic command lets the programmer change the color the pen draws.

Level: Easy

Section: 5-2 Page: 85

61.The ___ Color Forward___ graphic command sets the color by rotating through 256 shades each of Blue-Green, Green-Red, and Red-Blue.

Level: Easy

Section: 5-2Page: 86

62.The Set Color graphic command allows the programmer to select a color for the pen from the ___color dialog box___.

Level: Moderate

Section: 5-2Page: 85

63.The default for the graphic pen is to draw a ___black___ line with a width of ___1___.

Level: Moderate

Section: 5-2Page: 85

64.A set of programming instructions grouped together into a single unit is called a(n) ___procedure___.

Level: Easy

Section: 5-3 Page: 87

65.The process of breaking a problem into smaller parts is called ___structured design___.

Level: Easy

Section: 5-3Page: 87

66.All procedures are found on the command menu under the ___Call Procedures___ menu option.

Level: Moderate

Section: 5-3Page: 89

67.Another name for an argument in a procedure is a(n) ___parameter___.

Level: Easy

Section: 5-4Page: 90

68.A formal argument is declared when the ___Procedure Edit___ dialog box is open.

Level: Moderate

Section: 5-4Page: 91

69.An actual argument is declared when the ___Arguments___ dialog box is open.

Level: Moderate

Section: 5-4Page: 92

70.In a procedure with multiple arguments the first actual argument corresponds to the ___first___ formal argument.

Level: Easy

Section: 5-4Page: 93

71.The argument inside of the procedure is a(n) ___formal___ argument.

Level: Easy

Section: 5-4 Page: 93

72.The argument placed in the parenthesis when calling a procedure is a(n) ___actual___ argument.

Level: Easy

Section: 5-4 Page: 91

73.A procedure that calls itself is called a(n) ___recursive___ procedure.

Level: Easy

Section: 5-5Page: 94

74.A recursive procedure that never stops calling itself is a(n) ___infinite recursion___.

Level: Moderate

Section: 5-5 Page: 94

75.The ___base case___ test on an argument can prevent infinite recursions.

Level: Hard

Section: 5-5 Page: 94

Essay Questions

76. Write a Visual Logic algorithm or program to draw a triangle.

Begin  Forward: 100  Turn Right: 120 

Forward: 100  Turn Right: 120 

Forward: 100  Turn Right: 120  End

77.Which design process leads to the use of procedures? What are the advantages of using procedures?

The goal of the structured design process is to break problems into smaller and smaller parts until a simple, general algorithm can be created to solve each part of the problem. Once this basic building block of an algorithm is created it can be placed in a procedure. The procedure can then be called multiple times as needed with the main program or from other procedures.

Using procedures results in code that is easier to read, understand, and maintain. There is only one location for the code that solves a particular problem. If it turns out that the logic in that procedure needs to be fixed or updated, the developer will only have to change the code in that one location instead of multiple locations. Not having duplicate code saves time and decreases the chance that errors are introduced into the code, both during the creation and maintenance phases of software development.

5 - 1