Functions in python

Hi there,
I know input(), int(), str(), list()… are called built-in functions
But when we import any module,
say tkinter 's grid(), frame(), label()…
or random 's random(), randint(), randrange()…
then will be called as functions too?

Consider a Module as a code library file containing a set of functions you want to include in your application.

Using your example, random, that function has a number of ‘methods’, such as .seed() .randint() .shuffle() and so on.

You’ll find that the Tkinter objects such as frame() and label() are called ‘Widgets’, while .grid() is a method that is used with said ‘widgets’

1 Like

So, won’t these be called as functions?
I’ve done a project report on python;
Please can you say if this is correct:

I’d argue that .grid() and .pack() are ‘methods’ (notice the dot prefix), but on the face of it, I see no other issues.

Also, try not to contradict whatever material you’re working from. e.g if your material has been supplied by some education establishment, then follow said material, rather than get into a debate about terminology.

1 Like

Thanks
And our school gave nothing, except acknowledgment pg and they just said topics to be in it like abstract, system config, Libraries and Functions used, source code, Output screenshots, Conclusion. I’m just doing it my way :slight_smile:

From a terminology standpoint, if you’re calling a name which is
directly defined in a module that’s a function. If you’re calling a
name which is attached to an object class then that’s a type of
function commonly referred to as a class method. That is to say,
methods are still functions, just with an implicit initial parameter
(“self”).

2 Likes

So I believe it will be ok if I’m using Functions and class methods from modules rather than functions from modules.
Am I right ?