CS 0012 Midterm

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

T/F A compound Boolean expression created with the and operator is true only when both subexpressions are true

T

T/F A decision structure can be nested inside another decision structure

T

T/F A function in Python can return more than one value

T

T/F A hierarchy chart does not show the steps that are taken inside a function

T

T/F Complex mathematical expressions can sometimes be simplified by breaking out part of the expression and putting it in a function

T

T/F Functions make it easier for programmers to work in teams

T

T/F IPO charts provide only brief descriptions of a function's input, processing, and output, but do not show the specific steps taken in a function

T

T/F In Python, the first character of a variable name cannot be a number

T

T/F In Python, you can specify which parameter an argument should be passed into a function call

T

T/F In a math expression, multiplication and division take place before addition and subtraction

T

T/F In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop

T

T/F Some library functions are built into the Python interpreter

T

T/F The following statement subtracts 1 from x: x = x - 1

T

T/F The while loop is a pretest loop

T

T/F When an input file is opened, its read position is initially set to the first item in the file

T

T/F When you open a file that already exists on the disk using the 'w' mode, the contents of the existing file will be erased

T

A(n) ___ variable keeps a running total

accumulator

A(n) ___ is a set of well-defined logical steps that must be taken to perform a task

algorithm

A magic number is ___

an unexplained value that appears in a program's code

A compound Boolean expression created with the ___ operator is true only if both of its subexpressions are true

and

When a file is opened in this mode, data will be written at the end of the file's existing contents

append mode

A(n) ___ is a piece of data that is sent into a function

argument

A(n) ___ makes a variable reference a value in the computer's memory

assignment statement

The -= operator is an example of a(n) ___ operator

augmented assignment

This type of file contains data that has not been converted to text

binary file

This is a small "holding section" in memory that many systems write data to before writing the data to a file

buffer

You ___ a function to execute it

call

When a program is finished using a file, it should do this

close the file

A design technique that helps to reduce the duplication of code within a program and is a benefit of using functions is ___

code reuse

Short notes placed in different parts of a program explaining how those parts of the program work are called ___

comments

A ___-controlled loop uses a true/false condition to control the number of times that it repeats

condition

A ___-controlled loop repeats a specific number of times

count

A ___ structure can execute a set of statements only under certain circumstances

decision

When working with this type of file, you can jump directly to any piece of data in the file without reading the data that comes before it

direct access

A(n) ___ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false

dual alternative decision

A string literal in Python must be enclosed in ___

either single-quotes or double-quotes

Validation loops are also known as ___

error traps

This is a single piece of data within a record

field

A ___ is a Boolean variable that signals when some condition exists in the program

flag

Suppose the following statement is in a program: price = 99.0. After this statement executes, the price variable will reference a value of which data type?

float

Which built-in function can be used to convert an int value to a float?

float ( )

A ___ is a diagram that graphically depicts the steps that take place in a program

flowchart

A group of statements that exist within a program for the purpose of performing a specific task is a(n) ___

function

GIGO stands for ___

garbage in, garbage out

When possible, you should avoid using ___ variables in a program

global

A variable that is visible to every function in a program file is a ___

global variable

The first line of a function definition is known as the ___

header

A ___ is a diagram that gives a visual representation of the relationships between functions in a program

hierarchy chart

You use a(n) ___ statement to write a single alternative decision structure

if

You use a(n) ___ statement to write a dual alternative decision structure

if-else

A(n) ___ loop has no way of ending and repeats until the program is interrupted

infinite

The integrity of a program's output is only as good as the integrity of the program's ___

input

Which built-in function can be used to read input that has been typed on the keyboard?

input ( )

A file that data is read from is known as a(n) ___

input file

Each repetition of a loop is known as a(n) ___

iteration

This is a prewritten function that is built into a programming language

library function

A ___ is a variable that is created inside a function

local variable

A ___ error does not prevent the program from running, but causes it to produce incorrect results

logic

and, or, and not are ___ operators

logical

A ___ is a name that represents a value that does not change during the program's execution

named constant

The ___ operator takes a Boolean expression as its operand and reverses its logical value

not

