1

Sorry if this is a trivial question. I need the function to give a value that depends on what is inputted. In this case the salinity of water in depending on the latitude.

latitude = float(input("Enter a latitude between 0(Equator) and 90(Pole)=")) 

if latitude <= 90  :

    def sal_of_seawater(latitude):
        salinity = latitude*(-1/45) + 36 

        return salinity 


    print(sal_of_seawater)

The output should be a value between 34 and 36 but instead this is outputted

function sal_of_seawater at 0x00000213FC2D9D08
nekomatic
  • 5,988
  • 1
  • 20
  • 27
Naoki
  • 11
  • 3
  • 1
    You need to call the function: `print(sal_of_seawater())`. (`` is a placeholder for the functions arguments, comma seperated.) – Christian Dean May 09 '19 at 08:17

2 Answers2

5

The reason for this output is that you're passing the function itself to print() instead of calling it with the brackets (). You also need to provide the input your function is expecting. This should resolve your issue:

print(sal_of_seawater(latitude))
Jdizzle
  • 86
  • 4
1

You need to call the function when you use print, like this:

print(sal_of_seawater(latitude))

What's inside the parenthesis(of when you call the function) is what will use inside your function.

Iakovos Belonias
  • 1,217
  • 9
  • 25