Write a program in python to design a converter from Kilograms to grams and vice versa.
Answers
Answered by
0
Below are the program for the above question:
Explanation:
choice=int(input("press 1 for kilogram to gram convertor and any integer value for gram to kilogram calculator")) # It is used to take the choice.
Input=float(input("Enter the weight")) #it is used take the input for weight.
if(choice==1):
print(str(Input*1000)) #print the gram value
else:
print(str(Input/1000)) #print the kilogram value.
Output:
- If the user inputs as 1 and 4 then the output is 4000.
- If the user inputs is 2 and 4000 then the output is 4.
Code Explanation:
- The above code is in python language in which the if condition is used to change the kilogram to the gram and else statement is used to change the gram to the kilogram.
Learn More:
- Python : https://brainly.in/question/14689905
Similar questions