Before a file can be used by a program, it must be ___

opened

In the expression 12 + 7, the values on the right and left of the + symbol are called ___

operands

A compound Boolean expression created with the ___ operator is true if either of its subexpressions is true

or

A file that data is written to is known as a(n) ___

output file

A(n) ___ is a special variable that receives a piece of data when a function is called

parameter

The ___ keyword is ignored by the Python interpreter and can be used as a placeholder for code that will be written later

pass

The while loop is a ___ type of loop

pretest

The input operation that appears just before a validation loop is known as the ___

priming read

An informal language that has no syntax rules and is not meant to be compiled or executed is called ___

pseudocode

This standard library function returns a random integer within a specified range of values

randint

This standard library function returns a random floating-point number in the range of 0.0 up to 1.0 (but not including 1.0)

random

This marks the location of the next item that will be read from a file

read position

The symbols >, <, and == are all ___ operators

relational

This statement causes a function to end and sends a value back to the part of the program that called the function

return

A(n) ___ is the part of a program in which a variable may be accessed

scope

A(n) ___ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list

sentinel

When working with this type of file, you can access its data from the beginning of the file to the end of the time

sequential access

A ___ structure provides one alternative path of execution

single alternative decision

A ___ is a single function that the program must perform in order to satisfy the customer

software requirement

This is a math module function

sqrt

A ___ is a sequence of characters

string

The contents of this type of file can be viewed in an editor such as Notepad

text file

A design technique that programmers use to break down an algorithm into functions is known as ___

top-down design

This standard library function returns a random floating-point number within a specified range of values

uniform

A ___ is any hypothetical person using a program and providing input for it

user

A ___ is a name that references a value in the computer's memory

variable

A(n) ___ expression has a value of either True or False

Boolean

This type of function returns wither True or False

Boolean

T/F A condition-controlled loop always repeats a specific number of times

F

T/F A flowchart shows the hierarchical relationships between functions in a program

F

T/F A program can be made of only one type of control structure. You cannot combine structures

F

T/F A single alternative decision structure tests a condition and then takes one path if the condition is true, or another path if the condition is false

F

T/F A statement in one function can access a local variable in another function

F

T/F Calling a function and defining a function mean the same thing

F

T/F Function names should be as short as possible

F

T/F If you print a variable that has not been assigned a value, the number 0 will be displayed

F

T/F In Python, you cannot write functions that accept multiple arguments

F

T/F It is not necessary to initialize accumulator variables

F

T/F Programmers must be careful not to make syntax errors when writing pseudocode programs

F

T/F The phrase "divide and conquer" means that all of the programmers on a team should be divided and work in isolation

F

T/F The process of input validation works as follows: when the user of a program enters invalid data, the program should ask the user "Are you sure you meant to enter that?" If the user answers "yes," the program should accept the data

F

T/F The process of opening a file is only necessary with input files. Output files are automatically opened when data is written to them

F

T/F To calculate the total number of iterations in a nested loop, add the number of iterations of all the loops

F

T/F Variable names can have spaces in them

F

T/F When a file that already exists is opened in append mode, the file's existing contents are erased

F

T/F When working with a sequential access file, you can jump directly to any piece of data in the file without reading the data that comes before it

F

T/F You can write any program using only sequence structures

F

T/F You cannot have both keyword arguments and non-keyword arguments in a function call

F

T/F You do not need to have an import statement in a program to use the functions in the random module

F

This is a design tool that describes the input, processing, and output of a function

IPO chart

This symbol marks the beginning of a comment in Python

#

This operator performs division, but instead of returning the quotient it returns the remainder

%

This is an operator that raises a number to a power

**

This operator performs integer division

//


Kaugnay na mga set ng pag-aaral

Investments Test Bank Missed Q's 1

View Set

AP2 Reproduction Menstrual Cycle Steele Buie

View Set

Human A&P Terms for the FINAL : Be able to define or describe each of the following. I will randomly choose 50 of these in which you will need to define

View Set

Control - Working with control charts

View Set

Series 63 Chapter 1 Continued Further

View Set

NURS intervention EXAM 2 PrepU & lecture quizzes

View Set