Python – KB to MB and MB to GB converter

A simple silly program that converts KBs to MBs and MBs to GBs.



def conv_KB_to_MB(input_kilobyte):
        megabyte = float(0.000976562)
        convert_mb = megabyte * input_kilobyte
        return convert_mb
def conv_MB_to_GB(input_megabyte):
        gigabyte = float(9.5367431640625E-7)
        convert_gb = gigabyte * input_megabyte
        return convert_gb
#Create the menu

print "Enter 1 to convert from KBs to MBs"
print "Enter 2 to convert from MBs to GBs"

        menu_choice = (raw_input("Enter a selection"))
except ValueError:
        print "This is not a number"
except NameError:
        print "Name Error"
except SystenError:
        print "Syntax Error"

if menu_choice == '1':
        kb_input = float(input("Enter KBs"))
        megabytes = conv_KB_to_MB(kb_input)
        print megabytes

elif menu_choice == '2':
        mb_input = float(input("Enter MBs"))
        gigabytes = conv_MB_to_GB(mb_input)
        print gigabytes
        print "exiting"
Share Button