-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path3.5. Mass and Weight .py
32 lines (30 loc) · 1.22 KB
/
3.5. Mass and Weight .py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
5. Mass and Weight
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 500 newtons display a message indicating that
it is too heavy.
If the object weighs less than 100 newtons display a message indicating that
it is too light.
Reference:
(1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3
(2) https://youtu.be/O6lqF8WxUwk
"""
# Get User Input(the object mass)
# Convert User input to float
mass = float(input("Please Enter an object mass : "))
# calculates its weight with the formula: weight = mass x 9.8
weight = mass * 9.8
# Display the Result
if weight > 500:
print("the object weighs : " + str(format(weight,",.2f")) + \
" newtons is too heavy ")
elif weight < 100:
print("the object weighs : " + str(format(weight,",.2f")) + \
" newtons is too light ")
else:
print("the object weighs : " + str(format(weight,",.2f")) + \
" newtons is neither heavy or light ")