About 157,000 results
Open links in new tab
  1. python - How do I define a function with optional arguments?

    A Python function can take in some arguments, take this for example, def add(x,y): return x+ y # calling this will require only x and y add(2,3) # 5 If we want to add as many arguments as we …

  2. How can I specify the function type in my type hints?

    Jun 15, 2016 · Another interesting point to note is that you can use the built in function type() to get the type of a built in function and use that. So you could have. def f(my_function: …

  3. Python define function inside if block or vice versa

    Jul 14, 2017 · The second one is best for if you just want one or the other. The first function will always give you the answer 15, because the mode changes while it is running. However, the …

  4. python - How can I use a global variable in a function? - Stack …

    Jul 11, 2016 · In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function’s body, it’s assumed to be a …

  5. mean in Python function definitions? - Stack Overflow

    Jan 17, 2013 · Simply -> is introduced to get developers to optionally specify the return type of the function. See Python Enhancement Proposal 3107. This is an indication of how things may …

  6. Python: How to create a function? e.g. f (x) = ax^2

    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 …

  7. 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 …

  8. Declaring a python function with an array parameters and passing …

    I'm more familiar with programming languages such as Fortran and C, in which you can define elemental functions which operate on each element inside an array. I finally tracked down the …

  9. python - How to define a mathematical function in SymPy

    May 8, 2016 · second, define a symbolic function; f = sympy.Function('f')(x) define a formula; f = x**x+1 if you have so many variable can use this function. def symbols_builder(arg): …

  10. python - How do I call a function from another .py file ... - Stack ...

    Define import statement in Example3.py - file for import all function. from com.my.func.DifferentFunction import * or define each function name which you want to …

Refresh