-3

For the pythons snippet below,

def line1(self, arr: List[int], a: int, b: int, c: int) -> int:

what does -> int mean? what is the purpose of b:int then? also what does self mean?

Sociopath
  • 13,068
  • 19
  • 47
  • 75
Power123
  • 23
  • 1
  • 5
  • 1
    Refer [Type Hinting](https://docs.python.org/3/library/typing.html) – Sociopath Aug 02 '20 at 17:26
  • 2
    Does this answer your question? [What does -> mean in Python function definitions?](https://stackoverflow.com/questions/14379753/what-does-mean-in-python-function-definitions) and [What is the purpose of the word 'self'?](https://stackoverflow.com/q/2709821/4518341) – wjandrea Aug 02 '20 at 17:26
  • Two of the things you ask are related to type hints, but if you're not familiar with self you should check out a structured tutorial https://sopython.com/wiki/What_tutorial_should_I_read%3F – jonrsharpe Aug 02 '20 at 17:27
  • for self see https://stackoverflow.com/q/7721920/217324 – Nathan Hughes Aug 02 '20 at 17:28

1 Answers1

0

Please at least try to use Google. Those are very simple questions.

But anyway:

self - means that a function belongs to a class and with self all the class attributes are passed to function so it could access them

-> - is a relatively new feature in python, it helps with a type annotation, it defines what function will return. In this case, the function is expected to return an integer value.

: - has the same purposes as the "arrow" from above it means that function expects to receive an integer value for a, b and c

You have got yourself some useful links in comments, please go over them.

sleepyhead
  • 419
  • 1
  • 5
  • 19