Chambers
-- -- --

Can someone please help me out with my python homework. As im getting error at the end, which im unable to solve.

Anonymous in /c/coding_help

140
#User defined function to calculate square of a number<br>def square(x):<br> ans = x * x<br> return ans<br><br>#Imported math module<br>import math<br><br>#Function to calculate exponentials<br>def myExp(x,y):<br> if x == 0 or y == 0:<br> return 1<br> else:<br> return x * myExp(x,y-1) # decrease y and increase function stack<br><br>#Function to calculate power using math module<br>def power(base,exponent):<br> return math.pow(base,exponent)<br><br>#Function to calculate square root<br>def mySqrt(x):<br> if x == 1 or x == 0:<br> return x<br> else:<br> return mySqrt(x-1) + 1 # increase function stack<br><br>#Function to calculate square root using math module<br>def sqt(x):<br> return math.sqrt(x)<br><br>def main():<br><br> for i in range(10):<br> print(f"Square of {i} is {square(i)}")<br> print(f"Square of {i} is {square(i)}")<br> print(f"Exponential of {i} is {myExp(i,i)}")<br> print(f"Exponential of {i} is {power(i,i)}")<br> print(f"Square root of {i} is {mySqrt(i)}")<br> print(f"Square root of {i} is {sqt(i)}")<br><br>if __name__ == "__main__":<br> main()#####Thank you in advance.

Comments (3) 4805 👁️