math sqrt python code example

Example 1: python sqrt import

import math

math.sqrt( x )

Example 2: sqrt python

#Run this code in the shell - do not run this as a .py file.
>>> import math
#On a different line type the following:
>>> math.sqrt(YourNumberHere)
#You may replace YourNumberHere with any number.

Example 3: python get square root

import math

toSquare = 300
squared = math.sqrt(toSquare)

Example 4: python square root

import math
a = input("what do you wnat to square root")
print(math.sqrt(a))

Example 5: pi python

# import built in math module
import math

# Showing usage of pi function
print(math.pi)

Example 6: python mathematics

// Python mathematical functions include but are not limited to:
print(10+10) // Returns 20 (Addition)
print(10*10) // Returns 100 (Multiplication)
print(10/10) // Returns 1 (Division)
print(10**10) // Returns 10000000000 (10 to the power of 10, 10^10)
print(10-10) // Returns 0 (Subtraction)
print(10>100) // Returns False (If A is greater than B)
print(10<100) // Returns True (If A is less than B)
print(10==10) // Returns True (If A is equal to B)

import math // Required for the function below
print(math.pi) // Returns the first 15 decimal places of Pi

Tags:

Css Example