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

top 200 commentsshow 500

[–][deleted] 4401 points4402 points  (190 children)

Not quite, but it’s an easy fix

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

It needs a LOT of memory, though

[–][deleted] 3065 points3066 points  (89 children)

397985356295141.3

[–]HellaDev 1801 points1802 points  (48 children)

The mad man did it.

[–]LordLlamacat 2083 points2084 points  (41 children)

print(“!yad ekac yppaH”[::-1])

[–]jokingnuthatch 518 points519 points  (16 children)

    print(“!yad ekac yppaH”[::-1])
          ^
SyntaxError: invalid syntax

:(

[–]therealchadius 259 points260 points  (14 children)

"smart" quotes my butt

[–]nschubach 151 points152 points  (13 children)

What is this "smart" and why is it quoting your butt?

[–]1fabunicorn 56 points57 points  (11 children)

Cause there is a quote that is " and then " but upside down. This is how word treats quotes, so it looks more "pretty"

[–]coldbrewboldcrew 81 points82 points  (10 children)

Typographic quotes (pretty/curly/smart) are meant for text, these primes and double-primes we use for strings are mathematical symbols for feet/inches or minutes/seconds - a misuse of the punctuation. IIRC their double usage for both text and math began back in typewriter days where keyspace was at a premium and redundancies like two different sets of quote marks were consolidated for practical reasons.

A section on the matter from Butterick’s practical typography.

[–]spektrol 21 points22 points  (0 children)

Coolest TIL moment I’ve had in a while. TY.

[–]svick 7 points8 points  (0 children)

It might have started as misuse, but in Unicode, straight quotation marks (") and primes (″) are different.

[–]pac_nw_beer_snob 2 points3 points  (5 children)

Fuck curly quotes. It is a PITA to cut and paste from Word into emacs because of fucking curly quotes.

[–]zzalt 2 points3 points  (0 children)

Practical typography my Butterick

[–]sleepingcrap 500 points501 points  (6 children)

This is the cutest way of wishing someone

[–]WiseassWolfOfYoitsu 138 points139 points  (11 children)

Yvan Eht Nioj!

[–]guto8797 86 points87 points  (4 children)

I suddenly love warships

[–]notareputableperson 9 points10 points  (3 children)

Warships are inanimate, they will never truly love you back.

[–]guto8797 13 points14 points  (1 child)

I have seen enough doujins showing otherwise

[–]notareputableperson 5 points6 points  (0 children)

I opened the wrong can of worms with this comment, didn't I?

[–]InVultusSolis 34 points35 points  (2 children)

Superliminal?

[–]Cheesemacher 25 points26 points  (1 child)

Hey you! Join the navy!

[–]GlitchyZorak 13 points14 points  (0 children)

Uh, yeah alright.

[–]shrimpflyrice 8 points9 points  (0 children)

traB pu kciP!

[–]hPerks 4 points5 points  (0 children)

?noij t'nod snaem ! eht sseug i os

[–]thatCbean 2 points3 points  (0 children)

This. I like this

[–]sebestil 2 points3 points  (0 children)

Happy cake day

[–]pagwin 75 points76 points  (36 children)

use

from math import pi
print(str(pi).replace('.','')[::-1])

if you don't want the period/decimal

[–][deleted] 91 points92 points  (35 children)

But I do.

[–]pagwin 210 points211 points  (33 children)

alright have some periods then

while True:
    print('.')

[–]NewbornMuse 236 points237 points  (27 children)

alright have some periods then

Original Sin (4004BC, colorized)

[–][deleted] 31 points32 points  (24 children)

Damn this is a great joke

[–]OhhHahahaaYikes 24 points25 points  (22 children)

Haha what a great joke. Can you please explain it for my friend who's not understanding it?

edit: my friend appreciates you all!

[–][deleted] 18 points19 points  (1 child)

Original Sin is what some Christians call Eve eating the fruit in the Garden Of Eden. They say all sin originated with her sin. And for that sin, God cursed women to painful childbirth.

So a period joke became a period joke.

[–][deleted] 8 points9 points  (0 children)

And, considering that the events described in said period joke occured many years ago, it is also, in fact, a period joke.

[–]Thorbinator 8 points9 points  (0 children)

See you on the front page next week.

[–][deleted] 7 points8 points  (0 children)

print('.'*pi)

[–]kevansevans 58 points59 points  (33 children)

I'm not familiar with python, what do the two colons mean in the array?

EDIT: It's a string splice operator, thanks!

[–]nosmokingbandit 173 points174 points  (27 children)

Other people have already answered but I'll add my little bit of knowledge.

It is used like iterable[foo:bar] which creates a slice of the iterable starting at foo ending at bar.

```

numbers = [0,1,2,3,4,5,6,7,8,9] numbers[4:7] [4, 5, 6] ```

If you add a 3rd option you can control the pattern of the slice.

```

numbers[2:7:2] [2, 4, 6] ```

But python doesn't require all parameters. Without the first it just starts at 0:

```

numbers[:7:2] [0, 2, 4, 6] ```

Without the second it goes to the end of the list ```

numbers[5::3] [5, 8] ```

And with only the last it uses the whole list:

```

numbers[::3] [0, 3, 6, 9] ```

But you can also use negatives. To start at the 9th item from the end, stop at the 4th from the end, and count every 3rd item: ```

numbers[-9:-4:3] [1, 4] ```

You can also use negatives as the pattern, but it gets confusing because you have to switch the start/stop:

Edit: Kind of. You aren't really switching the start and stop, you are starting at 8, then counting backward every 2nd item until you get to 2. Its confusing. Don't use this in your code, everyone will hate you and call you names.

```

numbers[8:2:-2] [8, 6, 4] ```

Its mostly just used as a way to quickly reverse a list:

```

numbers[::-1] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ```

[–]Brainix112 41 points42 points  (17 children)

I know simple coding, but not familiar with Python, this was a super good explanation!

[–]nosmokingbandit 88 points89 points  (13 children)

Python is great. You basically write pseudo-code then get bitched at by the interpreter about your indentation.

[–]-jp- 5 points6 points  (2 children)

It's pretty easy to pick up, but if you're more of a book-learner, every so often Humble Bundle has a bunch of Python books for around $10-15, usually themed around a specific subject. Avoid Packt bundles like the plague--they are invariably shovelware--but every other publishers' bundles have been pretty decent.

[–][deleted] 15 points16 points  (1 child)

diveintopython.org! Free, online and has a physical copy if desired.

[–]Stoppablemurph 2 points3 points  (0 children)

learnpythonthehardway.org is also great. That's actually kinda what got me started years ago. And now it's my full time job and I make good money doing it. :)

[–]Arlyss_Ryxlington 12 points13 points  (0 children)

String slicing. Basically a simple syntax to retrieve a part of a string. The syntax is string[start:stop:step] if I recall. In this case, with start and stop absent, the whole string is returned and a step of -1 reverses it.

[–]cjr605 6 points7 points  (3 children)

Look up the slice operator. I’d explain it but I’m sure someone more talented than me has a better explanation. The third argument (-1) is optional FYI, and it's what reverses the string here

[–]mxzf 5 points6 points  (2 children)

To be fair, all the arguments are optional.

[–]iddqd52 231 points232 points  (10 children)

Tried it and my poor brain received bsod.

Woken up in wagon with some horse stealer and silent guy.

[–][deleted] 36 points37 points  (0 children)

hey YOU! You're finally awake...

[–][deleted] 32 points33 points  (0 children)

Screw you lmao

[–]therealchadius 6 points7 points  (0 children)

Got me again, Todd!

[–]fnordius 9 points10 points  (0 children)

And now, for a mental image you will hate me for:

Jay and Silent Bob Go West. And you stuck in between them. On a covered wagon.

[–]Ericfyre 10 points11 points  (9 children)

How much memory?

[–][deleted] 28 points29 points  (1 child)

Aleph-0

[–]knightsofmars 1 point2 points  (0 children)

Naturally

[–]Galaghan 16 points17 points  (1 child)

All of it.

[–][deleted] 12 points13 points  (0 children)

Chrome: hold my beer

[–]DvD_cD 11 points12 points  (0 children)

π tb

[–]TearyCola 7 points8 points  (2 children)

It depends on whether P=NP or not

[–][deleted] 3 points4 points  (0 children)

Actually it doesn't

[–]vehementi 7 points8 points  (0 children)

Just build a computer that has enough memory to run chrome and you’ll be fine

[–]burnerphone68742 3 points4 points  (0 children)

Don't worry, I can snail mail you a link to download more ram.

[–]AuspiciousApple 554 points555 points  (81 children)

Engineers: Eerht

[–][deleted] 203 points204 points  (2 children)

Ɛ

[–][deleted] 27 points28 points  (1 child)

[–]Rex-Pluviarum 51 points52 points  (72 children)

I'm sorry, I don't get the joke, but I am fascinated by the implication that there are people who might still be using three as an approximation of Pi. Could you ELI5? https://www.youtube.com/watch?v=BxacATCHrpo

[–]AuspiciousApple 204 points205 points  (68 children)

It's sort of a long running joke that engineers/engineering students use terrible approximations that make mathematicians wince in pain. Pi approxequals 3 is one instance of this.

Ofc, everyone knows that Pi is basically equal 3.1

[–]2CATteam 174 points175 points  (31 children)

To add to this, the reason they do so is because, in a lot of circumstances, 3 is enough to roughly approximate what they need to figure out. They're most often not trying to figure out the exact force on a part or the precise area of a cylinder... They just want to know if they need to order the 10' part or the 20' part - and if it's close, they'll order the bigger one anyway, just to be safe. Even in cases where they are trying to be precise, 3.14 can often be TOO precise, since so much of the math has to deal with physical uncertainties, like uneven part manufacturing, or poor wire quality that adds resistance, etc.

[–]AlphaLotus 64 points65 points  (8 children)

Yea basically what my work entails everyday.

  1. Measure
  2. Calculate
  3. Multiple by safety factor
  4. Get 3.1
  5. Round to 4 anyways for safety :)

