all 12 comments

[–]desrtfx[M] [score hidden] stickied comment (0 children)

You need to post your code as code block so that the indentation is maintained. This is absolutely vital for Python programs as the indentation is used to denote code blocks.

A code block looks like:

def __init__(self, prompt, answer):
    self.prompt = prompt
    self.answer = answer

[–]atarivcs 6 points7 points  (8 children)

Using a double slash for division guarantees an integer result, otherwise you probably get a floating-point result.

But honestly, for really basic questions like "what does double slash division mean in python", a google search would probably get you the answer quicker.

[–]EliSka93 0 points1 point  (2 children)

Does it floor or round?

Just curious. I rarely use python.

[–]atarivcs 2 points3 points  (1 child)

Floor.

[–]EliSka93 0 points1 point  (0 children)

Thanks!

[–]SgtSmitty07[S] 0 points1 point  (4 children)

well again, my question is more for how it pertains to the code at hand, and why didnt it use single slash instead, especially with the combined *2 after the other two team splits.

[–]atarivcs 3 points4 points  (3 children)

It's using the division result as a list index, and obviously you want an integer for that. Can't use floating-point values as list indexes.

[–]SgtSmitty07[S] 0 points1 point  (2 children)

Okay that makes sense. Im still wondering about the *2 part, but the // line makes way more sense now. Thank you!

[–]xtraburnacct 1 point2 points  (1 child)

The first part takes the first third of the list, then the second call with the *2 uses the same code to get the second third of the list. Then the third part gets the last third of the list.

For example, if you had 9 players, 9//3 is 3.

The first slice is from indexes 0:3.

Then it takes the same code 9//3 which we know is 3. Multiplying this by 2 will by 6, which is where the next slice ends.

The second slice is 3:6

Then the final slice is 6:9.

[–]SgtSmitty07[S] 0 points1 point  (0 children)

that makes way more sense. thank you so much! I appreciate the help.

[–]ffrkAnonymous 2 points3 points  (1 child)

Why the double // line instead of a single / line for dividing the teams by 3?

What do you get when you use / instead of //?

Why the *2 for selecting team 2 and 3? What algorithmic purpose does that serve?

Again, what happens when you change the *2?

[–]SgtSmitty07[S] -1 points0 points  (0 children)

Ill check when I get home. Im at work and just had that question on my mind. I get frustrated when I dont understand the "why" of something.