write a program in python to input weight in gram and display it in KG and gram
Answers
Answered by
0
weight = int(Input("Enter weight in gram"))
print( "In gram = ", str(str(weight)+"g"))
print("In kilogram = ", str(str(weight/1000) + "kg"))
Answered by
4
The following codes will have to be typed in script mode, saved and then executed.
There are two possible codes for this.
One is to assign the formula into a variable, while the other is to directly type in the required logic in the print statement.
CODE 1:
x = float(input("Enter your weight [in grams]:"))
kg = x/1000
print("Your weight in Kilograms is", kg)
CODE 2:
x = float(input("Enter your weight [in grams]:"))
print("Your weight in Kilograms is", x/1000)
Both codes will produce the same output.
Similar questions