Scientists measure an object’s mass in kilograms and its weight in newtons. If you know the amount of mass of an object in kilograms, you can calculate its weight in newtons with the following formula:
weight= mass x 9.8
Write a program that asks the user to enter an object’s mass, and then calculates its weight.If the object weighs more than 1,000 newtons, display a message indicating that it is too heavy. If the object weighs less than 10 newtons, display a message indicating that it is too light.
CODE:
Mass = float(input("Enter an object’s mass :")) #Asking user to enter an object's mass.
Weight = Mass * 9.8 # Converting mass in kilograms to weight in newtons.
Message = ""
if Weight > 1000: #Checking if weight is above 1000 or not.
Message = " The object is too heavy at " + format(Weight, ',.2f') +" newtons." # If it is true update the message.
elif Weight < 10: #Checking if weight is below 10 or not.
Message = "The object is too light at" + format(Weight, ',.2f') + " newtons." # if it is true update the message.
print(Message) # Display the result
OUTPUT:
Enter an object’s mass :1
The object is too light at9.80 newtons.
Enter an object’s mass :150
The object is too heavy at 1,470.00 newtons.