Skip to main content
edited tags
Link
UpAndAdam
  • 1.7k
  • 1
  • 3
  • 20
Source Link

einstein.py check50 says I am returning '2'

Check50 says I am returning '2' but I do not think this is the case. I have also tried changing the order in which I print/return to see if it is expecting something different the error messages are all the same. Bellow is the code and the check50 output

C_LIGHT = 300000000

def main():
    ##prompt the user for input
    ##assuming the user inputs integer per instructions
    user_in = int(input("Input a mass in kg to Calculate E=Mc^2\n"))
    print(mass_to_energy(user_in))

def mass_to_energy(user_in):
    ##Calculating e=mc^2
    ## outputs the equivalent number of Joules as an integer
    ##print(user_in * (C_LIGHT ** 2))
    return (user_in * (C_LIGHT ** 2))

main()
Results for cs50/problems/2022/python/einstein generated by check50 v3.3.8
:) einstein.py exists
:( input of 1 yields output of 90000000000000000
    expected "90000000000000...", not "2"
    Seems like your output might not be the right number!
:( input of 14 yields output of 1260000000000000000
    expected "12600000000000...", not "2"
    Seems like your output might not be the right number!
:( input of 50 yields output of 4500000000000000000
    expected "45000000000000...", not "2"
    Seems like your output might not be the right number!