10+ Python Cube Root Finder Program Examples

This post contains a total of 10+ Hand-Picked Python Cube Root Finder Program Examples with Source Code. All these Cube root programs are made using Python Programming Language.

You can use the source code of these examples with credits to the original owner.

Related Posts

Python Cube Root Finder Programs

1. By David Akhihiero

Made by David Akhihiero. Simple program to find the cube root of a number. Source

1.4142156862745097
2.1544177077840487
2.1544177077840487
precision = 0.0001

def ab(x):
    if x < 0:
        return -x
    else:
        return x
        
def sqrt(x, y = 1):
    if ab(x / y - y) <= precision:
        return y
    else:
        return sqrt(x, (x / y + y)/2)

print(sqrt(2))

def cbrt(x, y = 1):
    if x < 0:
        return -1 * cbrt(ab(x))
    if ab((x / (y * y)) - y) <= precision:
        return y
    else:
        return cbrt(x, (y + sqrt(x / y)) / 2)

print(cbrt(10))
print(cbrt(10))

2. By Sweet Devil

Made by Sweet Devil. Python program to find the cube root of a number N to a precision of 0.0001, with library functions. Source

5
Cube root from 5 is equal to 1.7100
n = int(input())
x,e = 1,(1-n)/3
while e>1e-5 or e<-1e-5: x,e = x-e,((x-e)*(x-e)*(x-e)-n)/(3*(x-e)*(x-e))
print("Cube root from {} is equal to {:.4f}".format(n,x))

3. By David Ashton

Made by David Ashton. A single line python program to find cube root. Source

2.1544
print(round(int(input())**(1/3), 4))

4. By Divyanshu Singh

Made by Divyanshu Singh. Source

Enter Number: 10.0

🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺
The Cube root of 10.0 is 2.1544
🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺🌺
import sys, codecs
sys.stdout = codecs.getwriter('utf_16')(sys.stdout.buffer, 'strict')


def Cube(a):
   b = round((a)**(1/3), 4)
   return b
   
a = float(input("Enter Number: "))
print(a)
print()


print('🌺'*14)
print("The Cube root of", a, "is", Cube(a))
print('🌺'*14)

5. By Victor Maltsev

Made by Victor Maltsev. Python Cube root calculator using Newton method. Source

Enter a number for calculating the cube root: 12
x(1)=4.666666666666667
x(2)=3.2947845804988667
x(3)=2.564996283933497
x(4)=2.3179736277253107
x(5)=2.2897785669119224
x(6)=2.28942853862757
The cube root of 12.0 is 2.289428485106665
e = 0.0001
try :
    y = float(input('Enter a number for calculating the cube root: '))
except :
    print('You entered not number!')
else :
    i = 0
    x = 1
    while(True) :
        xx = (2*x+y/x/x)/3
        d = xx - x
        if (abs(d)<e) :
            d = y - xx * xx * xx
            if (abs(d)<e) :
                break
        x = xx
        i += 1
        print('x({0})={1}'.format(i,xx))
    print('The cube root of {0} is {1}'.format(y,xx))

6. By Anjul Upadhyay

Made by Anjul Upadhyay. Source

Enter the value : 10
2.154434690031884
x=int(input("Enter the value : "))

print(x)

while x>0:
    x=x**(1/3)
    print(x)
    break
    

7. By Shobhit

Made by Shobhit. Source

Enter the cube:6.0
The cube root is:1.8171205928321397
n=float(input("Enter the cube:"))
print(n)
x=0.5-(0.5**3-n)/(n*(0.5**2))
for i in range(60000):
    x=(lambda x,n:x-(x**3-n)/(n*(x**2)))(x,n)
print(f"The cube root is:{x}")

8. By Davy hermans

Made by Davy hermans. Source

7
The cube root of 7.0 is 1.9129
number = float(input())
order = len(str(int(number)))
#print(number)
#print(order)
result = 10**(order/3)
if number < 10:
    result = 1
#print(result)
#print(result**3)
def getcloser(r,n):
    if abs(r**3 - n) > 0.0001:
        if n < 10:
            r+= (n-r**3)/10
#            print(r)
            getcloser(r,n)
        else:
            r+= (n-r**3)/n
#            print(r)
            getcloser(r,n)
    else:
        r = round(r,4)
        print("The cube root of {0} is {1}".format(n,r))

getcloser(result,number)  
    

9. By Rik Wittkopp

Made by Rik Wittkopp. Source

input is: 9

Cube root is: 2.0797

Test function against input:
8.995018801572998
# Rik Wittkopp

x = int(input())
print('input is:',x)
print()

# Function - find cube root
def root_3():
    y = 0
    res = y
    while res < x:
        y += 0.0001
        res = round(y**3,2)
        if res >= x:
           return round(y,4)

   
print('Cube root is:',root_3())      
print()       

print('Test function against input:')
print(root_3()**3)

10. By Alan Progg

Made by Alan Progg. Very basic python cube root finder program. Source

216

your answer is:
216
because
6
x
6
x
6
equals to:
216
num = int(input())
answer = num*num*num
print(answer)
print("")
print("your answer is:")
print(answer)
print("because")
print(num)
print("x")
print(num)
print("x")
print(num)
print("equals to:")
print(answer)
print("")
print("Thanks For Trying")

11. By Max

Made by Max. Source

Number 7
1.9129311827723892
#e is the precision
e=0.0000001
y=float(input("Number\n"))
x=y/2.0
t=x
x=x-(x*x*x*-y)/(3.0*x*x)
#since we do not want our stopping condition to depent on the size of the input we stop if the method stops changing the output greatly
while abs(x-t)>e:
	t=x
	x=x-(x*x*x-y)/(3.0*x*x)
print(x)