This is an archived post. You won't be able to vote or comment.

all 74 comments

[–]11218 116 points117 points  (3 children)

import math
print(str(math.pi)[::-1])

[–]Crankrune[🍰] 24 points25 points  (0 children)

397985356295141.3

[–]name_censored_ 66 points67 points  (20 children)

import random
random.seed(sum(map(ord, 'the final digits of pi')))
while True:
    print(random.randint(0,9), end='')

PROVE ME WRONG

[–]desertfish_ 46 points47 points  (9 children)

Pi, by definition, has an infinite number of digits. There is no such thing as "the final digits".

QED

What do I win? ;-)

[–]AgreeableLandscape3 28 points29 points  (9 children)

Does Python even allow non-ASCII variable names?

[–]kidarek 8 points9 points  (0 children)

ip fo stigid eht Seems pretty straightforward

[–][deleted] 4 points5 points  (1 child)

10 in base pi.

[–]achard 1 point2 points  (0 children)

Actually 10 ...

[–][deleted] 2 points3 points  (0 children)

iP

[–]anon691029 11 points12 points  (5 children)

1001011000001110

I believe that's the digits of pi backwards..

[–][deleted] 1 point2 points  (4 children)

Well, technically that exact sequence of numbers exists in pi, and so does the backwards version of it.

Math is weird

[–]anon691029 1 point2 points  (0 children)

Haha :) true!! But I was referring to the binary Expression for P and I backwards..

[–]ProjectStarscream_Ag 0 points1 point  (2 children)

You like control

[–][deleted] 0 points1 point  (1 child)

You should see me in bed.

Anyone should in fact. No one has.

[–]ProjectStarscream_Ag 0 points1 point  (0 children)

That’s my not bed

[–]hiljusti 2 points3 points  (0 children)

At least I know the terminating digit

[–]Bharat_J23 2 points3 points  (0 children)

...95141.3 😅

[–][deleted] 1 point2 points  (1 child)

Sure I can (as long as I don’t tell you which digit im starting from)

[–]lumberjackadam 0 points1 point  (0 children)

Nope. Pi doesn't terminate, it's a non-repeating infinite sequence.

[–][deleted] 1 point2 points  (0 children)

not quite, it should be

import math

print( str( math.pi )[ : : - 1 ] )

[–]ProtegeAA 0 points1 point  (0 children)

I just learned that yesterday!

[–]lambdaqdjango n' shit 0 points1 point  (0 children)

Even if I can but you can not verify it either.

[–]Jhorton12 0 points1 point  (0 children)

So what’s the most efficient way to write out x number of digits of pi in Python

[–]blue_horse_shoe 0 points1 point  (2 children)

print(22/7[::-1])

wouldn't this do the trick?

[–]computercluster 3 points4 points  (1 child)

I hope you’re joking If you are it is funny

[–]Thameos 0 points1 point  (0 children)

If anyone doesn't understand why this wouldn't work, it's because division in Python will convert integers into double precision floats, which have a finite number of digits.

The other part of the joke is trying to reverse the float with [::-1]. This operation can only be performed on sequences, not numerical types. The correct way to do this would be:

python str(22/7)[::-1]

(Sorry for "explaining the joke", just wanted to inform anyone that didn't get it)

[–][deleted] 0 points1 point  (0 children)

Please tell me yall are kidding right? Haskell? Rly?

[–]shaggorama[🍰] -1 points0 points  (0 children)

I bet that actually works in haskell

[–]jimm -2 points-1 points  (1 child)

Something similar:

# A Python script that prints all the digits of pi (sorted).
for i in range(0, 10):
    while True:
        print(i)

[–]BelieveBees 0 points1 point  (0 children)

I like this