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
Which of the following was a major economic concern in the mid to late 1970
Charra [1.4K]
Without knowing any definite answer I would probably guess the military spending in Vietnam
7 0
3 years ago
Read 2 more answers
Jorge wanted to find out how many 9-volt batteries connected in a series are required to create a 120-volt circuit. So, he divid
natta225 [31]

Answer:

Jorge would need over 13\frac{1}{3} number of 9 volts battery to create 120 volts.

Explanation:

A series connecting is one in which two or more batteries are connected terminal-to-terminal, so that the same current flow through each battery. Each battery has an internal resistance, r, which is the opposition to the flow of current by the battery itself.

The total emf, E, of a given number of cells connected in series is given by;

E = E_{1} + E_{2} + E_{3} + E_{4} + .........

And each of the cell has an internal resistance, r. So that the total internal resistance of the cells in series is;

r = r_{1} + r_{2} + r_{3} + r_{4} + .......

Thus, Jorge's mistake was that 13\frac{1}{3} number of 9 volts batteries would not give 120 volts because each battery has its internal resistance. Therefore the appropriate answer is that he would need over 13\frac{1}{3} number of 9 volts battery to create 120 volts.

5 0
3 years ago
What are the steps for grouping worksheets in a workbook?
Hoochie [10]

Answer:

1, bottom    2,shift,        3,Ctrl

Explanation:

i got it right.

8 0
3 years ago
Read 2 more answers
Use BlueJ to write, test, and execute a program that reads a sequence of data for several employee objects from an input file. U
Serjik [45]
I don’t understand it
5 0
3 years ago
What are demographics<br><br>​
LUCKY_DIMON [66]

Answer:

What Is Demographics? Demographic analysis is the study of a population based on factors such as age, race, and sex. Demographic data refers to socio-economic information expressed statistically including employment, education, income, marriage rates, birth and death rates and more

Explanation:

Yea

8 0
3 years ago
Read 2 more answers
Other questions:
  • From the video "Your Password Sucks", using computer power to guess your password by trying multiple variations one after the ot
    15·2 answers
  • An independent computer program that copies itself from one computer to another over a network is called a ____:
    11·1 answer
  • How can a user begin working with a new, blank workbook in Excel?
    10·1 answer
  • Which command should you enter to configure a single port to discard inferior bpdus 200-125?
    5·1 answer
  • A _____ defines what must take place, not how it will be accomplished.​
    12·1 answer
  • Robert's employer has agreed to pay half the tuition for Robert to complete his college degree. This benefit is known as what?
    7·2 answers
  • 1. What are copyright laws?
    12·2 answers
  • Write an algorithm to find perimeter of circle<br>​
    12·1 answer
  • Which type of information could be displayed using this line graph?
    12·2 answers
  • What is keyboard? answer me <br>​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!