ISA 221 Final Exam

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

This string method returns true if a string contains only alphabetic characters and is at least one character in length. a. the isalpha method b. the alpha method c. the alphabetic method d. the isletters method

the isalpha method

This string method returns true if a string contains only numeric digits and is at least one character in length. a. the digit method b. the isdigit method c. the numeric method d. the isnumber method

the isdigit method

You write this statement to respond to exceptions. a. run/ handle b. try/except c. try /handle d. attempt/except

try/except

Which of the following statements creates a tuple? a. values [1, 2, 3, 4] b. values {1, 2, 3, 4} c. values ( 1) d. values ( 1,)

values ( 1,)

This string method returns a copy of the string with all leading whitespace characters removed. a. lstrip b. rstrip c. remove d. strip_leading

lstrip

This built-in function returns the highest value in a list. a. highest b. max c. greatest d. best of

max

Today, CPUs are small chips known as __________.

microprocessors

Assume the following statement appears in a program: mylist = [ ] Which of the following statements would you use to add the string 'Labrador' to the list at index 0? a. mylist[0] = 'Labrador' b. mylist.insert(0, 'Labrador') c. mylist. append ( 'Labrador' ) d. mylist.insert('Labrador', 0)

mylist.insert(0, 'Labrador')

Before a file can be used by a program, it must be a. formatted. b. encrypted. c. closed. d. opened.

opened

A file that data is written to is known as a(n) a. input file. b. output file. c. sequential access file. d. binary file.

output file

A(n) __________ is a set of instructions that a computer follows to perform a task.

program

When an exception is generated, it is said to have been _______ a. built b. raised c. caught d. killed

raised

This marks the location of the next item that will be read from a file. a. input position b. delimiter c. pointer d. read position

read position

This file object method returns a list containing the file's contents. a. to_list b. getlist c. readline d. readlines

readlines

When working with this type of file, you access its data from the beginning of the file to the end of the file. a. ordered access b. binary access c. direct access d. sequential access

sequential access

This string method returns a copy of the string with all leading and trailing whitespace characters removed. a. clean b. strip c. remove_whitespace d. rstrip

strip

The contents of this type of file can be viewed in an editor such as Notepad. a. text file b. binary file c. English file d. human-readable file

text file

The part of a computer that runs programs is called __________.

the CPU

This removes an item at a specific index in a list. a. the remove method b. the delete method c. the del statement d. the kill method

the del statement

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

True

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

True

You can have more than one except clause in a try/except statement. T or F

True

You can use the + operator to concatenate two lists. T or F

True

You can use the for loop to iterate over the individual characters in a string. T or F

True

global

When possible, you should avoid using _________ variables in a program.

call

You _________ the module to execute it.

This list method adds an item to the end of an existing list. a. add b. add to c. increase d. append

append

When a file is opened in this mode, data will be written at the end of the file's existing contents. a. output mode b. append mode c. backup mode d. read-only mode

append mode

This type of file contains data that has not been converted to text. a. text file b. binary file c. Unicode file d. symbolic file

binary file

This is a small "holding section " in memory that many systems write data to before writing the data to a file. a. buffer b. variable c. virtual file d. temporary file

buffer

When a program is finished using a file, it should do this. a. erase the file b. open the file c. close the file d. encrypt the file

close the file

This function returns the length of a string. a. length b. size c. len d. lengthof

len

This will happen if you try to use an index that is out of range for a list. a. A ValueError exception will occur. b. An IndexError exception will occur. c. The list will be erased and the program will continue to run. d. Nothing-the invalid index will be ignored.

An IndexError exception will occur.

This will happen if you try to use an index that is out of range for a string. a. A ValueError exception will occur. b. An IndexError exception will occur. c. The string will be erased and the program will continue to run. d. Nothing-the invalid index will be ignored.

An IndexError exception will occur.

A file object's writelines method automatically writes a newline ( '\n' ) after writing each list item to the file. T or F

False

A flowchart shows the hierarchical relationships between functions in a program.

False

A statement in one function can access a local variable in another function.

False

Assume list1 references a list. After the following statement executes, list1 and list2 will reference two identical but separate lists in memory: list2 = list1 T or F

False

Calling a function and defining a function mean the same thing.

False

Function names should be as short as possible.

False

If you do not handle an exception, it is ignored by the Python interpreter, and the program continues to execute. T or F