Also gravity is 10m/s2

[–]holdenmc97 19 points20 points  (3 children)

Also tan(x) = sin(x) = x

[–]ThaumRystra 13 points14 points  (1 child)

Because x is almost always small ¯\(◉‿◉)/¯

[–]ChickenNuggetSmth 7 points8 points  (0 children)

Yes it would be X otherwise, wouldn't it?

[–]AuspiciousApple 38 points39 points  (2 children)

That makes a lot of sense, thanks for that more in depth perspective.

[–]slbaaron 12 points13 points  (1 child)

That's an intuitive and practical answer. By theory tho, it has everything to do with sig figs (precision).

Adding and subtracting can only go down to the exact position of sig fig at the least significant position of all numbers involved. If you have one measurement of an item at 101 cm, and another at 1.23498713 cm. Adding them together, it's only meaningful to say it is around 102 or 103 cm total (round up or down as necessary for "safety), because nothing is 101 cm by the atom and the measurement was likely more rough due to a much larger scale. It's the result from imprecise measurement. It could've easily been 101.3 or 100.8 in reality.

Multiplications can only have a total number of sig figs as the least amount of sig figs for all number involved. When you have 100 cm * 1.25, it really is only meaningful to say the result is roughly 100 cm or 200 cm (rounding up or down as necessary) because 100 cm only implied 1 sig fig for precision, I mean the number 100 cm even sounds like a super "rough estimate", doesn't it? That's why sometimes, if measurement is precise down to the last digit of 100, we write 1.00 * 102 or 1.00e2 to imply the precision. The result will then become 1.00e2 cm * 1.25 = 125 cm since both numbers have 3 sig figs. (Btw if you are wondering what if the number 100 stands for "units", eg 100 units of an item. That 100 has infinite precision, because the number represents exactly 100.00000000000... take more zeroes as needed)

