Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
P2 -> P3 : Errors
#1
I have some code which I believe to be from Python 2 and need to move it to Python 3. I do not code in Python, or I stumble through very simple routines with some luck.

The code below gives me several errors in Python 3. Any suggestions or things I need to address? Any help would be greatly appreciated.


p, q = 1, 3
a, b, a1, b1 = 4, 1, 12, 4
for i in range(10000):
    p, q = p+q, q+2        # next convergent
    a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
    while 1:
        d = a//b
        r = a1 - d*b1      # break if a//b != a1//b1
        if r < 0 or r >= b1: break
        print d,           # common digits
        a, a1 = 10*(a-d*b), 10*r
Reply


Messages In This Thread
P2 -> P3 : Errors - by wsHVM - Dec-13-2021, 01:50 AM
RE: P2 -> P3 : Errors - by bowlofred - Dec-13-2021, 03:54 AM

Forum Jump:

User Panel Messages

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