My Channel

How to make a Weight Calculator | Weight Converter | Simple and easy to make

 Weight Calculator - Simple & Easy to make



Hey Guys,

Welcome back and today i will show you how to make a Simple Weight calculator that works the same way as the Currency convertor.

So, as i said its easy to make and is almost same as the currency convertor.

So, here is the Code:

def convertor():
    print("Welcome to the Weight Convertor.")
    print("This can only convert between Kilograms (kg) and Pounds(lbs).")
    unit = input("Enter a Unit: ")
    weight = float(input("Enter a Value: "))
    if unit.upper() == "KG":
        print("The weight in Pounds is ,",weight*2.20462262,"pounds")
    elif unit.upper() == "LBS":
        print("The weight in Kilogram is,",weight*0.45359237,"kilograms")
    else:
        print("This cannot be converted. Do you want to convert?")
        convertor()
convertor()

Steps to explain with:

1.This also has the functions to make it repeat at point when we enter something else that required. 

2.It welcomes us.

3.Entering Units and value to convert. Note: This converts only between Kg and Pound. More Units will be coming and You can Copy this part of code:

if unit.upper() == "KG":
        print("The weight in Pounds is ,",weight*2.20462262,"pounds")
    elif unit.upper() == "LBS":
        print("The weight in Kilogram is,",weight*0.45359237,"kilograms")
    else:
        print("This cannot be converted. Do you want to convert?")
        convertor()

This can be used to edit and add more units as well.

4. I have called the function twice to make it run if the user enters something wrong and call the whole code.

So, this time around i have explained it in 4 simple steps and i hope you enjoyed it.

Meet you on the Next Post or Project, Until then Bye!

Be sure to Share this Blog with at least 15 members you know

By the Blog Author.


Post a Comment

2 Comments

  1. Replies
    1. vera level bro..
      check out my new blog!!
      https://raghavinspace.blogspot.com/

      Delete