COSC 131: File Processing, Strings and Exceptions

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/25

flashcard set

Earn XP

Description and Tags

Flashcards for COSC 131: Intro to Programming for Engineers, covering file processing, strings, and exceptions.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

26 Terms

1
New cards

Text File

A collection of characters stored in a computer file system.

2
New cards

File Extension

Indicates the type of data the file likely contains and is used by the operating system to choose which application to open the file.

3
New cards

File Path

The location of a file within the directory structure of a computer's file system.

4
New cards

open(path, mode)

Opens a file for reading, writing, or appending.

5
New cards

read()

Returns the entire contents of a file as a single string.

6
New cards

write()

Writes data to a file.

7
New cards

close()

Closes a file, releasing system resources.

8
New cards

Escape Sequence

A character that represents a special control function, such as a newline or tab.

9
New cards

\n

Represents a new line.

10
New cards

\t

Represents a tab.

11
New cards

Multiline strings

Strings that contain embedded newline characters.

12
New cards

str.splitlines()

Splits a string into a list of substrings based on newline characters.

13
New cards

startswith()

Checks if a string starts with a specified substring.

14
New cards

endswith()

Checks if a string ends with a specified substring.

15
New cards

str.split()

Splits a string into a list of substrings based on a specified delimiter.

16
New cards

strip()

Removes leading and trailing whitespace from a string.

17
New cards

upper()

Changes the capitalization of a string to uppercase.

18
New cards

lower()

Changes the capitalization of a string to lowercase.

19
New cards

title()

Changes the capitalization of a string to title case.

20
New cards

urllib.request.urlopen()

Used to open Internet resources as files.

21
New cards

Exceptions

Unexpected events that disrupt the normal flow of a program's execution.

22
New cards

FileNotFoundError

An exception raised when a file cannot be found.

23
New cards

ValueError

An exception raised when a function receives an argument of an improper value.

24
New cards

try block

A block of code where exceptions are anticipated.

25
New cards

except block

A block of code that handles a raised exception.

26
New cards

raise

Force an exception to occur.