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

This chapter from the Python programming course covers various aspects of functions and classes, including reading and writing files, handling exceptions, and storing data using JSON. Topics include reading an entire file, reading line by line, making a list of lines, writing to a file, handling ZeroDivisionError exceptions, and using try-except blocks. Students will also learn how to count the frequency of each word in a list of filenames and store data using JSON.

Typology: Schemes and Mind Maps

2021/2022

Uploaded on 10/28/2022

thanh-duong-nhat
thanh-duong-nhat 🇻🇳

10 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecturer:
Nguyen Tuan Long,
Phd
Email:
Mobile:
0982 746 235
Chapter 2: Functions and classes
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

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)