I have created a class called: Sample, where I declared a static method named calculate() which takes a number and return it is square root. This program is saved in 'static_method_2.py'
import math
class Sample:
data = 10
@staticmethod
def calculate(x):
return(math.sqrt(x))
I want to access this calculate method in another python program.(both python program in same folder)
import static_method_2
num = int(input('Enter Number for square root \n'))
# print(method.data)
print("Square root of {} is {}".format(num, static_method_2.calculate(num)))
When I am running 2nd program, it's showing error:
AttributeError: module 'static_method_2' has no attribute 'calculate'
Can anyone please suggest how to get rid of this problem, or where I am doing mistake.