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
How many total bits are required for a direct-mapped cache with 128 blocks and a block size of 8 bytes, assuming a 4GB main memo
Marysya12 [62]

Answer:

32

Explanation:

Total bits will be 32 only as address is of 32 bits

(meaning to ask the size of the cache)

7 0
2 years ago
If you have 60fps on your laptop tell me one way you can go to 240fps
choli [55]

Answer: NO

Explanation:

A 60hz monitor refreshes the screen 60 times per second. Therefore, a 60hz monitor is only capable of outputting 60fps

4 0
2 years ago
Read 2 more answers
In a Java Script language. create a two-dimension array consisting of numbers representing costs. After creating the array, prin
Tanzania [10]

Answer:

Can you elaborate more?

Explanation:

5 0
3 years ago
A communication medium which allows receivers to observe multiple cues, such as body language and tone of voice, and allows send
castortr0y [4]

Answer: Rich medium

Explanation: A communication is said to be rich id it provides the services like observing the body language, immediate communication, instant judging of the voice tone etc. These factors are commonly found in the face to face interaction which is considered as the rich source of communication. It is considered as rich medium because  it has the capability of receiving the output immediately .

4 0
3 years ago
Which soft skills would these mobile app developers need to use in the situations described?
Ber [7]

Answer:

1: work ethic/presentation.

2: communication.

3: adaptability.

4: creativity.

(these are all guesses so i'm not 100% sure)

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • You should use _____ software for writing a letter.
    10·1 answer
  • A colleague asks you to research a CPU for a new server that will run Windows Server 2019. He explains the server roles that he
    7·1 answer
  • Which is better analog music or digital music
    15·2 answers
  • What is the correct order of headers, from left to right, in a completed frame?
    8·1 answer
  • What is a multipurpose network device?
    10·1 answer
  • . ------------ means that the two merging companiesbecame history and a new firm
    10·1 answer
  • Write a program that takes the account's present value, monthly interest rate, and the number of months that the money will be l
    5·1 answer
  • Quiénes se benefician de la realidad virtual​
    12·1 answer
  • Please Help, Thank you!
    5·1 answer
  • How can we avoid falling victim to a phishing or pharming scheme
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!