160k views
2 votes
Write a function to accept a vector of masses (m) from the user and gives the corresponding energy to them. Energy vector is the output of the program. Constant c is the speed of light which is 2.9979 x 108 m/s inside the function.

User Tenatious
by
7.1k points

1 Answer

4 votes

Answer:

Written in Python

def energyvector(mass):

c = 2.9979 * 10**8

energy = mass * c ** 2

print(round(energy,2))

Step-by-step explanation:

This line defines the function

def energyvector(mass):

This line initializes the speed of light

c = 2.9979 * 10**8

This line calculates the corresponding energy

energy = mass * c ** 2

This line prints the calculated energy

print(round(energy,2))

User Edhgoose
by
6.3k points