Procedures

Procedures

12th Grade

6 Qs

quiz-placeholder

Similar activities

AP CSP Code.org Unit 7

AP CSP Code.org Unit 7

9th - 12th Grade

8 Qs

AQA A Level: 4.4.1 Abstraction

AQA A Level: 4.4.1 Abstraction

12th Grade

10 Qs

Code.org Unit 7 Test

Code.org Unit 7 Test

9th - 12th Grade

8 Qs

APCSA Unit 7

APCSA Unit 7

9th - 12th Grade

8 Qs

AP CSP Unit 7

AP CSP Unit 7

9th - 12th Grade

8 Qs

Unit 7 APCSA

Unit 7 APCSA

9th - 12th Grade

8 Qs

Code.org Unit 7 Review

Code.org Unit 7 Review

9th - 12th Grade

8 Qs

AP Computer Science Principles Unit 7 Review

AP Computer Science Principles Unit 7 Review

9th - 12th Grade

8 Qs

Procedures

Procedures

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Ms Seccafico

Used 99+ times

FREE Resource

6 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

In the following procedure, the parameter str is a string and the parameter num is a number.

PROCEDURE printArgs(str, num)


{

DISPLAY(num)

DISPLAY(str)

DISPLAY(num)

}


Consider the following code segment.


printArgs("**", 1)

printArgs("*", 2)


What is displayed as a result of executing the code segment?

1 * 1 2 ** 2

1 ** 1 2 * 2

* 1 * ** 2 **

** 1 ** * 2 *

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following procedures.


PROCEDURE proc1(str)

{

DISPLAY(str)

DISPLAY("happy")

}

PROCEDURE proc2(str1, str2)

{

proc1(str2)

DISPLAY(str1)

}


What is displayed as a result of the procedure call proc2("birthday", "to you") ?

birthday happy to you

birthday happy birthday

to you birthday happy

to you happy birthday

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Consider the following procedure.


PROCEDURE doSomething(num1, num2)

{

DISPLAY(num1)

RETURN(num1)

DISPLAY(num2)

}


Consider the following statement.

DISPLAY(doSomething(10, 20))


What is displayed as a result of executing the statement above?

10 10

10 20

10 10 20

10 20 10

4.

MULTIPLE SELECT QUESTION

1 min • 1 pt

Which of the following are benefits of procedural abstraction?


Select two answers.

Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers.

Procedural abstraction eliminates the need for programmers to document their code.

Procedural abstraction makes it easier for people to read computer programs.

Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A student is developing a program that allows users to look up the definitions of words that appear in a book.

The student plans to perform a large number of searches through a dictionary containing words and their definitions. The student will use a procedure written by a computer scientist to quickly search the dictionary (and knows that the procedure will return a definition if one is available). The student cannot modify the search procedure written by the computer scientist but can call the procedure by supplying a word.


Which of the following is a true statement about the student’s use of the computer scientist’s search procedure?

The student is changing the search procedure’s internal abstractions.

The student is modifying the search procedure to take a definition as an argument and return the corresponding word.

The student is reusing the computer scientist’s procedural abstraction by knowing what the procedure does without knowing how it does it.

The student is reusing the computer scientist’s procedural abstraction by using duplicate code each time a search needs to occur.

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

A student wrote the following procedure to calculate the sum of the integers from 1 to 5.


The student later decides to modify the procedure to calculate the sum of the integers from 1 to max, which represents any positive integer greater than 1.

Which of the following changes should be made to the procedure to meet the student’s goal?


I. The procedure should take max as an input parameter. II. The condition in the REPEAT UNTIL block should be changed to count > max.

III. The condition in the REPEAT UNTIL block should be changed to max < 5.

I only

II only

I and II

I and III