Function arguments (in Python for example)

前端 未结 8 2032
离开以前
离开以前 2020-12-03 16:47

What are [function] arguments? What are they used for?
I started learning Python very recently; I\'m new to programming and I apologize for this basic

8条回答
  •  抹茶落季
    2020-12-03 17:20

    In a few words, they're data that gets "passed into" the function to tell it what to do. Wikipedia has details.

    http://en.wikipedia.org/wiki/Function_argument

    For instance, your hi() function might need to know who to say hello to:

    def hi(person):
        print "Hi there " + person + ", how are you?"
    

    Or a mathematical function might need a value to operate on:

    def square(x):
         return x * x
    

提交回复
热议问题