False

In Python you cannot write functions that accept multiple arguments.

False

Lists in Python are immutable. T or F

False

The else suite in a try/except statement executes only if a statement in the try suite raises an exception. T or F

False

The finally suite in a try/except statement executes only if no exceptions are raised by statements in the try suite. T or F

False

The isupper method converts a string to all uppercase characters. T or F

False

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

False

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

False

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

False

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. T or F

False

When you call a string's split method, the method divides the string into two substrings. T or F

False

You can remove an element from a tuple by calling the tuple's remove method. T or F

False

You cannot have both keyword arguments and non-keyword arguments in a function call.

False

You do not have to have an import statement in a program to use the functions in the random module.

False

header

The first line of a module definition is known as the _________.

This is the first index in a list. a. - 1 b. 1 c. 0 d. The size of the list minus one

0

This is the first index in a string. a. - 1 b. 1 c. 0 d. The size of the string minus one

0

If you call the index method to locate an item in a list and the item is not found, this happens. a. A ValueError exception is raised. b. An Invalidindex exception is raised. c. The method returns - 1. d. Nothing happens. The program continues running at the next statement.

A ValueError exception is raised.

hierarchy chart

A _________ is a diagram that gives a visual representation of the relationships between modules in a program.

local variable

A _________ is a variable that is declared inside a module.

Top Down Design

A design technique that programmers use to break down an algorithm into modules is know as _________.

code reuse

A design technique that programmers use to reduce the duplication of code within a program and is a benefit of using functions as _________.

function

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

global variable

A variable that is visible to every module in the program is a _________.

argument

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

parameter

A(n) _________ is a special variable that receives a piece of data when a module is called.

scope

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

When the * operator's left operand is a list and its right operand is an integer, the operator becomes this. a. The multiplication operator b. The repetition operator c. The initialization operator d. Nothing-the operator does not support those types of operands.

The repetition operator

This is the last index in a list. a. 1 b. 99 c. 0 d. The size of the list minus one

The size of the list minus one

This is the last index in a string. a. 1 b. 99 c. 0 d. The size of the string minus one

The size of the string minus one

IPO chart

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

sqrt

This is a math module function

library function

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

random

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).

uniform

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

randint

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

return

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

Boolean

This type of function returns either True or False

A function in python can return more than one value.

True

A hierarchy chart does not show the steps that are taken inside a function.

True

A list can be an element in another list. T or F

True

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

True

Functions make it easier for programmers to work in teams.

True

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.

True

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

True

Once a string is created, it cannot be changed. T or F

True

Some library functions are built into the Python interpreter

True

The del statement deletes an item at a specified index in a list. T or F

True

The repetition operator ( *) works with strings as well as with lists. T or F

True

Tuples in Python are immutable. T or F

True

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. a. ordered access b. binary access c. direct access d. sequential access

direct access

This term refers to an individual item in a list. a. element b. bin c. cubbyhole d. slot

element

This is a section of code that gracefully responds to exceptions. a. exception generator b. exception manipulator c. exception handler d. exception monitor

exception handler

This is a single piece of data within a record. a. field b. variable c. delimiter d. subrecord

field

This string method returns the lowest index in the string where a specified substring is found. a. first index of b. locate c. find d. index of

find

The physical devices that a computer is made of are referred to as __________.

hardware

This operator determines whether one string is contained inside another string. a. contains b. is in c. == d. in

in

This is a number that identifies an item in a list. a. element b. index c. bookmark d. identifier

index

A file that data is read from is known as a(n) a. input file. b. output file. c. sequential access file. d. binary file.

input file

This function returns the length of a list. a. length b. size c. len d. lengthof

len


Set pelajaran terkait

Human Resource Management or HRM

View Set

Sustantivos femeninos con terminación "-cion"/"-sion"/"-dad"/"-tad"/"-tud"

View Set

Nurs 211 Chapter 17: Implementing

View Set

MIS Chapter 1, MIS Chapter 2, MIS Chapter 3, MIS Chapter 4

View Set

Chapter 8: Financing Real Estate

View Set

Mother Baby NCLEX practice questions week 1

View Set

Three types of Cartilage (connective tissue)

View Set

Biology 114- Chapter 14 LearnSmart

View Set

Chapter 29: Care of Patients with Respiratory Emergencies (PRACTICE)

View Set