Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding Functions
#2
A function is a reusable routine that does the same thing for a set of variable inputs:
as an example, if you were building a simple calculator, you would need functions for add, subrtract ,
multiply and divide among others.
the add function might look like this:
>>> def add(a, b):
...     return a + b
...
>>> add(4, 5)
9
>>> add(2, 3)
5
>>> z = 2
>>> y = 9
>>> add(z, y)
11
>>>
hope this is helpful
Reply


Messages In This Thread
Understanding Functions - by Dez - Nov-03-2017, 12:26 AM
RE: Understanding Functions - by Larz60+ - Nov-03-2017, 12:43 AM
RE: Understanding Functions - by metulburr - Nov-03-2017, 12:48 AM
RE: Understanding Functions - by wavic - Nov-03-2017, 03:28 AM
RE: Understanding Functions - by Dez - Nov-04-2017, 12:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Improving my understanding of functions and methods menator01 2 2,183 Apr-24-2020, 06:26 AM
Last Post: menator01
  Need help understanding a couple of functions (encrypt,decrypt, int_to_bytes) xoani 0 2,019 Jun-09-2019, 03:25 PM
Last Post: xoani
  i have problems understanding 2 functions,look for help. Tony 2 2,662 Dec-05-2018, 12:35 PM
Last Post: Tony
  Help in understanding scope of dictionaries and lists passed to recursive functions barles 2 3,246 Aug-11-2018, 06:45 PM
Last Post: barles

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020