Python - Compute square roots

Introduction

There are three ways to compute square roots in Python:

  • using a module function,
  • an expression, or
  • a built-in function.

Demo

import math 
print( math.sqrt(144) )              # Module 
print( 144 ** .5 )                   # Expression 
print( pow(144, .5) )                # Built-in 
print( math.sqrt(1234567890) )       # Larger numbers 
print( 1234567890 ** .5 )
print( pow(1234567890, .5) )

Result

Related Topic