Physics Class Assignment help

Why is there an error?

File “script.py”, line 32
return force = (get_force * distance)
^
SyntaxError: invalid syntax

There are a couple errors here, your first one is the syntax error on line 32.

The return function is not capable of assigning to a variable in this way. Take a look at an example:

def add(n1, n2):
  return number = n1 + n2
#           \
#           The reference to number is unnecessary as this value will be
#           assigned when the function is called, and it results in a
#           syntax error

Instead of assigning a value by reffering to it, return assigns a value when its function is called as the value of a variable:

def add(n1, n2):
  return n1 + n2

#    Here is were number is assigned
#   /
number = add(5, 5)

There is a second error in your code, but I won’t go into detail since you have not asked about it.
As a hint though, take a look at how you call your functions.

1 Like

Hi @cloud0101767980

error in line 32 is because of return force = (get_force * distance)
You should compare it with the return lines of the other functions.

In addition to what @8-bit-gaming has said, I think it would also be really helpful if you printed out each function to see what the results are.

For instance, with the first one, f_temp what happens when you call it and pass through an argument (the number 100 [that would be converted to celsius])?

The function takes one parameter. Think of the parameter as empty and you’re going to pass an argument (the temperature in Fahrenheit) thru there to get a result.

3 Likes

Ok, thanks. What’s the second error?

If one is simply given the answer, than it is much harder to learn. A large part of learning to program is to learn debugging. I can certainly help guide you in the right direction though.

After you have fixed your first error, what does your second error message say?

4 Likes