Docsity

Functions and Classes: Reading and Writing Files, Exceptions, and Storing Data in Python, Schemes and Mind Maps of Programming Paradigms

Partial preview of the text

Download Functions and Classes: Reading and Writing Files, Exceptions, and Storing Data in Python and more Schemes and Mind Maps Programming Paradigms in PDF only on Docsity!

Lecturer: Nguyen Tuan Long, Phd Email: [email protected] Mobile: 0982 746 235

Chapter 2: Functions and classes

  • Reading from a File
  • Writing to a File
  • Exception
  • Storing Data

Chapter 2: Functions and classes 2

2.3. File and Execptions

Reading from a File

File Paths

Note Windows systems use a backslash () instead of a forward slash (/) when displaying file paths, but you can still use forward slashes in your code.

Reading from a File

Reading Line by Line

Reading from a File

Large Files: One Million Digits

Is Your Birthday Contained in Pi?

Practice

Writing to a File

Appending to a File

Practice

Reading from a File

The else Block

Reading from a File

Practice

Storing Data

Using json.dump() and json.load()

The JSON (JavaScript Object Notation)