Computer Science, asked by kangym727, 7 months ago

how to transfer a function in python something like: def math(a, b)

Answers

Answered by Sanramkar
1

Explanation:

1) if u want to transfer the values to the definition you can write

math(1,2)

this will cause it to take a=1 and b=2

but I would recommend u to use any other name as there is a math module in python. so it may relate it with that and cause u an error to occur.

2)if u want to transfer the values from a definition you can say it to return the variable which contains the final value

for eg:

def math(a,b):

sum=a+b

return sum

this will return the sum

for eg:

if u write print(math(2,3)) it will print 5

3)if u want to import the definition from one python file to another then for eg

of the 1sr file is file1.py and the second file is file2.py

and if the first file contains the math definition then u can import it to the 2nd file like

import file1

import file1.math

this will import the 1st file into the 2nd one and then execute he 1st file in order to get all the values from it.

hope this helps u and please mark it as the brainliest

cheers :)

Similar questions