r/ProgrammerHumor • • Aug 01 '22

>>>print(“Hello, World!”)

Post image
60.8k Upvotes

5.7k comments sorted by

View all comments

Show parent comments

2.7k

u/Equivalent-Bench5950 Aug 01 '22

Does that give a random number from 1 to 6?

1.1k

u/Popstar403 Aug 01 '22

1 - 7 but yes

1.3k

u/bob1689321 Aug 01 '22

Because 1-6 would make too much sense

78

u/partytoni1 Aug 01 '22

I guess 0-5 would have had more sense, but...

129

u/lesbianmathgirl Aug 01 '22

1-6 would make more sense, because if I'm calling a function named after a 6-sided die (yes there are other types of die, but the 6-sided one is the Platonic form), it should return the same results as you'd expect of a 6-sided die.

78

u/know_greater_evil Aug 01 '22

Exactly, this is the same reason I have all my factory classes print manufacturing sounds to the console.

Ex: BRRRRRR, WOA-THUUMP, SSSSSC SSSSSC

5

u/sascha-sphw Aug 02 '22

You made my day!

Now I am having a tough time concentrating on work again...

0

u/[deleted] Aug 01 '22

[deleted]

48

u/lesbianmathgirl Aug 01 '22

The 6-sided die is, for the majority of people, the closest physical manifestation of the abstract idea of a die. Or put another way, when most people hear the word "dice"*, they imagine a 6-sided one. For comparison, Plato would say the Platonic form of a triangle is the equilateral triangle.

*For consistency I was going to stick with "die", but it would be a lie to say that when most people hear "die" they think of anything other than death.

11

u/partytoni1 Aug 01 '22

She means that there are several types of dices, like the ones you use in a D&D game for example, that does not have 6 faces. But the de facto standard when you think about a die is the 6-sides one.

→ More replies (1)
→ More replies (10)

4

u/XiaoXiongMao23 Aug 02 '22

Actually, in addition to the d6 cube die, the d4 tetrahedron, d8 octahedron, d12 dodecahedron, and d20 icosahedron could all be considered Platonic as well ;)

→ More replies (2)
→ More replies (3)
→ More replies (4)

13

u/[deleted] Aug 02 '22

When I began programming in Python, this is what fucked me up. Ranges include the first number, but not the second number? I would constantly forget which one is included and which one is not.

5

u/SandyDigsPhreedom Aug 01 '22

And this does. Yes...of...of course - nervous liberal arts sweating-

4

u/LeafyGreensOnToast Aug 02 '22

because import die in python is like importing a bunch of info from a library called "die". die as in dice, see below lol:

5

u/SandyDigsPhreedom Aug 02 '22

Oh “die” die! Yes that makes more sense than “die” die.

(For real though thank you)

→ More replies (2)

243

u/loegare Aug 01 '22

Uh what? Why 7

199

u/[deleted] Aug 01 '22

Semi-inclusive range, I guess?

17

u/Merinther Aug 01 '22

If Die(1,6) returned a number no greater than 5, that would have made sense. But this seems backwards, and anyway, there are no arguments given – surely the default would have taken that into account?

30

u/Tsu_Dho_Namh Aug 01 '22

That can't possibly be correct.

There's no way a random die number generator is giving out 7 possible outcomes for a 6 sided die.

Popstar403 is either taking the piss or doesn't know what they're talking about.

74

u/[deleted] Aug 01 '22

Semi-inclusive means [1:7). So 1 is included, 7 is not.

16

u/Zombieattackr Aug 01 '22

I hate it but it makes so much sense when you actually need to do math and use it…

→ More replies (4)

7

u/[deleted] Aug 02 '22

Okay but they said it gives a random number 1-7. Not that it finds a number within a semi-inclusive range of 1-7, which would not ever return 7.

7

u/RunawayMeatstick Aug 02 '22

Yeah their wording was off. Ranges in Python start at the first number, but end at the last number without including it (you can think of the last number as the exit condition on a for loop)

→ More replies (1)
→ More replies (7)
→ More replies (1)
→ More replies (18)

4

u/Lord_Of_Water__l__ Aug 01 '22

Maybe range(1,7), but "1 to 6" is english.

→ More replies (10)
→ More replies (5)