Check sibling questions
Computer Science - Class 12
Chapter 14 - Functions in python

A function checkMain() defined in module Allchecks.py is being used in two different programs In program 1 as

Allchecks.checkMain(3,’A’)

and in program 2 as

checkMain(4,’Z’).

Why are the functions call statements different in each program?

 

Answer:

In program 1, the complete module ie., Allchecks.py is imported as ‘import Allchecks’ and hence to use a specific function in the module , the  module name must be added before the function name. 

In program 2, only the required function is imported from the module as ‘ from Allchecks import checkMain( )’ and hence the function can be used independently without mentioning the module name.

Are ads bothering you?

CA Maninder Singh's photo - Expert in Practical Accounts, Taxation and Efiling

Made by

CA Maninder Singh

CA Maninder Singh is a Chartered Accountant for the past 12 years. He also provides Accounts Tax GST Training in Delhi, Kerala and online.