Suppose a function called add() is defined in a module called adder.py. Which of the following code snippets correctly show how to import and use the add() function?
options are:
a) import adder result = adder.add(2,3)
b) from add import adder result = adder(2, 3)
c) from adder import add result = adder.add(2,3)
d) import add from adder result = add(2,3)
Answers
Answered by
14
Explanation:
a)import adder results=adder.add(2,3)
Answered by
0
import adder
result = adder. add(2,3)
Explanation:
There are 3 ways to import a module in python. Some of them are:-
(i) import module_name
(ii) import module_name. member_name
(iii) from module_name import *
When we have already imported the function from the module we need not use the module name again for accessing the function.
Similar questions
Science,
2 months ago
English,
2 months ago
Science,
2 months ago
Social Sciences,
5 months ago
Math,
11 months ago