About 50 results
Open links in new tab
  1. Python: How to create a function? e.g. f(x) = ax^2 - Stack Overflow

    Python will allow doing that, but not using standard data types. You can define a class for a polynomial and then define any methods or functions to get the highest power or anything else.

  2. Basic explanation of python functions - Stack Overflow

    Sep 5, 2015 · The same is true of the arguments in the function you've provided. This means that the order of the arguments in a function call is important. The Python language, like many others, …

  3. python - How do I define a function with optional arguments? - Stack ...

    How do I define a function with optional arguments? Asked 13 years, 10 months ago Modified 1 year, 6 months ago Viewed 1.2m times

  4. Python: defining a function inside of a function - Stack Overflow

    new_function = function_writer() new_function() In this case there doesn't seem to be much point (just as there wouldn't normally be much point defining a function that always returns 0), but if …

  5. python - How do I forward-declare a function to avoid `NameError`s for ...

    In python the statement globals()[function_name]() is the same as foo() if function_name = 'foo' for the reasons discussed above, since python must lookup each function before calling it. If one were to …

  6. How do Python functions handle the types of parameters that you pass …

    Apr 7, 2017 · Python doesn't know that you are calling the function with the proper types, and expects the programmer to take care of that. If your function will be called with different types of parameters, …

  7. Declare function at end of file in Python - Stack Overflow

    Python is a dynamic programming language and the interpreter always takes the state of the variables (functions,...) as they are at the moment of calling them. You could even redefine the functions in …

  8. Define a method outside of class definition? - Stack Overflow

    May 26, 2018 · You can define a function outside of a class and then add it. However, there is a subtle difference in assigning the function to the class or to the instance object.

  9. python - How do I get ("return") a result (output) from a function? How ...

    The natural, simple, direct, explicit way to get information back from a function is to return it. Broadly speaking, the purpose of a function is to compute a value, and return signifies "this is the value we …

  10. Explicitly Define Datatype in Python Function - Stack Overflow

    Python is a strongly-typed dynamic language, which associates types with values, not names. If you want to force callers to provide data of specific types the only way you can do so is by adding explicit …