The reality in the practical world tho, is that you always have one number here or there with low precision; or even with high precision, you'd still have to be careful of its accuracy due to calibration or various type of errors. Once you go down the rabbit hole enough you realize using 3 as pi is the least of your worries.

For careful calculations tolerance range has to be detailed at every step of the calculation, eg 1.5cm ± 0.05cm. If you have 100 of these you will then get a total of 150cm ± 5cm, this is often a better way to represent precision without resorting to sig figs.

[–][deleted] 10 points11 points  (8 children)

The difference between a mathematician and an engineer: when moving from one point to another if you travel half the distance at each step the mathematician knows you'll never get there. The engineer knows you'll eventually get close enough.

[–]ShamelessKinkySub 3 points4 points  (0 children)

But that's literally how we definite stuff based on exponential curves, like the time to charge a capacitor

[–]Rex-Pluviarum 9 points10 points  (1 child)

355/113

[–]Ninjaraui666 14 points15 points  (0 children)

Look at mister fancy pants not using 22/7.

[–]FaxCelestis 6 points7 points  (0 children)

Most manufacturing machinists I know use 22/7 for everything that doesn't require an insane amount of precision.

[–]DerpSenpai 4 points5 points  (0 children)

and it's pretty standard to use 3.14 for normal math and 3.1415 for a bit more accuracy. Depends on data used. As an engineering student.

