Test 3 Chapters 7, 8, and 9 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Using floating-point numbers can lead to arithmetic errors because floating-point numbers

A

approximate values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

To read a list of lists that’s stored in a binary file, you use

A

the load() method of the pickle module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A binary file is like a text file in all but one of the following ways. Which one is it?

A

A binary file stores numbers with binary notation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A method for creating an object in a class.

A

constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CSV File

A

is a type of text file that stores multiple values in each line (.csv)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The csv module is a standard module so you don’t need to import it

A

Which of the following is not true about a CSV file?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Decimal Class

A

a decimal object that stores a decimal number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Exact Value

A

exact value that yields expected results

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Except Clause

A

except is used to catch and handle the exception(s) that are encountered in the try clause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Exception

A

occurs when you try to open a file that does not exist and the program crashes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

exit()

A

To cancel the execution of a program in the catch clause of a try statement, you can use the

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ceil()

A

returns ceiling value of x i.e., the smallest integer not less than x.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

FileNotFoundError

A

If a program attempts to read from a file that does not exist, which of the following will catch that error?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Finally Clause

A

a part of a try block that is executed no matter how the try block is exited

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

float(data)

A

method is used to return a floating point number from a number or a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

int(data)

A

method is used to return an integer point from a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Floating-Point Error

A

It’s a problem caused when the internal representation of floating-point numbers, which uses a fixed number of binary digits to represent a decimal number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Floating-Point Number

A

any number with a decimal point

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

floor()

A

returns floor of x i.e., the largest integer not greater than x.

20
Q

To define a variable named number that contains 123.4567 as a decimal number, not a floating-point number, which block of code would you use?

A

from decimal import Decimal

number = Decimal(123.4567)

21
Q

Immutable

A

cannot be changed

22
Q

Index

A

refers to a position within an ordered list. Python strings can be thought of as lists of characters; each character is given an index from zero (at the beginning) to the length minus one (at the end).

23
Q

lc.setlocale

A

opens access to the POSIX locale database and functionality. The POSIX locale mechanism allows programmers to deal with certain cultural issues in an application, without requiring the programmer to know all the specifics of each country where the software is executed.

24
Q

Locale Module

A

part of Python’s internationalization and localization support library. It provides a standard way to handle operations that may depend on the language or location of a user.

25
Q

Math Module

A

provides access to the mathematical functions defined by the C standard.

26
Q

Mutable

A

can be changed

27
Q

New Line

A

\n it is used to indicate the end of a line of text

28
Q

OS Error

A

a built-in exception in Python and serves as the error class for the os module, which is raised when an os specific system function returns a system-related error, including I/O failures such as “file not found” or “disk full”.

29
Q

Pickle

A

generally known as serializing an object, writing a python object to a binary file

30
Q

Pickle Module

A

makes it easier to work with binary files, it automates the process of storing an object in a binary file

31
Q

Print Format

A

prints the specified message to the screen, or other standard output device. The message can be a string, or any other object, the object will be converted into a string before written to the screen.

32
Q

print(data).format

A

give placeholders an explicit positional index.This allows for re-arranging the order of display without changing the arguments.

33
Q

Raise Statement

A

To throw an exception with Python code, you use the

34
Q

read()

A

returns the specified number of bytes from the file.

35
Q

readline()

A

method returns one line from the file.You can also specified how many bytes from the line to return, by using the size parameter.

36
Q

reader()

A

s used to read the file, which returns an iterable object.

37
Q

readlines()

A

returns a list containing each line in the file as a list item.

38
Q

Repitition Operator

A

makes multiple copies of a tuple and joins them all together.

39
Q

Scientific Notation

A

a method for expressing a given quantity as a number having significant digits necessary for a specified degree of accuracy, multiplied by 10 to the appropriate power, as 1385.62 written as 1.386 × 103.

40
Q

setlocale()

A

modifies the locale setting for the category.

41
Q

sys module

A

provides functions and variables used to manipulate different parts of the Python runtime environment.

42
Q

Text File

A

stores all of its data as characters and each line ends with a new line character

43
Q

Try Clause

A

all statements are executed until an exception is encountered. except is used to catch and handle the exception(s) that are encountered. Else lets you code sections that should run only when no exceptions are encountered

44
Q

Try Statement

A

you code any statements that may throw an exception in the try clause

45
Q

type()

A

either returns the type of the object or returns a new type object based on the arguments passed

46
Q

with open()

A

returns a file object, which has methods and attributes for getting information about and manipulating the opened file.

47
Q

With Statement

A

used to open a file object thats only available for its block of statements