Would someone be able to explain in simple English why this happens when I try to index the below... I thought I should be getting back 45, 49, 52, 55 as my answer? I'm sure I am missing something here...  times = (43, 45, 49, 52, 55) print(times[1:4]) (45, 49, 52)
106
I need a good explanation (references are a plus) on Python's slice notation.   To me, this notation needs a bit of picking up.   It looks extremely powerful, but I haven't quite got my head around it.
20105
$T(n) = 2$ if $n=0$  $T(n) = 9T(n-1)-56n +63$ if $n&gt;=1$  Repeated substitution  $k=1$  $T(n) = 9T(n-1)-56n+63 $  $k =2$  $T(n) = 81T(n-2) -560n + 1134$   $k =3$  $T(n) = 729T(n-3) -5096n + 15309$  I cant find the pattern for the n term and the integer  For now i just have  T(n) = $9^k(n-k)$
67560
I am stuck on the 4 th one.I have done the rest.I have found out the value of a_n.But not getting how to proceed for the 4 th one.
113672
For example:  &gt;&gt;&gt; x = [1, 1, 2, 'a', 'a', 3] &gt;&gt;&gt; unique(x) [1, 2, 'a', 3]   Assume list elements are hashable.  Clarification: The result should keep the first duplicate in the list. For example, [1, 2, 3, 2, 3, 1] becomes [1, 2, 3].
18119
I know there is a method for a Python list to return the first index of something:  &gt;&gt;&gt; l = [1, 2, 3] &gt;&gt;&gt; l.index(2) 1   Is there something like that for NumPy arrays?
122842
I perfectly understand the permutations formula i.e. if you have $n$ things how many ways can you rearrange it if taken $k$ at a time (or if you have $k$ slots)? So you draw the following tree. And the formula comes out naturally. $$^nP_k = \frac{n!}{(n-k)!}$$  I get that it is including all of the duplicates, too. And to get rid of them we use the combinations formula: $$^nC_k = \frac{n!}{k!(n-k)!}$$ Can somebody explain why we have to divide by the &quot;number of ways to re-arrange the slots&quot; to get rid of the duplicates? I understand that it works and the division is used to scale a number down but I am not getting that &quot;aha moment&quot; of why we do it. Can somebody explain it?
90954
Straightforward question, so if it is applied to every element of a vector that means that every one of them is scaled down exactly length times. How did people come up with this, to make it exactly 1? I am sorry if this is fairly obvious, but I just don't see it.
112773
I need to be able to take a string like:  '''foo, bar, "one, two", three four'''   into:  ['foo', 'bar', 'one, two', 'three four']   I have an feeling (with hints from #python) that the solution is going to involve the shlex module.
12628
Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:  &gt;&gt;&gt; 6/3 2 &gt;&gt;&gt; 6//3 2
54602
I was wondering whether it makes sense to use the $\sum $ notation for uncountable indexing sets. For example it seems to me it would not make sense to say  $$ \sum_{a \in A} a \quad \text{where A is some uncountable indexing set e.g. some $A \subset \mathbb{R}$ } $$  Would it be better to avoid the above notation in general for uncountable indexing sets ? Any help in making better sense of this would be very appreciated.
2695
Some of you may recognize this as Project Euler's problem number 11. The one with the grid.  I'm trying to replicate the grid in a large multidimensional array, But it's giving me a syntax error and i'm not sure why  grid = [  [ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 08 ], [ 49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00 ], [ 81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65 ], ...   And I get this error:     File "D:\development\Python\ProjectEuler\p11.py", line 3     [ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91 , 08 ],        ^ SyntaxError: invalid token   Why is it throwing an error before the comma?
23996
I am a newbie to Python and have come across the following example in my book that is not explained very well. Here is my print out from the interpreter:  &gt;&gt;&gt; s = 'spam' &gt;&gt;&gt; s[:-1] 'spa'   Why does slicing with no beginning bound and a '-1' return every element except the last one? Is calling s[0:-1] logically the same as calling s[:-1]? They both return the same result. But I'm not sure what python is doing exactly. Any help would be greatly appreciated.
70618
So I was writing up a simple binary tree in Python and came across [...]  I don't believe this to be related to the Ellipsis object, more it seems to have something to do with an infinity loop (due to Python's shallow copy?). The source of this infinity loop and why it doesn't get expanded while expanding when accessed is something I'm completely lost to, however   &gt;&gt;&gt; a [[[[[], [], 8, 3], [[], [], 3, 2], 6, 3], [], 1, 4], [[], [], -4, 2], 0, 0] &gt;&gt;&gt; Keys(a)#With a+b [0, 1, 6, 8, 3, -4] &gt;&gt;&gt; Keys(a)#With [a,b] [8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...]] &gt;&gt;&gt; Keys(a)[1]#?? [8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...], 8, [...], [...], 3, [...], [...], 6, [...], [...], 1, [...], [...], -4, [...], [...], 0, [...], [...]]     Version using a+b  def Keys(x,y=[]):     if len(x):y+=[x[2]]+Keys(x[0],y)+Keys(x[1],y)#Though it seems I was using y=y[:]+, this actually outputs an ugly mess     return y   version using [a,b]  def Keys(x,y=[]):     if len(x):y+=[x[2],Keys(x[0],y),Keys(x[1],y)]     return y   So what exactly is [...]?
79173
Given sets $A$, $B$, and $C$, prove $A\times (B\cap C)=(A \times B)\cap (A\times C)$.   It is an assignment and we have to submit it tomorrow. We are really get stuck on this and need some help.  Thanks in advance.
41203
\documentclass [12pt]{article} \oddsidemargin=0pt \topmargin=0pt \textwidth=6.5in \textheight=8.5in \begin{document} \begin{center} {\large\bf\LaTeX\ Example 6} \end{center} We can typeset array structures \begin{equation} \mathbf{A}\times \mathbf{B}=\left| \begin{array}{ccc} \mathbf{i} &amp; \mathbf{j}  &amp; \mathbf{k} \\      a_1  &amp;      a_2        &amp; a_3 \\       b_1  &amp;      b_2        &amp; b_3  \end{array}  \right| \end{equation} \begin{quote} \begin{verbatim} \begin{equation} \mathbf{A}\times \mathbf{B}=\left| \begin{array}{ccc} \mathbf{i} &amp; \mathbf{j}  &amp; \mathbf{k} \\  a_1  &amp;  a_2   &amp; a_3 \\  b_1  &amp;  b_2   &amp; b_3 \end{array} \right| \end{equation} \end{verbatim} \end{quote} Or \begin{equation} \mathbf{A}=\left( \begin{array}{ccc} a_{11} &amp; a_{12} &amp; \cdots &amp; a_{1n} \\ a_{21} &amp; a_{22} &amp; \cdots &amp;  a_{2n} \\ \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\ a_{n1} &amp; a_{n2} &amp; \cdots &amp; a_{nn} \end{array} \right) \end{equation} \end{document}
87286
Just reading about the cross product. It says here: $$A\times B= \{(x,y)|x\in A, y\in B\}$$ Does this mean that the result of $A\times B$ is a new set of ordered pairs? If so, what happens if both A and B share a common member? What would the result be, since an ordered pair cannot include duplicates?    Edit: Quoting the free textbook I'm looking at online,     If we are given that A is a set and no other information about A, then there is no   ordering to the elements of A. Thus, we cannot speak of “the second element of the set A”   unless we have specified an ordering of the elements of A. If we wish to regard A as ordered in some way, then we specify this fact explicitly: “The elements of A are ordered a, b, c,” or “A = (a, b, c).” The latter notation replaces the braces with parentheses and designates that A is ordered, left to right, as indicated. We call this an ordered set. An ordered set is also called a linear order. Various other names are also used: list, vector, string, word — all with no repeated elements. Of course, you’ve seen repeated elements in vectors, for example the point in the plane at the coordinates (1,1). That’s fine, it’s just not an ordered set.       Why is it okay to specify a set S = {a, b, c, a} where the element a has been repeated,   but it is not okay to have repeated elements in an ordering of S?   When we say S  =   {a, b, c, a}, we know that S contains just the three elements a, b and c.  If we were to talk   about the ordered set (a, b, c, a) it would not make sense because it would say that the   element a is in two places at once: the first position and the last position.
91496
Something's been bugging me about SO for a while now, that is the inaccuracy of "length of time" strings.  The best example I can give at the moment is .  If you look at the length of time he's been registered, it says 1 year.  He joined the site September 2008, which is only 3 months off two years.  It's the same with answers - you can give an answer 50 seconds before anyone else, but at certain times page views will show both as "5 minutes ago" or whatever.  That's not quite as bad, but with answers being sorted "randomly by votes" by default you could lose out on votes or being marked as the correct answer to the slower answer even if they're both the same.  There's probably a better method amongst these, IMO:   "Vulgar fraction" unicode characters     Member for 1½ years   answered 5¼ minutes ago asked 3⅓ hours ago  Different units   Member for 21 months (at least it's better than "1 year") Answered 306 seconds ago (ugly, I know) Asked 64 minutes ago (also ugly)  Combining units   Member for 1 year 9 months (fits easily on the profile screen) Answered 5 minutes 6 seconds ago (probably too long) Asked 3 hours 20 minutes ago (also long)  Rounding up   I personally prefer option 1, unicode fraction characters.  "Member for 21 months" is pretty good too because it's easy to quickly work out.  "Asked 452 seconds" ago is horrible though.  EDIT: I'm completely aware of the timestamp hover because I am forced into using it so much. It's a great feature, but it's not really in your face so not everyone knows about it. I still think there's a better "glancing" solution than having to hover over the time string.