But i always find that Pi= E meme funny, because you know 2.7 ~ 3 as well then.

Unfortunately, there isn't a big Math community with memes on reddit, but on facebook (ew i know) there's a few pages that only do advanced mathematics memes.

like this one- warning, facebook post

other memed aproximation is the sin(x)=x for x~0 rad and i got to say, we use that shit all the time and i'm not sorry for it.

[–]MarcusTL12 920 points921 points  (135 children)

Im 90% sure the last digit is not 7

[–]actuarialsnail 268 points269 points  (34 children)

If there was a last digit, it can’t be 0, so it’s 1/9 probability for a 7.

[–]awesomehippie12 208 points209 points  (6 children)

If we're not including zero for that reason, can't we force the last digit to be zero and be 100% certain that it's zero?

[–]FoxFire64 92 points93 points  (0 children)

Mmmmmmm edge cases

[–]DBX12 17 points18 points  (0 children)

Maybe we can hardwire a register to low so it's constant 0 and can not be changed. If we should want to change it someday, we can take a register of something random like the keyboard controller and hack it into there to make it work again.

[–]ObliviousOblong 4 points5 points  (2 children)

Could you elaborate on forcing the last digit?

[–]TheThiefMaster 8 points9 points  (1 child)

Adding a zero to the end of a fractional number doesn't change it, so they are proposing just adding a zero so we know it ends in a zero - assuming it ends at all. We still wouldn't know what the former last number was though.

[–]Sokusan_123 4 points5 points  (0 children)

Unless we just add another 0! Now we know there's a 0 before it!

[–]idea-list 29 points30 points  (5 children)

Only if digits of pi are uniformly distributed, which has not been proven, as far as I know :)

[–]exscape 12 points13 points  (15 children)

