Programming 4-5

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

What is the result of the following statement? x = random.randint (5,15)*2

A random integer from 5 to 15, multiplied by 2, assigned to the variable x

What type of function can be used to determine whether a number is even or odd?

Boolean

What type of loop structure repeats the code based on the value of the Boolean expression?

Boolean-controlled loop

When a function is called by its name, then it is ________.

Executed

In Python, an infinite loop usually occurs when the computer accesses the wrong memory address

False

In a menu-driven program, a loop structure is used to determine the menu item the user selected

False

One of the drawbacks of a modularized program is that the only structure we could use is sequence structure

False

True/False: A function definition specifies what a function does and causes the function to execute

False

True/False: A local variable can be accessed from anywhere in the program.

False

True/False: Functions can be called from statements in the body of a loop, and loops can be called from the body of a function.

False

True/False: In Python, there is no restriction on the name of a module file.

False

True/False: In a menu-driven program, a loop structure is used to determine the menu item theuser selected.

False

True/False: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure

False

True/False: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.

False

True/False: The first line in the while loop is referred to as the condition clause.

False

True/False: The hierarchy chart shows all the steps that are taken inside a function

False

True/False: The math function, atan(x), returns one tangent of x in radians

False

True/False: The value assigned to a global constant can be changed in the mainline logic

False

True/False: Unlike other languages, in Python, the number of values a function can return is limited to one.

False

A( n ) ________ chart is also known as a structured chart.

Hierarchy

What is the disadvantage of coding in one long sequence structure?

If parts of the duplicated code have to be corrected, the correction has to be made many times

Which of the following statements causes the interpreter to load the contents of the random module into memory?

Import Random

________ is the process of inspecting data that has been input to a program to make sure it is valid before it is used in a computation.

Input validation

The Python library functions that are built into the Python _____ can be used by simply calling the function.

Interpreter

What makes it easier to reuse the same code in more than one program?

Modules

What is the structure that causes a statement or a set of statements to execute repeatedly

Repetition

A variable's ________ is the part of a program in which the variable may be accessed.

Scope

The _____ of a local variable is the function in which the variable is created.

Scope

Python comes with ________ functions that have been already prewritten for the programmer.

Standard

In Python, the variable in the for clause is referred to as the ________ because it is the target of an assignment at the beginning of each loop iteration.

Target Variable

What does the following statement mean?num1, num2 = get_num()

The function get_num() is expected to return a value each for num1 and num2.

To get the total number of iterations of a nested loop, multiply the number ofiterations of all the loops.

True

True/False: A better way to repeatedly perform an operation is to write the statements for the task once, and then place the statements in a loop that will repeat the statements as many times as necessary.

True

True/False: A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program

True

True/False: A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program.

True

True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures

True

True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.

True

True/False: Both of the following for clauses would generate the same number of loop iterations. for num in range(4): for num in range(1,5):

True

True/False: Different functions can have local variables with the same names.

True

True/False: In Python, one can have a list of variables on the left side of the assignment operator

True

True/False: In Python, one can have a list of variables on the left side of the assignment operator.

True

True/False: In a nested loop, the inner loop goes through all of its iterations for every single iteration of an outer loop.

True

True/False: In flowcharting, the decision structure and the repetition structure both use the diamond symbol to represent the condition that is tested.

True

True/False: One of the reasons not to use global variables is that it makes a program hard to debug.

True

True/False: Python allows for passing multiple arguments to a function

True

True/False: Python allows for passing multiple arguments to a function.

True

True/False: Python function names follow the same rules for naming variables

True

True/False: Python function names follow the same rules for naming variables.

True

True/False: Reducing duplication of code is one of the advantages of using a loop structure.

True

True/False: The function header marks the beginning of the function definition

True

True/False: The function header marks the beginning of the function definition.

True

True/False: The integrity of a program's output is only as good as the integrity of its input. For this reason the program should discard input that is invalid and prompt the user to enter correct data.

True

True/False: The math function, ceil(x), returns the smallest integer that is greater than or equal to x.

True

True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.

True

True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function

True

True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function.

True

True/False: To get the total number of iterations of a nested loop, multiply the number of iterations of all the loops.

True

When will the following loop terminate? while keep_on_going != 999 :

When keep_on_going refers to a value equal to 999

A value-returning function is ________.

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

The variable used to keep the running total is called a(n)

accumlator

A(n) _____ is any piece of data that is passed into a function when the function is called.

arguments

A set of statements that belong together as a group and contribute to the function definition is known as a( n ) ________.

block

What type of loop structure repeats the code a specific number of times?

count-controlled loop

What type of value is returned by the functions random and uniform

float

Which of the following functions returns the largest integer that is less than or equal to x?

floor

What is a group of statements that exists within a program for the purpose of performing a specific task

function

A(n) _____ constant is a global name that references a value that cannot be changed

global

A(n) _____ variable is accessible to all the functions in a program file

global

It is recommended that programmers should avoid using _____ variables in a program when possible.

global

The first line in the function definition is known as the function

header

In a menu-driven program, what statement is used to determine and carry out the user's desired action?

if-elif-else

The _____ argument specifies which parameter the argument should be passed into

keyword

n Python, a comma-separated sequence of data items that are enclosed in a set of brackets is called a ________.

list

A(n) _____ variable is created inside a function

local

The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations.

math

Which of the following will assign a random number in the range of 1 through 50 to the variable number?

number = random.randint(1, 50)

A(n) _____ is a variable that receives an argument that is passed into a function.

parameter

A(n) ________ is a variable that receives an argument that is passed into a function.

parameter

The first input operation is called the ________, and its purpose is to get the first input value that will be tested by the validation loop

priming read

In a value-returning function, the value of the expression that follows the key word _____ will be sent back to the part of the program that called the function

return

The _____ design technique can be used to break down an algorithm into functions.

top-down

Which of the following represents an example to calculate the sum of the numbers (accumulator)?

total += number

What is the format for the while clause in Python?

while condition :

What are the values that the variable num contains through the iterations of the following for loop?for num in range(4)

0, 1, 2, 3

What are the values that the variable num contains through the iterations of the following for loop? for num in (2 , 9 , 2)

2,4,6,8

Given the following function definition, what would the statement print magic(5) display? def magic(num): return num + 2 * 10

25

What is not an example of an augmented assignment operator?

<=


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

Krueger, Explorations in Economics 1e, Module 47

View Set

LCSW Exam: Therapist Development Center

View Set

GEO Plates, Plate Boundaries, and Driving Forces

View Set

Bio - Chapter 20 - genes within population (a)

View Set