keyboard_arrow_left keyboard_arrow_right
Girish's Project

Units Converter

About Girish

My name is Girish Chinnaiya. I study in The Asian School which is in Bahrain. I really interested in programming with especially python, I also have other interests such as sports, reading books etc.

Girish's project details:

This project is a unit converter that will enable the user to convert units of length and weight such as kilometre to meter and grams to milligrams and many more. This program only deals with the metric system, for now.

print("**********Girish's Unit Converter!**********")
print("Greetings User! This program is made to facilitate you to convert a number from a unit to a another unit whether its length or weight!")
measure = input("Which measurement you would like to convert from and to (length or weight): ")
print(".......................................")
if measure == "length":
    num1 = int(input("Now. please enter the value from which you would like to convert. (eg. 100 m to km): "))
    unit1 = input("Pls enter the length unit from which you want to convert: ")
    if unit1 == "millimeter" or unit1 == "Millimeter" or unit1 == "mm" or unit1 == "MM":
        print("Valid unit!")
    elif unit1 == "centimeter" or unit1 == "Centimeter" or unit1 == "cm" or unit1 == "CM":
        print("Valid unit!")
    elif unit1 == "Metre" or unit1 == "Meter" or unit1 == "m" or unit1 == "M" or unit1 == "metre" or unit1 == "meter":
        print("Valid unit!")
    elif unit1 == "Kilometer" or unit1 == "kilometer" or unit1 == "km":
        print("Valid unit!")
    else:
        print("Please enter a valid unit!")
        exit(0)
    unit2 = input("Pls enter the another length unit to which you want to convert: ")
    if unit2 == "millimeter" or unit2 == "Millimeter" or unit2 == "mm" or unit2 == "MM":
        print("Valid unit!")
    elif unit2 == "centimeter" or unit2 == "Centimeter" or unit2 == "cm" or unit2 == "CM":
        print("Valid unit!")
    elif unit2 == "Metre" or unit2 == "Meter" or unit2 == "m" or unit2 == "M" or unit2 == "metre" or unit2 == "meter":
        print("Valid unit!")
    elif unit2 == "Kilometer" or unit2 == "kilometer" or unit2 == "km":
        print("Valid unit!")
    else:
        print("Please enter a valid unit!")
        exit(0)
    print(".....................................")
    if unit1 == "Kilometer" or unit1 == "kilometer" or unit1 == "km" and unit2 == "Metre" or unit2 == "Meter" or unit2 == "m" or unit2 == "M" or unit2 == "metre" or unit2 == "meter":
        result = num1*1000
        print(num1, 'km' + ' ' + '=', result, 'm')
    elif unit1 == "Metre" or unit1 == "Meter" or unit1 == "m" or unit1 == "M" or unit1 == "metre" or unit1 == "meter" and unit2 == "centimeter" or unit2 == "Centimeter" or unit2 == "cm" or unit2 == "CM":
        result1 = num1*100
        print(num1, 'm' + ' ' + '=', result1, 'cm')
    elif unit1 == "centimeter" or unit1 == "Centimeter" or unit1 == "cm" or unit1 == "CM" and unit2 == "millimeter" or unit2 == "Millimeter" or unit2 == "mm" or unit2 == "MM":
        result2 = num1*10
        print(num1, 'cm' + ' ' + '=', result2, 'mm')
    if unit1 == "millimeter" or unit1 == "Millimeter" or unit1 == "mm" or unit1 == "MM" and unit2 == "centimeter" or unit2 == "Centimeter" or unit2 == "cm" or unit2 == "CM":
        result3 = num1/10
        print(num1, 'mm' + ' ' + '=', result3, 'cm')
    elif unit1 == unit1 == "centimeter" or unit1 == "Centimeter" or unit1 == "cm" or unit1 == "CM" and unit2 == "Metre" or unit2 == "Meter" or unit2 == "m" or unit2 == "M" or unit2 == "metre" or unit2 == "meter":
        result4 = num1/100
        print(num1, 'cm' + ' ' + '=', result4, 'm')
    elif unit1 == "Metre" or unit1 == "Meter" or unit1 == "m" or unit1 == "M" or unit1 == "metre" or unit1 == "meter" and unit2 == "Kilometer" or unit2 == "kilometer" or unit2 == "km":
        result5 = num1/1000
        print(num1, 'm' + ' ' + '=', result5, 'km')
    else:
        print("The program isn't able to calculate your result")
