03/15/2024
Python code to convert pounds (lb) to kilograms (kg):
def lb_to_kg(lb):
kg = lb * 0.453592
return kg
usage:
pounds = float(input("Enter weight in pounds: "))
kilograms = lb_to_kg(pounds)
print("Weight in kilograms:", kilograms)
This code defines a function lb_to_kg() that takes a weight in pounds as input and returns the equivalent weight in kilograms. Then, it prompts the user to input a weight in pounds, converts it to kilograms using the function, and prints the result.