Question: Please only solve this in Python. A particular data compression algorithm can reduce a file's size to 80 peroent of its original size (so, for

Please only solve this in Python.  Please only solve this in Python. A particular data compression algorithm

A particular data compression algorithm can reduce a file's size to 80 peroent of its original size (so, for example, a 100-bybe file wil compress to 80 bytes). Before the compressed file can be stored on disk, it must be divided into blocks of 512 bytes each (so a 1000-byte compressed file will require two 512-byte blocks for storage) Write a program that does the following 1. Prompt for and read in the number of empty/available blocks on disk (an integer value) While the number of empty blocks is greater than 0 a. Print the number of free blocks available b. Prompt for and read in the size of an uncompressed file, in bytes (an integer value) c. Calculate the size in bydes of the file when it is compressed (to keep the compressed size an 2 integer, first muliply the original size by 8 and then divide the product by 10) d. Print out the size of the compressed tile, in bytes e. Calculate the number of blocks required to hold the compressed fie. Start by dividing the compressed size by 512 (using floor division); the quotient is the starting number of blocks. the remainder of the division is greater than 0, add 1 more block to the total required t. Print out the number of blocks required g the number of blocks needed is greater than the number of free blocks i. Print out a message reporting that not enough blocks are avaiable Set the total number ot free blocks to 0 (this will cause your loop to end) h. Otherwise Print a message ind cating that the file has been saved Subtract the number of blocks required from the number of free blocks i Add 1 to the count of files that were successfully "saved ii. L Update the total number of blocks used on disk 3. When your program ends, print out the number of files that were saved, and how many blocks were used in al to save those files. Stony Brook University CSE 101: Introduction to Computers (Section 01) Fall 2017 Sample Program Execution (program output is shown in italics, and user input is shown in boldface) Enter number of free blocks: 1000 Theve are 1000 blockfs) avalable Eter file size in bytes: 75000 Compressed size: 60000 byteys) 118 blocks of disk space wil be needed File has been saved There are 882 block(s) available Enter file size in bytes: 34000 Compressed size: 27200 byteys) 54 blocks of disk space wil be needed File has been saved There are 828 block(s) available

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!