The work formula measures the multiplication of magnitude of displacement (d), the component of the
orce (F), and the angle (8) between d and F. It can be obtained from the following expression:
W = F x d x cos(0).
Write a program which prompts the user to enter d, F, and 0. Then, calculates W and displays
the computed value for W on the screen. (Notice: You should include all steps and respect the
Python syntax in order to obtain full mark).
• Which Python built-in functions did you use to write this program?
• Which modules in Python did you import? Which functions from the imported modules are
applied in your program?
import math
F = eval(input('Enter force here: '))
d = eval(input('Enter distance here: '))
theta = math.radians(eval(input('Enter angle here: ')))
print(F*d*math.cos(theta))
Enter force here: 76
Enter distance here: 5
Enter angle here: 60
190.00000000000003
Comments
Leave a comment