All problems
Measured Compression Ratio
Problem
Given the original size and the compressed size in bytes, return the compression ratio compressed / original. This equals the ratio of the bit counts, since both sizes scale by the same factor of eight. Return 0.0 when the original size is zero.
Hint
A ratio below 1 means the compressed file is smaller than the original.
Test cases
case 1
in: [1000,400]
expected: 0.4
case 2
in: [100,100]
expected: 1
case 3
in: [100,150]
expected: 1.5
case 4
in: [0,0]
expected: 0
Starter codePython
def measured_compression_ratio(original_bytes, compressed_bytes):
# Your code here
pass4 test cases · run your code against them in the editor