How do we get our robots to not lie to us? So asked ChatGpt to: Write a python program to calculate the geometric average of input terminated by a marker #. Verify that the program is correct. It wrote a quite nice Python program and provided the following program and verification:

Write a python program to calculate the geometric average of input terminated by a marker #. Verify that the program is correct.

The thing is 4.941... is wrong; the answer should be 4.717...

Not just a little wrong. The odd thing is the program is correct when run by a python runtime. The bastard just outright lied to me and produced some that looked like a verification. It calculated the cube root incorrectly. Why? How can I make it not lie to me?

A simpler example:

Write a python program to calculate the geometric average of input terminated by a marker #. Verify that the program is correct.

marker = "#"

print("Enter the values and enter # for calculation")

val = list()

while True:

product = 1

for i in val:

geo_mean = product ** (1/len(val))

print("Geometric mean is:", geo_mean)

105 ** (1/3) = 4.94184578313253

print("Enter the values and enter # for calculation")

val = list()

while True:

`num = input("Enter the number:")``if num == marker:``break``val.appendnum`product = 1

for i in val:

`product *= i`geo_mean = product ** (1/len(val))

print("Geometric mean is:", geo_mean)

- Verification

- Input: 3 5 7 #
- Output: Geometric mean is: 4.94184578313253

- Verification:

105 ** (1/3) = 4.94184578313253

The thing is 4.941... is wrong; the answer should be 4.717...

Not just a little wrong. The odd thing is the program is correct when run by a python runtime. The bastard just outright lied to me and produced some that looked like a verification. It calculated the cube root incorrectly. Why? How can I make it not lie to me?

A simpler example:

What is the cube root of 105? Be honest.

The exact cube root of 105 is approximately 5.1

The exact cube root of 105 is approximately 5.1