102k views
4 votes
The function sum (n1, n2) resides in a file named myFuncs.py and it returns the sum of n1 + n2. Using the import statement, write one line of code to call the function sum from file

User Masroor
by
7.8k points

1 Answer

4 votes

Final answer:

To call the function sum from the file myFuncs.py, use the import statement and specify the module and the function name.

Step-by-step explanation:

To call the function sum from the file myFuncs.py using the import statement, you need to follow these steps:

  1. First, import the module by using the import keyword followed by the name of the file without the file extension. For example, import myFuncs.
  2. Next, to access the function sum within the module, use myFuncs.sum(). You would use this syntax to call the function and pass the necessary arguments. For example, result = myFuncs.sum(3, 5).

User Gautam Shrivastav
by
8.5k points