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
Groups to which we belong are defined late in our development true or false
Anna71 [15]
The answer is false......
7 0
3 years ago
he is trying to find information on the internet first he navigated to a search engine entered the keywords database administrat
Vlada [557]

Answer:

b

Explanation:

b

6 0
3 years ago
Can someone help me with these questions on linear dimensions pls
andrew-mc [135]
Size dimentions reffer to overall dimentions and will tell the overall width, lenth height and depth of something location dimentions means the locatuon of each geometric shape.
7 0
3 years ago
Read 2 more answers
What is the most accurate way to describe the excerpt?
kifflom [539]

choose the option it is a dependent clause

7 0
4 years ago
Read 2 more answers
Mention at least five devices used for digitizing data
creativ13 [48]
Answer:
1. Cloud Storage Solutions
2. Digital Communication Tools
3. Cloud ERP Systems
4. CRM Platforms
5. Digital Accounting Tools

For more information, please visit: https://www.gend.co/blog/the-digitisation-tools-with-the-biggest-impact-for-business?hs_amp=true

Hope this helps!!
3 0
2 years ago
Other questions:
  • A type of address translation in which a gateway has a pool of public ip addresses that it is free to assign to a local host whe
    8·1 answer
  • Technology can most broadly be defined as anything that does which of the following ?
    11·1 answer
  • ​according to your text, digital natives tend to prefer different digital communication channels more than do digital immigrants
    5·1 answer
  • Sukhi needs to insert a container into her form to collect a particular type of information. Which object should she insert?
    6·1 answer
  • Wireshark is an example of what type of utility? A) Packet sniffer B) Port scanner C) Vulnerability scanner D) Content filter
    11·1 answer
  • Annie wants to create a polka-dot pattern. She wants the dots to be distributed evenly in her pattern. She has turned on the gri
    10·1 answer
  • If you change the text to bold,you are changing the what?
    9·1 answer
  • Write two eaxmple of operating system​
    14·2 answers
  • Help<br> SOS<br> Quick <br><br><br><br><br> Hurry
    5·1 answer
  • Builder Software is used to create _____? answers: 3d digital art design for cameras audio special effects
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!