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
What are the controls in the Capture panel? Define each controls
MArishka [77]

Answer:

.............

........

8 0
2 years ago
Adding _____ will allow the user to create text as it will often appear in publications with multiple articles, such as a newspa
mart [117]
Does applications make sense <span />
5 0
3 years ago
Read 2 more answers
Manufacturing changes what materials into useful products
Vlad [161]

Answer:

Raw Materials

Explanation:

Raw materials are the resources used by a company to produce its finished goods and products. some common raw materials are cocoa for beverages, limestone for cement etc

3 0
3 years ago
What is the decimal equivalent of 11BA?
allsm [11]

Answer:

To convert hexadecimal number 11BA to decimal, follow these two steps:

Start from one's place in 11BA : multiply ones place with 16^0, tens place with 16^1, hundreds place with 16^2 and so on from right to left

Add all the product we got from step 1 to get the decimal equivalent of 11BA.

Using the above steps, here is the work involved in the solution for converting 11BA to decimal number (Don't forget that we start from ones place to so on...)

Decimal equivalent of "A" = (A) 10 × 16^0 = 10

Decimal equivalent of "B" = (B) 11 × 16^1 = 176

Decimal equivalent of "1" = 1 × 16^2 = 256

Decimal equivalent of "1" = 1 × 16^3 = 4096

Decimal equivalent of "11BA" = 409625617610

11BA = 4538

Here is the final answer, The hexadecimal number 11BA converted to decimal is therefore equal to:

4538

4 0
2 years ago
Instructions:Select the correct answer.
Luba_88 [7]
<span>A.) system administrator

Hope that helps</span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • Reading is the process of transferring data, instructions, and information from memory to a storage medium.
    15·1 answer
  • which of the following is an educated or informed guess that is proposed and supported with verifiable evidence
    12·1 answer
  • When using a function to preform a calculation how would you select the range of numbers to use
    13·1 answer
  • All tif files start at offset 0 with what 6 hexadecimal characters?​
    11·1 answer
  • In what software development model does activity progress in a lock-step sequential process where no phase begins until the prev
    7·1 answer
  • A deluxe meal, represented by a DeluxeMeal object, includes a side dish and a drink for an additional cost of $3. The DeluxeMeal
    14·1 answer
  • Which of the following statements should be avoided when developing a mission statement?
    13·1 answer
  • A network consists of 75 workstations and three servers. The workstations are currently connected to the network with 100 Mbps s
    12·1 answer
  • How do I use files and functions in programming?
    10·1 answer
  • While working in a group of two the members are not getting along. You bring the two members together so they can discuss this i
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!