def calculate_storage(filesize): block_size = 4096 # Use floor division to calculate how many blocks are fully occupied full_blocks = ___ # Use the modulo operator to check whether there's any remainder partial_block_remainder = ___ # Depending on whether there's a remainder or not, return # the total number of bytes required to allocate enough blocks # to store your data. if partial_block_remainder > 0: return ___ return ___ print(calculate_storage(1)) # Should be 4096 print(calculate_storage(4096)) # Should be 4096 print(calculate_storage(4097)) # Should be 8192 print(calculate_storage(6000)) # Should be 8192
Answers
Answered by
4
Answer:
E0e0rir94ie93o
Answered by
4
Answer:
def calculate_storage(filesize):
block_size = 4096
# Use floor division to calculate how many blocks are fully occupied
full_blocks = filesize//block_size
# Use the modulo operator to check whether there's any remainder
partial_block_remainder = filesize%block_size
# Depending on whether there's a remainder or not, return
# the total number of bytes required to allocate enough blocks
# to store your data.
if partial_block_remainder > 0:
return block_size*(full_blocks+1)
return block_size
print(calculate_storage(1)) # Should be 4096
print(calculate_storage(4096)) # Should be 4096
print(calculate_storage(4097)) # Should be 8192
print(calculate_storage(6000)) # Should be 8192
Similar questions
English,
4 months ago
Geography,
8 months ago
Social Sciences,
8 months ago
Physics,
11 months ago
Social Sciences,
11 months ago