Computer Science, asked by galaxy15, 6 months ago

Program 18:- Write a program to read the weight of an object in gram and display its weight in kilograms and grams, respectively.
*Example*
*Input:-* Enter the weight of the object in grams: 2,500
*Output:-* Weight of the object (kilograms and grams): 2 kg and 500 g
*● Note:-* 1 kilogram = 1,000 grams

Answers

Answered by 0RPS0
4

W1 = eval (input('Enter the Weight of Objects in grams:'))

print(' Weight of Object = ',W1,' grams')

W2 = W1 // 1000

W3 = W1 % 1000

print(' Weight of Objects = ',W2,' kg and ',W3 'g')

*Output*

Enter the Weight of Object in g : 1250

Weight of Object = 1250 g

Weight of Object = 1 kg and 250 g

Similar questions