0

I am trying to put up a function in python to make some calculations. I have some constants (energy-levels)

#theory in keV
e_zn = 9.6586
e_ge = 11.1031
e_br = 13.4737
...

Now I tried to define a function with two arguments: name or symbol of the element and a value from experiments (angle)..

def energy(name, angle):
    e = (sc.h * sc.c) / (2 * d * np.sin(np.deg2rad(angle)) * sc.e * 1e3)
    print(name)
    print(name, e, "keV")
    e_th = "e_"+name
    print("e_"+name)
    var = np.absolute((e - e_th) / e)
    print(var)

PROBLEM: How can I use my theory values in the function?

e_th = "e_"+name
print("e_"+name)

This just gives me text. I know why - because I defined the value new. But I dont know how to make the function use my constants (theory in keV)!

I want to use energy(zn, 13.0) and I want the function to use my 'e_zn' value.

I hope someone understood where my problem is.

Thanks.

Tony Babarino
  • 3,355
  • 4
  • 32
  • 44
lrsp
  • 1,213
  • 10
  • 18

0 Answers0