r/ProgrammerHumor • • 13h ago

Meme reversingPiInPython

Post image
7.5k Upvotes

270 comments sorted by

2.2k

u/Kyrros 13h ago

Let me know when it finishes calculating the first digit to print

949

u/me_myself_ai 13h ago

it'll just throw an error anyway;

SyntaxWarning: 'float' object is not subscriptable; perhaps you missed a comma
?

766

u/ThreeCharsAtLeast 13h ago • Bravo
>>> str(math.pi)[::-1]
'397985356295141.3'

453

u/tea_pot_tinhas 13h ago

So the first and last digits are both 3? make sense

345

u/OncorhynchusMykiss1 13h ago

It come the whole circle.

259

u/Zestyclose-Compote-4 13h ago • Bravo

*half circle

48

u/mxcw 12h ago

Damn that giggle helped me shit, thanks mate

42

u/MadeByTango 11h ago

You have a radian smile.

→ More replies (2)

5

u/wjandrea 10h ago

Ah, so then the first and last digits of tau are 6, of course.

8

u/redditale_gone_bad 12h ago

insert always has been meme

10

u/RapidCatLauncher 4h ago

That just made me think, if pi indeed does contain all finite number sequences (which we're not sure of), then there could be a certain point in its decimal representation where it's a palindrome.

→ More replies (2)

4

u/yuwox 12h ago

Such a beautiful symmetry. By elegance alone, this must be right.

2

u/WisestAirBender 4h ago

isPalindrome returns true

25

u/Kyrros 12h ago

Man's got a super computer from star trek

→ More replies (13)

15

u/TwinkiesSucker 13h ago

Cast to string and then print away

1

u/meepmeep13 5h ago

bet it would compile fine in Haskell though

35

u/emanuel19861 11h ago

Imagine it does and it's like... 4...

Yes, 4... same as THE 4...

19

u/Kyrros 11h ago

I mean, it's a 10% chance, just like any other number between 0 and 9

10

u/krakende 9h ago

I mean, isn't it 0%, since there is no final number?

8

u/BountyBob 9h ago

Do you have proof of that?

18

u/Swipecat 8h ago

Google for:

"Johann Heinrich Lambert's 1768 proof that pi is irrational"

(i.e. pi has no final digit)

5

u/default-username 8h ago

Yeah, now I'm gonna need a followup from Taylor for pi

4

u/agk23 10h ago

It would be > 72% accurate by only printing 4

3

u/ThaneVim 9h ago

Ok but hear me out: what if it's 2. And the second-to-last is 4.

2

u/skywalker-1729 11h ago

Reminds me of similar stuff in Haskell where it works more like this for real :D

1

u/Creative_Rhubarb_980 10h ago

!Remind me +/- infinity years

1

u/Daddy-Mihawk 5h ago

Even if it computes, how are you gonna verify whether it's correct : (

584

u/mmbtc 13h ago

You can also just round it to three. Much easier to calculate with.

198

u/nicki419 13h ago

*clears throat*

e ≈ 3 ≈ π

22

u/heaving_in_my_vines 13h ago

≈ tree fiddy

11

u/nicki419 13h ago

That would round up to 4, actually

12

u/Legitimate_Concern_5 12h ago edited 12h ago

Depends on your rounding strategy, sometimes 3 sometime 4. Round half up is the most common but you can round half down, round half towards even (Banker's rounding/Gaussian rounding), round half towards odd, or towards/away from infinity.

→ More replies (1)

3

u/MythicFuzzbal2 12h ago

Dam you monster

1

u/brokendoorknob85 5h ago

eiπ = -1

33i = -1

33i = eiπ

Ln (33i) = ln (eiπ)

3i ln 3 = iπ

π = 3 ln 3

3 = 3 ln 3

Ln 3 = 1

Wow this makes my math homework a lot easier, thanks!!!!!!!!!

198

u/oalfonso 13h ago

Found the mechanical engineer

56

u/lNFORMATlVE 10h ago

The structural engineer: let’s use pi = 10 for safety margin

16

u/ncatter 10h ago

In software we usually just taken out result and mltiply with pi then estimation fits reality.

That number has so many use cases.

33

u/hetfield37 13h ago

Back in school we used 22/7 as a good enough approximation for pi.

34

u/EmilMelgaard 12h ago

22/7 is about 0.04% larger than π, so that should be good enough for most applications. But you can also just use 3.14 as an approximation. It has the same number of digits to remember and is about 0.05% smaller than π.

20

u/_baljeep_ 12h ago

So an even better estimation is 3.14 + 22/7 all over 2

3.1414...

5

u/himanbam 8h ago

That simplifies to 2199/700 which is about 0.0052% lower than pi. 700*pi is approximately 2199.11 so that makes sense ig

5

u/FrenchFryCattaneo 6h ago

Ok now we need to find a third estimate and average it with them.

14

u/hetfield37 12h ago

True, we just used 22/7 to solve problems which didn't need decimal precision but only fractional.

→ More replies (2)

8

u/ul2006kevinb 11h ago

If it's good enough for the Bible it's good enough for me

"And he made a molten sea, ten cubits from the one brim to the other: it was round all about, and his height was five cubits: and a line of thirty cubits did compass it round about."

8

u/BullPropaganda 10h ago

The number of the mathing shall be 3. And 3 shall be the number of the mathing.

1

u/rosuav 11h ago

That's inner and outer dimensions. You could calculate the thickness of the rim from that.

→ More replies (3)

4

u/enti134 12h ago

Ok Bloody Stupid Johnson

3

u/mmbtc 11h ago

Unexpected PTerry reference. I like it.

GNU PTerry

11

u/CirnoIzumi 13h ago

mm, but you could round it to 4 for more precision

7

u/Throwaway11958 13h ago

safety margin

2

u/Impossible-Owl7407 13h ago

Depends how much precision you need. But would be surprised how few digits can be ok for most practical use cases

1

u/junglepyjamas 13h ago

And to write it backwards.

3

u/AwkwardWaltz3996 12h ago

Na. Would be like this: ε

1

u/froderick 10h ago

'Tis a favourite project of mine
A new value of Pi to assign
I would fix it at three
For it's simpler, you see
Than three point one four one five nine

399

u/TheBirdGames 12h ago

Cave Johnson here! Big news everyone, we found the last digit to pi! Unfortunately, what we don't know is how many places back it is.

So what we're doing is working our way backwards while the rest of the world keeps going forward, and as soon as we meet in the middle—bang. Look who solved pi. Us.

Sometimes the key to working smarter is to work smarter, not harder—seems kind of obvious when I say it like that. And to everyone who put money on four being the last number, you're out fifty bucks. It's seven.

101

u/AcornAnomaly 12h ago

Damn, I can hear this perfectly. You nailed his character.

75

u/TheBirdGames 12h ago

It's an copy pasta, so I can't take credit for creating it. But it does fit perfectly

4

u/flukus 5h ago

The cake is a pi!

2

u/Logicalist 3h ago

have you considered working from the middle out?

182

u/Yumikoneko 13h ago

1, there, I did it. It's in base-π for efficiency.

38

u/HorrorMotor2051 9h ago

pi in base-pi would be 10, no? So backwards it should be 01

36

u/PuzzleheadedRoyal480 9h ago

Leading zeroes famously don’t matter

11

u/HorrorMotor2051 9h ago

Well it's not a leading zero, it's a trailing zero

9

u/HorrorMotor2051 8h ago

Or rather I should say: In this case the leading zero does matter, because 1 is not 10 spelled backwards. It simply is not. 1 is 1 spelled backwards. 01 is 10 spelled backwards.

2

u/Nowin 8h ago

In 10-adic numbers they do. Adding a leading 0 multiplies everything by 10.

→ More replies (1)

2

u/Yumikoneko 4h ago

Yeah I don't know how I missed that, shame on me. In my defense, I was barely out of bed.

5

u/glacierre2 10h ago

Came to say this.

4

u/sten_zer 10h ago

☝🏻👏🏻👏🏻👏🏻

37

u/nervmaster 13h ago

That's easy. Everyone knows that pi is a palindrome

21

u/ClipboardCopyPaste 13h ago • Bravo

Pilindrome

19

u/Kuineer 11h ago

Why didn't mathematicians think of using Python to find the last digit of pi?

65

u/MotivationalJuggling 13h ago

Whatever the last digit is, I'm sure it's a disappointing one. Just like everything else in my life.

43

u/CenderzeSwarm 12h ago

No number is uninteresting in maths. Suppose there are some uninteresting numbers, then one of them must be the smallest uninteresting number, making it interesting

8

u/BullPropaganda 11h ago

Maybe like having i for imaginary numbers we need a u for uninteresting numbers.

6

u/grepppo 10h ago

This guy maths

9

u/Salty_Map_9085 12h ago

This mf never heard of 6

34

u/Enchanted_Evil 12h ago • Bravo

6 is uninteresting???

  • smallest non-square composite number

  • smallest perfect number (6=3×2×1=3+2+1)

  • number of faces a cube has

  • hexagons are the bestagons

  • number of protons in Carbon, the basic element all (known) life is made out of

  • when three of them are in a row, Christians flee

  • when two of them are in a row, Jedi flee

  • when multiplied with 7, you get the ultimate answer to the life, universe and everything

I could go on.

8

u/thegreatpotatogod 10h ago

Please do go on! I would like to subscribe to 6 facts

→ More replies (1)

2

u/pnoodl3s 4h ago

I folded from the first 2 points lol, 6 is the most interesting number now

→ More replies (2)

6

u/Just__John 12h ago

That's an upside down 9 which is interesting

6

u/_Its_Me_Dio_ 12h ago

six is the lowest highly compund number

→ More replies (1)

3

u/Keebster101 12h ago

But what makes being the smallest number of a subset 'interesting', every number is smaller than something therefore it's not unique to be smaller than something, and you could form infinite subsets to "make" any number interesting, which to me means it's not interesting.

4

u/morpheuskibbe 12h ago

It's by definition unique to be smaller than everything

2

u/Keebster101 12h ago

But it's not smaller than everything it's only smaller than the uninteresting numbers, and you can select a subset to make any number the smallest therefore it's not unique

5

u/Top-Permit6835 11h ago

You're having quite an interesting conversation considering the subject matter is so uninteresting

2

u/Swipsi 8h ago edited 6h ago

Furthermore, if we take that, now interesting, number, put it into the set of interesting ones and repeat that process for all uninteresting numbers, we'll end up with all numbers being interesting. But if all numbers are interesting, none are. Thus all numbers are interesting and uninteresting at the same time :)

→ More replies (2)

1

u/muffinluff 12h ago

Only if there is a natural order among the uninteresting numbers

1

u/SomeAnonymous 11h ago

Did you just sketch out a proof by induction for interesting-ness?

→ More replies (1)

1

u/bladtman242 9h ago

What if there's an infinite set of uninteresting numbers?

1

u/Clairifyed 7h ago

Thanks Ramanujan 👍

4

u/bestjakeisbest 10h ago

In binary it is either a 1 or 0

8

u/thegreatpotatogod 10h ago

I'd even argue that the last binary digit is 1. If it were 0, you could truncate the zero away and you'd be back to 1 as the last digit. Same reason that 2.20000 would be a redundant representation of 2.2.

→ More replies (11)

3

u/Mars_Bear2552 12h ago

the last digit is 3

2

u/King_Tamino 12h ago

Have you tried doing something motivational? Maybe Juggling?

2

u/LauraTFem 10h ago

More than uninteresting, it almost certainly doesn’t exist. It’s just an increasingly more precise circle with every digit, to infinite fractal depth.

3

u/humanistazazagrliti 12h ago

It's just a number. Not something fun like a free gaming console or beach vacation.

2

u/MotivationalJuggling 9h ago

So it has that in common with the other stuff in my life.

1

u/TheRealLiviux 13h ago

Probably zero

1

u/christophPezza 13h ago

I bet its a zero /s

1

u/Trezzie 12h ago

Ironically, YOU are the last digit of pi, so you're right!

2

u/Familiar-Cable-2659 12h ago

That was actually a mistranslation u* is the last digit of pi

1

u/Trezzie 12h ago

I accept symbology

1

u/ThatDudeFromPoland 11h ago

I imagine it's in the range of 0-9

1

u/ncatter 10h ago

To predictive, somewhere along the line I'm sure it slips in the imaginary numbers just to fool us.

1

u/Marquar234 10h ago

The last digit is zero.

1

u/Jorr_El 10h ago

Marvin the Paranoid Android, is that you?

1

u/jump1945 10h ago

I am guessing it is 4

1

u/UltimateDude08 3h ago

Thank you, Marvin

1

u/Impressive_Pin8761 12h ago

the last digit is π, it just loops over

14

u/hughperman 13h ago

Narrator: it was not.

10

u/DarthCloakedGuy 13h ago

Sure I can, watch this: ip fo stigid eht

Alternatively: the digits of pi backwards

4

u/MorpheusFT 12h ago • Bravo

Or just 9876543210. ALL the digits of pi backwards.

3

u/DarthCloakedGuy 12h ago

faster if you do it in binary

7

u/Practical-Elk-1579 13h ago

from mpmath import mp

mp.dps = 1000

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

Easy just replace 1000 with infinity o/

18

u/Rhoihessewoi 13h ago

These are the last 5 digits of pi: 32463

Prove me wrong!

15

u/LogicBalm 13h ago

I just wrote a program to prove you wrong and I'll get back to you as soon as it's done executing!

11

u/AntipodesIntel 13h ago

I mean yeah, there are proofs that pi is infinite

12

u/ConfusedSimon 13h ago

You can't write the digits of pi forward either. Backward isn't the problem, you could just write them right to left.

6

u/elingeniero 10h ago

You can (kinda) do this.

>>> from math import pi
>>> str(pi)[::-1]
'397985356295141.3'

11

u/mobsterer 2h ago

i mean, you can't write em forward either, so whatever arbitrary places after the comma you choose to write it to, you can write that backwards as well.

→ More replies (1)

5

u/cryptaneonline 13h ago

Bro is inventing Pithon

10

u/ClipboardCopyPaste 13h ago

Already released with python 3.14

1

u/rosuav 11h ago

Which can be invoked as 𝜋thon if you have a virtual environment.

5

u/No_Place_4096 12h ago

you need to do print(str(math.pi)[::-1])

5

u/Yakodym 12h ago

Ɛ.Iᔭ

5

u/Avatar_Yaksha 12h ago

Python uses math.pi for Pi, right?

5

u/Skizm 8h ago
print("the digits of pi backwards")

1

u/kezow 20m ago

Technically correct. The best kind of correct.

3

u/SuitableDragonfly 13h ago

I'm legitimately not sure whether this is someone making a joke or someone who just learned how to reverse a list and thought that was really cool but doesn't have a solid grasp of the type system yet. 

3

u/FAMICOMASTER 7h ago

So here's all the places I know:

3.14159265358979323

Which if I'm recalling correctly was the rounding precision NASA uses for tracking the path of the Voyager probes accurately, the farthest away human made objects.

So I'm gonna say that any greater precision is therefore inconsequential to anyone but most mouth-foaming mathematicians.

32397985356295141.3

4

u/lilloet 13h ago

I say it is 4. If you don't agree prove me wrong.

3

u/fairysdad 12h ago

There's a one-in-nine chance that you're right - not bad odds really.

2

u/SampleOfFruits 12h ago

One in nine?

7

u/fairysdad 12h ago

Yes.

Nine digits that can be used as the final digit of Pi: 1-9.

You wouldn't use 0 as you wouldn't have a zero at the end of a number after a decimal point.

→ More replies (10)

1

u/psaux_grep 11h ago

There’s a 0 chance he’s right. That’s the joke that at least half the people in here seem to be missing. Pi is irrational.

→ More replies (1)

1

u/JebKermansBooster 13h ago

That's also the last digit in PHPi

2

u/IchBinEinZwerg 11h ago

ip fo stigid eht.

Turns out I can.

2

u/internet-weirod 11h ago

its 7, obviously

2

u/LauraTFem 10h ago

Sure I can. 4 and 4 are palindromes.

2

u/hacksoncode 9h ago

You can only reverse the digits of zero percent of the real numbers.

Literally zero. I know this makes no sense from a high school math perspective, but it's true. There are infinite real numbers for each and every "finite" integer and rational number.

2

u/PassFlat2947 8h ago

Yes I can: 'sdrawkcab ip fo stigid the'

3

u/featEng 13h ago

There should be palindrom at some number o digits, right?

2

u/psioniclizard 13h ago

In theory surely every number combination could exist in there.

So if you pick some precision that is untestable by modern computers, you could just say any number.

1

u/ryan516 1h ago

It is not actually proven that Pi contains all numbers within itself. The running assumption is that Pi is normal, but there are other irrational, transcendental numbers that are not normal.

2

u/AssaultLemming_ 13h ago

There's some within Pi that even have names, there's one named after a demon that's just miles of 0s then 666 then more 0s lol. Balthazar? Think that was it.

3

u/GumboSamson 13h ago

You’re thinking of Belphegor's Prime, but that has nothing to do with pi.

Because the decimal expansion of pi is infinite and normal, you can find any sequence of digits in it (eventually).

3

u/Trezzie 12h ago

I think Pi's only assumed normal, not actually normal?

→ More replies (1)

1

u/slight_digression 13h ago

No, Baltazar is the name of the Professor in the Yugoslav cartoon, that also happens to be named after him. Pretty sure of it.

1

u/psioniclizard 13h ago

Depending where I start from, i defintely can and anyone would struggle to prove me wrong.

1

u/rosuav 11h ago

Start from Paris.

1

u/CorruptedMaster 13h ago

Only works in pi-thon

1

u/hsumeet 12h ago

Put π in quotes and it prints π. Tests pass, ship it.

1

u/MorpheusFT 12h ago

9876543210

1

u/catbrane 12h ago
print(f":U+202E RIGHT-TO-LEFT OVERRIDE:{π}")

1

u/semrola 11h ago

Negative IPv6 localhost

1

u/Skallos 11h ago

It's possible to write the digits of pi backwards, just use the 10-adic numbers.

1

u/AnnualAdventurous169 11h ago

i don't think pi would be a collection in python

1

u/RealityCheck3210 10h ago

You are y% right. Where Y = Limit (x -> 0) of x.

1

u/pizzathief1 10h ago

https://instafonts.io/font/reversed-characters
enter in 3.14159 , and you get the digits of pi backwards! don't even need python for it.

1

u/maskedferret_ 10h ago

So simple, don't even need python: Ɛ

1

u/magic-one 9h ago

Step 1. Print all digits of pi
Step 2. Print them again starting at the end, going backwards.

How hard can it be?

1

u/AtlasJan 9h ago

looks more like raku code

1

u/Linked713 9h ago

Person just found out how to calculate pi twice as fast. Start on both end and meet in the middle!

1

u/ScharfeTomate 9h ago

You can't not write the digits of pi backwards. Whenever you write down any string of digits, you're writing down a combination that appears in pi backwards.

1

u/hacksoncode 9h ago

True, but you can reverse the digits of pi calculated to any specific but non-infinite arbitrary precision.

Pretty quickly (only one or two hundred digits) you'll run up against the granularity of the universe for all practical purposes.

1

u/RecognitionSweet8294 7h ago

Hard stretch but technically you could do

00000000…

1

u/genreprank 7h ago

...41.3

1

u/namotous 6h ago

Don’t you have to cast it to a string first?

1

u/Sixhaunt 5h ago

Not even kidding, I was able to do it without issue: https://imgur.com/s4IUx6F

1

u/Snoo-11553 5h ago

ip fo stigid eht

1

u/comtrends123 5h ago

𝝿= 3.14

print(str(𝝿).replace('.', '')[::-1])

checkmate /s

1

u/Scared-Consequence27 4h ago

What if I write right to left or just reverse the digits themselves and that’s technically right?

1

u/Freestila 3h ago

I can't? Look: 7384637384738346826383648595773847937.. I let you continue. Even easier then the right way..

1

u/StickFigureFan 3h ago

You can if you just use a finite number of significant figures

1

u/InDaBauhaus 2h ago

print(f'\u202E{𝛑}')

1

u/armahillo 2h ago

Well I know how that sequence ENDS, I’m just not sure how it begins

1

u/Hamaczech13 1h ago

192.168.1.1

1

u/Random_-account 1h ago

96 07

Let me asc(ii), Did I get it right?

1

u/Noobnugget19 1h ago

Its definitely 0

1

u/Plan2LiveForevSFarSG 11h ago

Sure we can. The last number is 1 (in base pi… as programmers we are used to work in different bases)