Tring math module

I am new to the python program, i wrote code using math modules
Getting user input and perform below module

n= int(input ("Entet a number"))
n=  math.log2(2)
n =  cos(1)
n = float(math.e(0.5))

print(f"n is {n}")

while i am running this i get type error, float object not callable
I couldn’t understand.

math.log takes two arguments. The first argument is a value you want to create the log value for and the second argument represents the base to which the logarithm will be computed.

You have tried to call a function named math.log2 but that does not exist. Also, if you want to use the functions contained in the math module, you will need to import it first.

cos is part of the math module, so you will need to prefix it with math.

Lastly, the float function expects a string as its argument, and what you supplied is not a string. By the way, math.e is not a function. It is a constant, so you can not call it as a function with an argument.

1 Like

Thank you for your clear explanation.