import math as m
def f1():
a = 10
b = 20
c = a+b
print(c)
print(m.sqrt(4))
def num(a,b):
d = a*b
return d
How to call to num
function in another pycharm module ?
import math as m
def f1():
a = 10
b = 20
c = a+b
print(c)
print(m.sqrt(4))
def num(a,b):
d = a*b
return d
How to call to num
function in another pycharm module ?
You can't, the function num(a,b)
is essentially a local variable inside f1(); it only exists when f1()
is ran.
Just write num(a,b)
not as a nested function and you can call it elsewhere (if you import it properly) and f1()
still has access to it:
import math as m
def num(a,b):
d = a*b
return d
def f1():
a = 10
b = 20
c = a+b
d = num(a,b)