Power in Python Script

Hi all!

How to calculator power in python script.
I tested with Text Editor but result is different.

image
image

Thank Advance!!

2 Likes

@manhgt214 ,

i did here…

ahhh…

in IronPython it does not work!
grafik

i think you have to load a library…

KR

Andreas

1 Like

Have a look at the following as it may help you Built-in Functions — Python 3.11.0 documentation

1 Like

@Brendan_Cassidy ,

but it does not work with IronPython

import math
from math import *

a = 27
b=(1/3)
c=pow(a,b)

OUT = c

Thank you!
This work with me

from fractions import Fraction

a = 27.0**(Fraction('1/3'))
b = 9.0**(Fraction('1/2'))
c = (24/60.0)**(Fraction('1/3'))

OUT = a,b,c
2 Likes

This is due to a specificity of Python2 (integer division), if you want the exact result make sure the denominator is of type float (only for Python2)

4 Likes