tatan tatan - 1 year ago 122
Python Question

How to do math functions in python?

I have latest python 3.5.1.

I have tried to do square root of numbers in python but I have not been able to. This is my code.

import math

enter image description here
When I press F5 to execute the code, I get a black screen with >>> symbol (shown on the picture). What should I do?

Answer Source

The code is not working because you are not assigning the value of math.sqrt(100) to a variable. To get a useable value, assign it to a variable like my_variable = math.sqrt(100). To print it, do print math.sqrt(100) or print my_variable.

The only thing that your code does is import the math module then run the sqrt() function. The reason there is nothing in IDLE is because your program is not written to have any output.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download