CISP Ch 5

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A module's file name should end in __________.

.py

The statement below prints a random number in the range of ___________ up to, but not including, ___________. print(random.random())

0.0; 1.0

Consider the following function definition: def do_something(number): return number * 2 Given the function definition, what will the following statement display? print(do_something(10))

20

When a program is developed as a set of functions in which each performs an individual task, the same programmer should be assigned to the job of writing the different functions.(t/f)

False(different programmers can be assigned the job of writing different functions)

Global variables make debugging easier(t/f)

False(makes debugging difficult bc any statement in a program can change the value of a global variable

A local variable is declared inside a function, and only statements in the same function can access it.(t/f)

True

If a specific operation is performed in several places in a program, a function can be written once to perform that operation, and then be reused any time it is needed.(t/f)

True

In top-down design, tasks are broken down into subtasks until no more subtasks can be identified.(t/f)

True

A function definition has two parts: _________.

a header and a block

The pieces of data that are passed into a function are called ________.

arguments

What does the following statement do? print(random.randrange(10, 20)) a. It prints 20 random integers up to the value of 19. b. It prints a random integer in the range of 10 through 19. c. It prints 10 random integers up to the value of 20. d. It prints a random integer in the range of 10 through 20.

b

Library functions are like _________ because they accept input, perform some operation (that cannot be seen) using the input, and produce output.

black boxes

What does the following statement do? print(random.randint(1, 20)) a. It stores 20 random integers in a list called x. b. It stores a random integer in the range of 1 through 20 to the variable x. c. It prints a random integer in the range of 1 through 20. d. It prints a random number of integers up to 20 in a list called x.

c

What is the last step in top-down design?

code the subtasks

Functions can be written for ________ across different programs to make development faster.

common tasks

What does the following statement do? x = random.randint(1, 100) a. it assigns a random number of integers up to 100 in a list called x. b. It assigns a random integer in the range of 2 through 99 to the variable x. c. It assigns 100 random integers in a list called x. d. It assigns a random integer in the range of 1 through 100 to the variable x.

d

A large task is divided into several smaller tasks that are easily performed. This technique is known as _________.

divide and conquer

The scope of a global variable is the ________.

entire program

To call a function means to _________ the function.

execute

A local variable in one function cannot have the same name as a local variable in a different function.(t/f)

false(since variables can't be accessed outside of their function, other functions can have the same variable name without causing a reassignment)

When a parameter is changed, it changes the argument that was passed into the parameter as well.(t/f)

false(the argument would not be changed)

When the end of a function is reached, the computer returns control back to the beginning of the program.(t/f)

false(the computer returns to the part of the program where the function was called)

A ________ is a group of statements that exist within a program for the purpose of performing a specific task.

function

A(n) ________ is a name that is available to every function in the program.

global constant

A prewritten function that performs some commonly needed task is called a _________.

global function

Suppose you have coded a module named my_shapes.py that contains the square, circle, and line functions presented in the chapter. Write the import statement that would allow you to use this module in a program. Assume that turtle has already been imported as the first line in the program.

import my_shapes

In Python, you can use the ________ function to cause a program to pause until the user presses the Enter key.

input

A(n) __________ displays a list of the operations on the screen, and allows the user to select the operation that he or she wants the program to perform.

menu-driven program

The variables that receive pieces of data in a function are called _________.

parameters

What statement prints a random floating-point number in the range of 0.1 through 0.5?

print(random.uniform(0.1, 0.5))

The purpose of the return statement in a function is to ________.

return a value back to the part of the program that called it

A variable's __________ specifies the part of a program in which a variable may be accessed.

scope

When the random module is imported, what does it use as a seed value for random number generation?

the computer's internal system time

The following statements call a function named show_data. Which of the statements passes arguments by position, and which passes keyword arguments?

the first statement passes by keyword argument and the second statement passes by position

A module's name cannot be the same as a Python key word.(t/f)

true

A parameter variable's scope is the entire function in which the parameter is declared.(t/f)

true

A void function does not return a value.(t/f)

true

If the same seed value is always used for generating random numbers, the random number function will always generate the same series of pseudorandom numbers. (t/f)

true

If you do not declare a global variable with the global keyword inside a function, then you cannot change the variable's assignment inside that function.(t/f)

true

The Python interpreter uses indentation to determine where a block begins and ends.(t/f)

true


Set pelajaran terkait

Chapter 11 - Complaints, Grievances, and Conflict

View Set

Lab 3-3: Search Text Files Using Regular Expressions: Linux installation and configuration

View Set

1.1 Scientific Method/Notes Study Guide

View Set