Chapter 6 revel MC

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is k after running the following code? def nPrint(message, n): while n > 0: print(message) n -= 1 k = 2 nPrint("A message", k) A. 0 B. 1 C. 2 D. 3

C. 2

Each time a function is invoked, the system stores parameters and local variables in an area of memory, known as____ , which stores elements in last-in first-out fashion A. a heap B. storage area C. a stack D. an array

C. a stack

a function _____ A. must have at least one parameter B. May have no parameters C. Must always have a return statement to return a value D. Must always have a return statement to return multiple values

B. may have no parameters

arrangements to functions always appear within______ A. brackets B. parentheses C. curly braces D. quotation marks

B. parentheses

When you invoke a function with a parameter, the value of the argument is passed to the parameter. This is referred to as ____ A. Function invocaiton B. Pass by value C. pass by reference D. pass by name

B. pass by value

What is k after running the following code? def nPrint(message, n): while n > 0: print(message) n -= 1 k = 2 nPrint(n = k, message = "A message") A. 0 B. 1 C. 2 D. 3

C. 2

Given the following function, what will be displayed by the call nPrint('a', 4)? def nPrint(message, n): while n > 0: print(message, end = '') n -= 1 A. aaaaa B. aaaa C. aaa D. Invalid call E. infinite loop

E. infinite loop

the header of a function consists of_____ a. function name b. function name and parameter list c. parameter list d. the keyword def, followed by the functions name and parameters, and ends with a colon

d. the keyword def, followed by the functions name and parameters, and ends with a colon

__________ is a simple but incomplete version of a function. A. A stub B. A function C. A function developed using botton-up approach D. A function developed using top-down approach

A. A stub

Which of the following should be defined as a none function? A. write a function that prints integers from 1 to 100 B. Write a function that returns a random integer from 1 to 100 C. Write a function that checks whether a number is from 1 to 100 D. Write a function that converts an uppercase letter to lowercase

A. Write a function that prints integers from 1 to 100

a variable defined outside a function is referred to as______ A. a global variable B. a function variable C. a block variable D. a local variable

A. a global variable

Given the following function header, which of the following is correct to invoke it? def f( p1, p2, p3, p4)

A. f(1, 2, 3, 4) D. f( p1 = 1, p2 = 2, p3 = 3, p4 = 4) E. f( 1, 2. 3. p4 = 4)

Whenever possible, you should avoid using __________. A. global variables B. function parameters C. global constants D. local variables

A. global variables

What will be displayed by the following code? x = 1 def f1(): x = 3 print(x, end = " ") f1() print(x) A. 1 3 B. 3 1 C. The program has a runtime error because x is not defined. D. 1 1 E. 3 3

B. 3 1

What will be displayed by the following code? x = 1 def f1(): y = x + 2 print(y, end = " ") f1() print(x) A. 1 3 B. 3 1 C. The program has a runtime error because x is not defined. D. 1 1 E. 3 3

B. 3 1

__________ is to implement one function in the structure chart at a time from the top to the bottom. A. Bottom-up approach B. Top-down approach C. Bottom-up and top-down approach D. Stepwise refinement

B. Top - down approach

Given the following function, what will be displayed the call nPrint('a', 4)? def nPrint(message, n) : while n > 0: print (message, end = ' ' ) n -= 1 A. aaaaa B. aaaa C. aaa D. Invalid call E. Infinite loop

B. aaaa

What will be displayed by the following code? x = 1 def f1(): print(x, end = " ") f1() print(x) A. 1 3 B. 3 1 C. The program has a runtime error because x is not defined. D. 1 1 E. 3 3

D. 1 1

A function with no return statement returns _____ A. Void B.Nothing C. 0 D. None

D. None

a variable defined inside a function is referred to as______ A. a global variable B. a function variable C. a block variable D. a local variable

D. a local variable

Consider the following incomplete code: def f(number): #missing function body # return the value number print(f(5)) the missing function body should be _______ A. return "number" B. print(number) C. print("number") D. return number

D. return number

What will be displayed by the following code? x = 1 def f1(): global x x = x + 2 print(x) f1() print(x) A. 1 3 B. 3 1 C. The program has a runtime error because x is not defined. D. 1 1 E. 3 3

E. 3 3

Does the function call main() in the following code cause syntax errors>? import math def main(): return math.sin(math.pi) math()

No


संबंधित स्टडी सेट्स

ATI- PN Adult Medical Surgical Practice 2017 B

View Set

Chapter 22: Psychotherapeutic Agents

View Set

General Survey Body Structure Terms

View Set

Chapter 6 International accounting

View Set

Culture Diversity Courses 1, 2, 3

View Set

Prep U Chapter 13 Assessing Nutritional Status

View Set