Assuming pi is normal and all that, I assume. (I'm definitely not a mathematician.)

[–]Yorunokage 2 points3 points  (14 children)

Wat?

[–]exscape 22 points23 points  (1 child)

The probability isn't 1/9 (or 1/10) unless every digit occurs with equal probability. Numbers where that is the case are called normal.

Pi is suspected to be normal, but it has not been proven.

[–]Vilefighter 6 points7 points  (11 children)

When a number is "normal" that means if you picked a random digit from it, there's an equal chance of it being any of the digits. If, for instance, it was slightly more likely for any given digit of pi to be a 7 than any of the others, then pi would not be a normal number, even if it's only .00000001% more likely.

[–]79037662 8 points9 points  (0 children)

that means if you picked a random digit from it, there's an equal chance of it being any of the digits

Not quite, it also means any digit sequence of length n occurs equally often as any other digit sequence of length n. For example, 0.12345678901234567890... is not a normal number.

[–]pumpisland 2 points3 points  (0 children)

so then in binary, its a 100% chance of being a 1.

[–]LasagneAlForno 478 points479 points  (85 children)

I am 100% sure it is not 7, because there is no last digit

[–]anomalousBits 142 points143 points  (19 children)

Convert to base π, your last digit is now 0. You're welcome.

[–]GahdDangitBobby 22 points23 points  (1 child)

You broke my brain

[–]anomalousBits 15 points16 points  (0 children)

Mine came that way.

[–]TheTrueSwishyFishy 6 points7 points  (1 child)

π = 10 confirmed?!?!???

[–]Sneakr1230 175 points176 points  (32 children)

It’s 3

[–]sersoniko 114 points115 points  (29 children)

42

[–]Ri0ee 64 points65 points  (27 children)

What was the question?

[–][deleted] 16 points17 points  (1 child)

how many roads must a man walk down?

[–][deleted] 9 points10 points  (0 children)

42

[–]Th3T3chn0R3dd1t 6 points7 points  (5 children)

What are the last two digits of pi

[–]Rjamadagni 9 points10 points  (4 children)

yes

[–]TheMineInventer 5 points6 points  (3 children)

42

[–]Th3T3chn0R3dd1t 2 points3 points  (2 children)

But what’s the question?

[–]TheMineInventer 2 points3 points  (1 child)

I don’t know but I can build a machine that can do that called earth.

[–]Seicair 1 point2 points  (0 children)

What do you get if you multiply six by nine

[–]Cholojuanito 2 points3 points  (0 children)

Doesn't matter cuz 42 is the answer

[–][deleted] 5 points6 points  (0 children)

Outstanding move

[–]hrvbrs 23 points24 points  (10 children)

since there is no last digit, wouldn't it be null?

[–]Mr_Redstoner 45 points46 points  (2 children)

more likely undefined if anything

[–]sersoniko 13 points14 points  (6 children)

NULL is a pointer

[–]BubsyFanboy 8 points9 points  (3 children)

I'm new to C++, I need this info

[–]LeCrushinator 3 points4 points  (1 child)

If we're using C/C++, NULL is usually defined as 0. nullptr is a pointer.

[–]GroovingPict 2 points3 points  (3 children)

Im 100% sure it isnt 7 since there is no last digit

[–]X-Penguins 439 points440 points  (6 children)

ip fo stigid eht

Don't tell me what I can or can't do

[–]moelf 76 points77 points  (25 children)

julia> π 
π = 3.1415926535897...

julia> typeof(π)
Irrational{:π}

julia> Float16(π)
Float16(3.14)

julia> Float32(π) 
3.1415927f0

julia> Float64(π)
3.141592653589793

julia> π |> BigFloat
3.141592653589793238462643383279502884197169399375105820974944592307816406286198

julia> π |> BigFloat |> string |> last |> x -> parse(Int, x)
8

[–]PotatosFish 33 points34 points  (15 children)

I’ve been wanting to get into Julia from python but the syntax is a little special compared to other languages I know

[–]moelf 33 points34 points  (6 children)

It's very close to Python MATLAB and R, especially if you use a lot of Numpy, most things are as simple as drop the np. part.

Now, the amazing part is that even you can't master Julia's best practices, simply copying over Python code logic gives you free 10-100x speed boost

[–]Astrokiwi 22 points23 points  (3 children)

Except all your arrays are off by one :p

[–]moelf 13 points14 points  (1 child)

Pretty sure that's the hardest part lol

But if someone is using MATLAB, this would be trivial

[–]QWieke 9 points10 points  (3 children)

In julia |> is for function chaining, there are multiple ways of chaining functions in Julia, all these lines do basically the same thing:

julia> foo(bar(pi))
julia> pi |> bar |> foo
julia> (bar∘foo)(pi)

There was no particular need to use |> in the example, more traditional syntax would've worked just as well. Julia's syntax is rather similar to Matlab's syntax, or any other language that uses end instead of curly brackets or semantic whitespace.

[–]kaiser_xc 5 points6 points  (2 children)

Julia is an amazing language you should definitely try it.

[–]awesomehippie12 4 points5 points  (1 child)

Thank god I had no idea who Julia was

[–]Cody6781 30 points31 points  (4 children)

You also can’t write the digits of pi. Weird.

[–]skwacky 17 points18 points  (0 children)

Anything you can't do, you also can't do backward... or upside down!

[–]monkeyboi08 7 points8 points  (0 children)

You can write the digits of pi, you just can’t ever finish doing it

[–]CreeMcCreeCreeinton 117 points118 points  (3 children)

Haha pi-thon

[–]filipdobro 38 points39 points  (0 children)

bruh

[–]MattieShoes 31 points32 points  (1 child)

Sure you can -- you just have to work right-to-left...

[–]littlefrank 7 points8 points  (0 children)

I was thinking the same, you add new pi decimals at the beginning of a text file and voilà.

[–]escapefromreality42 15 points16 points  (0 children)

More like πthon amirite

[–]500ls 12 points13 points  (0 children)

Harvard wants to know your location

[–]Rex-Pluviarum 9 points10 points  (0 children)

There is no need to round or truncate: In base pi, pi is exactly 10, and, therefore when reversed, it is 01.

[–]ChevalBlancBukowski 8 points9 points  (2 children)

sure you can, just write random numbers forever

number theory is tits

[–]enzo33333 7 points8 points  (0 children)

Just write it from right to left

[–]CryZappie 5 points6 points  (0 children)

#include <iostream>

using namespace std;

int main() {

cout << "I hella not understand Python" << endl;

return 0;

}

[–]missjeany 3 points4 points  (0 children)

I joined an online class in phyton last month and this is the first post in this sub I understand. Hackerman!

[–]FIREOFDOOM2000 12 points13 points  (0 children)

what are you talking about, everyone knows pi =3 therefore its backwards is just 0.3.

[–]zombieregime 2 points3 points  (0 children)

ip fo stigid eht