1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klemol [59]
3 years ago
9

You are utilizing the pickle.load function to load objects into a program from a file. However, your program raises an exception

as soon as the end of the file is reached. What must you do?
Social Studies
1 answer:
lesantik [10]3 years ago
6 0

Answer:

When the program raises an exception as soon as the end of the is reached, this exception makes the input process difficult. We have no specific or clear way to encounter the end of the file before the exception is raised.

So to resolve this Python's try except statement can be used. This statement catches the exception and enables the program to recover. We can construct an input file loop. This loop will keep loading objects until the end of the file is detected. Below is an example to load objects from the file into a new list.

lst=list()

fileObj = open("item.dat","rb")

while True:

try:

      item= pickle.load(fileObj)

      lst.append(item)

      except EOFError:

               fileObj.close()

               break

print(lst)

The file name is item.dat and new list is named as lst. When the end of the file is encountered EOFError is raised and except clause with EOFError closes the input file and breaks out of the loop.

You might be interested in
Each of the following may result from an excise tax EXCEPT: A. increase in cost of production B. increase in consumer price C. r
777dan777 [17]

Answer:

IT IS B

Explanation:

8 0
3 years ago
Name at least four things teachers should keep in mind when delivering positive or negative consequences.
mezya [45]
A.Positive outcomes are best when the educator discloses to the students precisely what they did accurately. 

b.Positive results can be similarly as great, or considerably more intense than negative outcomes in averting undesirable conduct if utilized accurately. 

c.Negative outcomes must be conveyed with conviction to demonstrate the understudy that they are sure about their choice and won't alter their opinion. 

d.Negative results ought to be conveyed solidly however without outrage and should be connected to the negative conduct.
5 0
3 years ago
Question 4 unsaved the process of simultaneously analyzing the behavior of individuals and the society that shapes that behavior
kodGreya [7K]

I believe the answer is: figuration

Figuration tend to be conducted with top down process. It observe how a certain regulation or expectation that is made by the society affect the overall behaviour of a certain part of population. (for example: figuring out why women's general interest in stem-related field is lesser than the men counterpart is caused by something societal)

3 0
3 years ago
One method that can be used to evaluate capital budgeting projects with different lives is to convert the project’s cash flows t
liubo4ka [24]

Answer: Equivalent annual annuity

Explanation:

Equivalent annual annuity  is the method used for capital budgeting for performing comparison between unequal lives and mutually explosive projects being carried out.

This approach considers project as annuities and then calculation of net worth of that project in present day is done.Through this process, annual cash is evaluated for different projects.It contains time value of money as an  benefit.

7 0
4 years ago
Ruthie's house is clean, however, in her closets are many bags full of old magazines, newspapers, and mail. Ruthie says she will
mr Goodwill [35]

Ruthie may be diagnosed with <u>hoarding</u> disorder.

8 0
4 years ago
Other questions:
  • CRITICAL THINKING (COLLEGE COURSE)
    14·1 answer
  • Identify the fallacy.
    14·2 answers
  • One role of the federal governments justice department is to
    7·1 answer
  • A pure market economy is sometimes called pure
    6·2 answers
  • How did the Fugitive Slave Act lead to the Civil War?
    6·2 answers
  • What two rivers flow through the North China Plain?
    9·1 answer
  • 2. To make covering clean and neat in appearance, ____ is used because the tape is not visible.
    11·1 answer
  • When was the The rise of Chinese civilization
    14·1 answer
  • True or false: Animal cells have chloroplasts and go through photosynthesis
    14·2 answers
  • What roles do the musk ox play in the tundra ecosystem?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!