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
Helen [10]
3 years ago
5

The function below tries to create a list of integers by reading them from a file. The file is expected to have a single integer

per line and the code works correctly in that case. If any of the lines don't contain just an integer, than this code fails. Fix this code so that it ignores any lines that don't contain integers instead of raising an exception. Do this with try/except blocks. Your code should still return the list of integers from the lines that contain integers.

Computers and Technology
1 answer:
Setler [38]3 years ago
4 0

Answer:

Check the explanation

Explanation:

def get_list_of_integers_from_file(filename):

int_list=[]

for line in open(filename).readlines():

try:

int_list.append(int(line))

except:

continue

return int_list

print(get_list_of_integers_from_file('file.txt'))

 

File.txt:

Kindly check the output below.

You might be interested in
When troubleshooting firewalls, you should never attempt to repeat the problem because you could do more damage. T/F
Zinaida [17]

Answer:

TRUE

Explanation:

the given statement is correct hence TRUE

troubleshooting is problem solving often applied to repair failed product .

Firewall is used for network security for the computer is monitors and controls the incoming and outgoing network traffic.

Basically what Firewall do is it create barrier between trusted networks and not trusted network.

8 0
3 years ago
4. When you're working with a word processing document and you press the Del key, what happens?
Thepotemich [5.8K]
When you're working with a word processing document and you press the Del key, C. The entire document is deleted.

I have actually tried doing this to know which choice is the correct answer. I opened a new document, typed some words then pressed the Del key.... NOTHING HAPPENED! The character to the right of the cursor was not deleted, the entire document was not deleted, nor was the formatting style deleted.

I chose letter C because after seeing that nothing happened in an open document, I saved said document and opened the folder where the document was saved. I selected the document and pressed the Del key... a prompt appeared asking me if I was sure that I want to move my file to the Recycle Bin? I clicked yes... the entire document is deleted

7 0
4 years ago
Read 2 more answers
Kenny is asked to submit a photo for the annual photographic competition. He decided to capture a photo with the light-painting
Alja [10]

A condition which would be necessary to achieve this effect is the use of: D. tilt-shift lens.

<h3>What is tilt-shift photography?</h3>

Tilt-shift photography can be defined as a creative and unique technique in photography that involves the manipulation of a camera, so as to enable a life-sized subject (location) to have a light-painting effect or look like a miniature-scale model.

This ultimately implies that, tilt-shift lens is a condition which would be necessary to capture a photo with the light-painting effect.

Read more on photography here: brainly.com/question/26643795

#SPJ1

7 0
2 years ago
What's the main piece of information you look for in an e-mail message you're investigating??
Black_prince [1.1K]
The ip address or originating e-mail domain
4 0
3 years ago
Read 2 more answers
write the algorithm, flowchart and BASIC program to calculate the area of the rectangle length 50m and width 30m.​
GalinKa [24]

Answer:

The Basic Program is as follows:

10 LENGTH = 50

15 WIDTH = 30

20 AREA = WIDTH * LENGTH

25 PRINT AREA

30 END

The Algorithm is as follows:

1. Start

2. Let Length = 50

3. Let Width = 30

4. Compute Area = Length * Width

5. Display Area

6. Stop

See Attachment for flowchart (flowchart is designed using draw io tools)

Explanation:

The flowchart, algorithm and basic program all follow the same sequence and explanation

Using the basic program as a case study;

Line number 10: The program starts by initializing LENGTH to 50

Line number 15: It then initializes WIDTH to 30

Line number 20: The AREA is calculated by LENGTH * WIDTH

Line number 25: The value of AREA is printed afterwards

Line number 30: Lastly, the program stops execution

8 0
3 years ago
Other questions:
  • Lydia used software and numerical data to create bar graphs. What software did she use?
    8·2 answers
  • Let's say you're creating a search stream in your hootsuite dashboard, to find mentions of the phrase vacation holiday getaway.
    15·1 answer
  • I want to customize my company's logo, name, address, and similar details in all my business documents what option should use?
    12·1 answer
  • Which of the following refers to a feature of wikis that allows the restoring of earlier work in the event of a posting error, i
    9·1 answer
  • Consider a channel that can lose packets but has a maximum delay that is known. Modify Protocol rdt2.1 to include sender timeout
    11·1 answer
  • What allows users to connect via the Internet to its private network?
    11·2 answers
  • What does it mean for a heap to be complete?
    7·1 answer
  • Translation of a file into a coded Format that occupies less space than the original file is called
    6·1 answer
  • Zack sees an online contest. He could win $10,000 instantly! On the sign-up form he enters his name and email address. He is als
    9·1 answer
  • Consider the conditions and intentions behind the creation of the internet—that it was initially created as a tool for academics
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!