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]
3 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]3 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
Complete the code to finish this program to analyze the inventory for a store that sells purses and backpacks.
sp2606 [1]

Answer:

import csv

fileIn = open("data/bags.txt","r")

countPurse = 0

textFile= csv.reader(fileIn)

for bag in textFile:    

   if bag[ 1 ] == 'purse':

       countPurse = countPurse + int(bag[6])

fileIn.close()

print("Number of purses:",countPurse)

Explanation:

I hope this helps!

3 0
3 years ago
How many accelerometers are there in an IRS system?
slega [8]

The number of accelerometers that are in an IRS system are three (3).

<h3>What is an IRS system?</h3>

IRS system is an abbreviation for inertial reference system (IRS) and it can be defined as a navigation system that is designed and developed to provide inertial navigation data to various user systems, especially by using a ring-laser gyro.

In the Aviation and Engineering filed, he number of accelerometers that are in an inertial reference system (IRS) system are three (3).

Read more on navigation system here: brainly.com/question/26052911

#SPJ12

5 0
2 years ago
How does data structure affect the programs we use​
Semmy [17]

Answer The data structure and algorithm provide a set of techniques for that program in order for it to function. think of it like yt

Explanation:

7 0
3 years ago
No PFP gang<br> lollolololololol
Lorico [155]
Yeah lol i don’t have one either
3 0
3 years ago
Read 2 more answers
Limestone deposits indicate that the location was:
jek_recluse [69]
B: formed by an active volcano
8 0
4 years ago
Other questions:
  • Consider the following JavaScript program:
    8·1 answer
  • List two ways that guest could be defined
    12·2 answers
  • ASAP
    12·1 answer
  • Which type of spreadsheet cell represents the left hand sides (lhs) formulas in an optimization analysis?
    5·1 answer
  • Titus would like to make his products stand out a little more in his Excel spreadsheet. What actions would help to distinguish o
    15·1 answer
  • Which of the following modes of replication requires a very low latency network connection and ensures data remains in synch wit
    13·1 answer
  • 1. The @ symbol is used to denote:​
    7·1 answer
  • Who initially developed what is now known as the internet?
    5·1 answer
  • You wrote a program to find the factorial of a number. In mathematics, the factorial operation is used for positive integers and
    14·2 answers
  • Images that are made up of pixels and cannot be resized without losing quality?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!