I am trying to write an application to convert bytes to kb to mb to gb to tb. Here\'s what I have so far:
def size_format(b):
if b < 1000:
r
Here is to convert bytes to kilo, mega, tera.
#From bytes to kilo, mega, tera
def get_(size):
#2**10 = 1024
power = 2**10
n = 1
Dic_powerN = {1:'kilobytes', 2:'megabytes', 3:'gigabytes', 4:'Terabytes'}
if size <= power**2 :
size /= power
return size, Dic_powerN[n]
else:
while size > power :
n += 1
size /= power**n
return size, Dic_powerN[n]