Skip to content

Instantly share code, notes, and snippets.

@AnisahTiaraPratiwi
Created March 23, 2021 21:14
Show Gist options
  • Save AnisahTiaraPratiwi/eed3c325dd1046c7c823f2d9e37c9bf6 to your computer and use it in GitHub Desktop.
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.
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
@Mercy-12
Copy link

Mercy-12 commented Jul 7, 2022

Thanks it really helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment