Just because I seen someone else ask but they didn't have enough information.

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 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?

Just because I seen someone else ask but they didnt have enough informationIf a filesystem has a block size of 4096 bytes this means that a file comprised of on class=

Respuesta :

Answer:

Following are the program to the given question:

def calculate_storage(filesize):#definging a method calculate_storage that takes filesize as a parameter  

 block_size = 4096#definging block_size that holds value

 full_blocks = filesize//block_size#definging full_blocks that divides the value and hold integer part

 partial_block_remainder = filesize%block_size#definging partial_block_remainder that holds remainder value

 if partial_block_remainder > 0:#definging if that compare the value

   return block_size*full_blocks+block_size#return value

 return block_size*full_blocks#return value

print(calculate_storage(1))    # calling method by passing value

print(calculate_storage(4096)) # calling method by passing value

print(calculate_storage(4097)) # calling method by passing value

Output:

4096

4096

8192

Explanation:

In this code, a method "calculate_storage" is declared that holds a value "filesize" in its parameters, inside the method "block_size" is declared that holds an integer value, and defines "full_blocks and partial_block_remainder" variable that holds the quotient and remainder value and use it to check its value and return its calculated value. Outside the method, three print method is declared that calls the method and prints its return value.

ACCESS MORE
EDU ACCESS