Created
March 23, 2021 21:14
-
-
Save AnisahTiaraPratiwi/eed3c325dd1046c7c823f2d9e37c9bf6 to your computer and use it in GitHub Desktop.
Let's use tuples to store information about a file: its name, its type and its size in bytes. Fill in the gaps in this code to return the size in kilobytes (a kilobyte is 1024 bytes) up to 2 decimal places.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def file_size(file_info): | |
name, type, size= file_info | |
return("{:.2f}".format(size / 1024)) | |
print(file_size(('Class Assignment', 'docx', 17875))) # Should print 17.46 | |
print(file_size(('Notes', 'txt', 496))) # Should print 0.48 | |
print(file_size(('Program', 'py', 1239))) # Should print 1.21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks it really helps.