Python Forum
I found a problem with Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I found a problem with Python
#11
(Jul-20-2023, 05:47 AM)Pedroski55 Wrote: Ah, pick another letter, not e for Euler's number!

Is this what you expect?

mylist = [27, 84, 110, 133]
e = 0
for num in mylist:
    e = e + num**5
    print('e is', e)
    print('e**0.2 is', e**0.2)
    Z = e**0.2
    print('Z is', Z)
    if Z == e**0.2:
        print('e**0.2 and Z are the same!')
Output:
e is 14348907 e**0.2 is 27.000000000000004 Z is 27.000000000000004 e**0.2 and Z are the same! e is 4196468331 e**0.2 is 84.05756207758672 Z is 84.05756207758672 e**0.2 and Z are the same! e is 20301568331 e**0.2 is 115.2141759184629 Z is 115.2141759184629 e**0.2 and Z are the same! e is 61917364224 e**0.2 is 144.00000000000003 Z is 144.00000000000003 e**0.2 and Z are the same!

It would appear you are correct, it seems to be a problem with the table syntax? maybe tables work better than just A + B + C + D?
-- "Incrementum Vitae Ex Animo" - Lucifer Daddy
Reply
#12
The difference is Pedroski55 is not calling int() after using the addition or exponentiation operators. int(float) throws away the fractional part of the float and returns the remaining value as an int object. int(1.2) == 1. int(-1.2) == -1.

Using a list only changed the structure of the code, not the results.
Reply
#13
Not long ago, I had to make a ppt on "The History of Euler's Number" Now, any time I see e, I immediately think of Euler's, admittedly cool, e!

I didn't stop to think you were just using e as a variable name!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I found how many numbers are there in a Collatz Sequence that I found? cananb 2 2,557 Nov-23-2020, 05:15 PM
Last Post: cananb
  Js2Py module not found problem Charliedactyl1 5 7,946 Jun-14-2020, 07:39 PM
Last Post: buran
  Package installed through Anaconda "not found" by Python zonova 0 2,314 May-08-2020, 11:50 PM
Last Post: zonova
  Python 36-32 problem encoding module not found mkgrtn 0 2,447 Apr-14-2020, 09:57 PM
Last Post: mkgrtn
  uising python zero with IDLE I get an error of 'module not found' Brian123 1 3,921 Apr-24-2019, 09:21 PM
Last Post: Yoriz
  How to fix error code 2 in python, “directory not found”? dav3javu 1 7,048 Apr-03-2019, 04:55 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020