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
AVprozaik [17]
2 years ago
12

If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s

torage. A file made up of 4097 bytes will use 4096 bytes of storage. A file made up of 4097 bytes will use 4096*2=8192 bytes of storage. Knowing this, can you fill in the gaps in the calculate_storage function below, which calculates the total number of bytes needed to store a file of a given size?
1 def calculate_storage(filesize):
2 block_size = 4096
3 # Use floor division to calculate how many blocks are fully occupied
4 full_blocks = ___
5 # Use the modulo operator to check whether there's any remainder
6 partial_block_remainder = ___
7 # Depending on whether there's a remainder or not, return
8 if partial_block_remainder > 0:
9 return ___
10 return ___
11
12 print(calculate_storage(1)) # Should be 4096
13 print(calculate_storage(4096)) # Should be 4096
14 print(calculate_storage(4097)) # Should be 8192
15 print(calculate_storage(6000)) # Should be 8192
Computers and Technology
1 answer:
mars1129 [50]2 years ago
8 0

Answer:

def calculate_storage(filesize):

   block_size = 4096

   full_blocks = filesize // block_size

   partial_block = filesize % block_size

   if partial_block > 0:

       return (full_blocks + 1) * block_size

   return filesize

print(calculate_storage(1))

print(calculate_storage(4096))

print(calculate_storage(4097))

Explanation:

The python program defines the function 'calculate_storage' that calculates the block storage used. It gets the number of blocks used to store the data by making a floor division to get the integer value, then it checks for remaining spaces in the block. If there are spaces left, it adds one to the full_blocks variable and returns the result of the multiplication of the full_blocks and block_size variables.

You might be interested in
17.
Radda [10]
Sorry to answer you so late but that would be truth because that is the first rule of science which is what thermodynamics depends in. 

The first law of thermodynamics is a type of law of conservation but with thermodynamics systems. 


So, in gogle I found this: "The law of conservation of energy states that the total energy of an isolated system is constant; energy can be transformed from one form to another, but cannot be created or destroyed."

Like I said, sorry to reply so late but I hope this helped! =)
3 0
2 years ago
A written guarantee to fix or replace an item is called a _____.
VladimirAG [237]
A warranty is a statement given by the manufacturer or other company
3 0
3 years ago
Read 2 more answers
Taylor volunteered as a computer support specialist for his university's online library. Which part of his resume should include
Sophie [7]
 it would be experience 
<span />
8 0
3 years ago
Read 2 more answers
Who go to Tennessee Connection Academy And If yall Do plz comment down below.
zalisa [80]

Answer:

it a or d

Explanation:

7 0
2 years ago
When a customer makes an online hotel booking the database is updated by using
Valentin [98]
I think it’s a form,if wrong please don’t be mad
4 0
3 years ago
Read 2 more answers
Other questions:
  • Discuss why mtv initially had a difficulty securing enough ads
    10·1 answer
  • For every $1 of deposits, the banks can increase ________________ by the value of the Money Multiplier.
    15·1 answer
  • Write a loop to output the word EXAM 99 times
    8·1 answer
  • Which feature allows users to see all suggestions for edits to a document at once?
    7·2 answers
  • Complete the following sentences with the correct form of the verbs in brackets.
    6·1 answer
  • Use the drop-down menus to complete the statements about using column breaks in word 2016
    6·2 answers
  • 3. Special keys labelled Fl to F12.
    8·1 answer
  • A continuous and differentiable function f(x) with the following properties: f(x) is decreasing at x=−5 f(x) has a local minimum
    13·1 answer
  • modify hw 02 c.c to use envp instead of environ. be sure that you understand how the code works. provide liberal comments to exp
    12·1 answer
  • Write l for law of enrtia,ll for law of Acceleration and lll for law of enteraction.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!