Python Program to Calculate Gravitational Force

This python program calculates Gravitational Force between two mass.

This program uses following formula for Gravitational Force:

Gravitational Force = ( G * m1 * m2 ) / r2

Where G is Gravitational Constant whose value is 6.674×10-11 m3.kg-1.s-1

m1 = mass of first body

m2 = mass of second body

r = distance

Python Source Code: Gravitational Force Calculator


# Python Program to Calculate Gravitational Force

# setting value of Gravitational Constant
G = 6.674e-11

# Reading weight and distance
m1 = float(input('Enter weight of first body (Kg): '))
m2 = float(input('Enter weight of second body (Kg): '))
r = float(input('Enter distance (m): '))

# Calculating Gravitational Force
F = G * m1 * m2 / r**2

# Displaying result
print('Gravitational Force = %f Newton' %(F))

Python Gravitational Force Program Output

Enter weight of first body (Kg): 50000
Enter weight of second body (Kg): 80000
Enter distance (m): 10
Gravitational Force = 0.002670 Newton