elif measure == 'weight':
    num1 = int(input("Now. please enter the value from which you would like to convert. (eg. 1000 g to kg): "))
    unit1 = input("Pls enter the weight unit from which you want to convert: ")
    if unit1 == "milligram" or unit1 == "Milligram" or unit1 == "mg" or unit1 == "MG":
        print("Valid unit!")
    elif unit1 == "gram" or unit1 == "Gram" or unit1 == "g" or unit1 == "G":
        print("Valid unit!")
    elif unit1 == "kilogram" or unit1 == "Kilogram" or unit1 == "kg" or unit1 == "KG":
        print("Valid unit!")
    elif unit1 == "Ton" or unit1 == "Tonne" or unit1 == "t" or unit1 == 'T':
        print("Valid unit!")
    else:
        print("Please enter a valid unit!")
        exit(0)
    unit2 = input("Pls enter the weight unit to which you want to convert: ")
    if unit2 == "milligram" or unit2 == "Milligram" or unit2 == "mg" or unit2 == "MG":
        print("Valid unit!")
    elif unit2 == "gram" or unit2 == "Gram" or unit2 == "g" or unit2 == "G":
        print("Valid unit!")
    elif unit2 == "kilogram" or unit2 == "Kilogram" or unit2 == "kg" or  unit2 == "KG":
        print("Valid unit!")
    elif unit2 == "Ton" or unit2 == "Tonne" or unit2 == "t" or unit2 == 'T':
        print("Valid unit!")
    else:
        print("Please enter a valid unit!")
        exit(0)
    print(".....................................")
    if unit1 == "Ton" or unit1 == "Tonne" or unit1 == "t" or unit1 == 'T' and unit2 == "kilogram" or unit2 == "Kilogram" or unit2 == "kg" or unit2 == "KG":
        result = num1*1000
        print(num1, 't' + ' ' + '=', result, 'kg')
    elif unit1 == "kilogram" or unit1 == "Kilogram" or unit1 == "kg" or unit1 == "KG" and unit2 == "gram" or unit2 == "Gram" or unit2 == "g" or unit2 == "G":
        result1 = num1*1000
        print(num1, 'kg' + ' ' + '=', result1, 'g')
    elif unit1 == "gram" or unit1 == "Gram" or unit1 == "g" or unit1 == "G" and unit2 == "milligram" or unit2 == "Milligram" or unit2 == "mg" or unit2 == "MG":
        result2 = num1*1000
        print(num1, 'g' + ' ' + '=', result2, 'mg')
    if unit1 == "milligram" or unit1 == "Milligram" or unit1 == "mg" or unit1 == "MG" and unit2 == "gram" or unit2 == "Gram" or unit2 == "g" or unit2 == "G":
        result3 = num1/1000
        print(num1, 'mg' + ' ' + '=', result3, 'g')
    elif unit1 == "gram" or unit1 == "Gram" or unit1 == "g" or unit1 == "G" and unit2 == "kilogram" or unit2 == "Kilogram" or unit2 == "kg" or unit2 == "" or unit2 == "KG":
        result4 = num1/1000
        print(num1, 'g' + ' ' + '=', result4, 'kg')
    elif unit1 == "kilogram" or unit1 == "Kilogram" or unit1 == "kg" or unit1 == "KG" and unit2 == "Ton" or unit2 == "Tonne" or unit2 == "t" or unit2 == 'T':
        result5 = num1/1000
        print(num1, 'm' + ' ' + '=', result5, 'km')
    else:
        print("The program isn't able to calculate your result")
else:
    print("Pls enter a valid measurement")
                                         
Name: Girish Chinnaiya
Grade: 9
Be the Next Creator like :