Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python problem 1. Consider a program that possesses a function that reads information from a file, called read_file() . The read_file function normally intends to

Python problem

1. Consider a program that possesses a function that reads information from a file, called read_file(). The read_file function normally intends to return a list containing pieces of information from the file that is read.

If the file reading fails (i.e. raises an exception), what should the read information function do?

A.Catch the exception and return None in the finally clause.

B.Catch the exception and print a message in the finally clause.

C.Do nothing (dont catch the exception)

D.Catch the exception and print a message in the except clause.

E.Catch the exception and return None in the except clause.

Problem 2

In writing networked programs, we utilized sockets to connect to other computers. We switched from the use of sockets to the use of what we called pseudo-files.

(a) What purposes did these pseudo-files serve, in terms of improvements over just writing and reading directly to and from sockets?

(b) Why did we call flush() when writing to pseudo-files?

Problem 3

When writing programs that access file systems, we opted to use particular libraries from the Python Standard Library like pathlib.

(a) Why did we use pathlib over just using open() or os.path on files? Give two specific reasons.

(b) What was the purpose of the method iterdir of the Path class from the pathlib library?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago