[Tutor] ASSIST A BEGINNER PLEASSE

Alan Gauld alan.gauld at yahoo.co.uk
Wed Nov 11 19:11:55 EST 2020


On 11/11/2020 22:46, Leonard Ujomu via Tutor wrote:
def calculate_storage(filesize):    block_size = 4096    # Use floor division to calculate how many blocks are fully occupied    full_blocks = 8192    # Use the modulo operator to check whether there's any remainder    partial_block_remainder = 4097 % 2    # Depending on whether there's a remainder or not, return    # the total number of bytes required to allocate enough blocks    # to store your data.    if partial_block_remainder > 0:        return block_size    return full_blocks
> print(calculate_storage(1))    # Should be 4096print(calculate_storage(4096)) # Should be 4096print(calculate_storage(4097)) # Should be 8192print(calculate_storage(6000)) # Should be 8192

You need to post in plain text otherwise the mail system messes up the
indentation, as you can see...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list