When trying to print the middle character of a string using the following code: def mid(a):     return a[(len(a) + 1) / 2]      print(mid(&quot;abc&quot;))  I get the error: TypeError: string indices must be integers  Changing it to:  def mid(a):     return a[(len(a) - 1) // 2 : (len(a) + 2) // 2]      print(mid(&quot;abc&quot;))  outputs: b  Why does directly grabbing the middle value return the TypeError, but grabbing the 0th value and then the middle value actually work?
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
If this is a duplicate question, please point to the right way, but the similar questions I've found here haven't been sufficiently similar. Suppose I estimate the model $$Y=\alpha + \beta X + u$$  and find that $\beta&gt;0$. However, it turns out that $X=X_1+X_2$, and I suspect $\partial Y/\partial X_1 \ne \partial Y / \partial X_2$, and in particular, that $\partial Y/\partial X_1 &gt; \partial Y / \partial X_2$. So I estimate the model $$Y=\alpha + \beta_1 X_1 + \beta_2 X_2 +u$$and find significant evidence for $\beta_1,\beta_2&gt;0$. How can I then test whether $\beta_1&gt; \beta_2$? I considered running another regression $$Y=\alpha +\gamma(X_1 - X_2) + u$$ And testing whether $\gamma&gt;0$. Is this the best way?  Also, I need to generalize the answer to many variables, i.e. suppose we have $$Y=\alpha + \beta^1 X^1 + \beta ^2 X^2 + \dots + \beta^nX^n + u$$ where for each $j=1,\dots,n$, $X^j=X_1^j+X_2^j$, and I would like to test for each $j$ whether $\partial Y/\partial X_1^j \ne \partial Y / \partial X_2^j$.  By the way, I am primarily working in R. What do the various dpkg flags like 'ii' 'rc' mean? I frequently need to check which packages are installed, and I use the following command:  dpkg -l | grep foo  which gives the following output  Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name                       Version         Description ii   foo                       &lt;version&gt;         &lt;description&gt;    What does the ii mean?  What other flags are there? How to read the flags? (because the explanation is quite complicated, IMO)   Thanks. How do I retrieve only the needed line from terminal output? Bootcamp: The startup disk does not have enough space to be partitioned When clicking continue on the first Boot Camp screen,  I am presented with a dialog that displays:     The startup disk does not have enough space to be partitioned.   You must have at least 39 GB of free space available.     This is despite "About this Mac" reporting 271GB of free space:    And "Disk Utility" reporting 268GB of free space:    Searching online I found  which suggested it was the result of Time Machine which i recently enabled and suggests to run sudo tmutil thinlocalsnapshots / 999999999999 which I did, it ran sucessfully, and I restarted, yet to no avail.  What is the solution to this instance of Apple's poor engineering?  Running macOS High Sierra 10.13.4 (17E202) Which one is correct? (Maybe both are correct.)     He passed away on the morning of March 5.   Or      He passed away in the morning of March 5. We know that if you (using Polyjuice), take the form of someone who had been injured, you assume that injured form (e.g. Barty/Moody). If you are injured, presumably you would be uninjured while under Polyjuice. My question is, is this in real-time? That is, if you take a Polyjuice, and while you're still under its effects, the person being transformed into gets injured (or even dies), will that injury be transferred onto you? And conversely, if you get injured while in someone else's body, will that transfer over to your real body after the Polyjuice wears off, will it disappear, or will it go to the person you turned into? Using a naked black hole as a mirror? This came to my mind after I learned the following from :  where T : struct   We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc.  Some of us even mastered the stuff like , , , , ...  But what are the most hidden features or tricks of C# that even C# fans, addicts, experts barely know?  Here are the revealed features so far:    Keywords    by  var by  using() statement by  readonly by  as by  as / is by  as / is (improved) by  default by  global:: by  using() blocks by  volatile by  extern alias by    Attributes    by   by   by   and  by   by   by   by    Syntax    (coalesce nulls) operator by  Number flaggings by  where T:new by  Implicit generics by  One-parameter lambdas by  Auto properties by  Namespace aliases by  Verbatim string literals with @ by  enum values by  @variablenames by  event operators by  Format string brackets by  Property accessor accessibility modifiers by  Conditional (ternary) operator (?:) by  checked and unchecked operators by  implicit and explicit operators by    Language Features   Nullable types by  Anonymous types by  __makeref __reftype __refvalue by  Object initializers by  Format strings by  Extension Methods by  partial methods by  Preprocessor directives by  DEBUG pre-processor directive by  Operator overloading by  Type inferrence by  Boolean operators  by  Pass value-type variable as interface without boxing by  Programmatically determine declared variable type by  Static Constructors by  Easier-on-the-eyes / condensed ORM-mapping using LINQ by  __arglist by    Visual Studio Features   Select block of text in editor by  Snippets by      Framework   TransactionScope by  DependantTransaction by  Nullable&lt;T&gt; by  Mutex by  System.IO.Path by  WeakReference by    Methods and Properties   String.IsNullOrEmpty() method by  List.ForEach() method by  BeginInvoke(), EndInvoke() methods by  Nullable&lt;T&gt;.HasValue and Nullable&lt;T&gt;.Value properties by  GetValueOrDefault method by    Tips &amp; Tricks   Nice method for event handlers by  Uppercase comparisons by  Access anonymous types without reflection by  A quick way to lazily instantiate collection properties by  JavaScript-like anonymous inline-functions by    Other   netmodules by     by     by The limit is   $$\lim_{x\rightarrow0} \frac{x-\sin_n(x)}{x^3},$$  where $\sin_n(x)$ is the $\sin(x)$ function composed with itself $n$ times:  $$\sin_n(x) = \sin(\sin(\dots \sin(x)))$$  For $n=1$ the limit is $\frac{1}{6}$, $n=2$, the limit is $\frac{1}{3}$ and so on.  Can we define a recurrent relation upon that given hypothesis? Also, how do I involve $n$ into calculation, because the final limit will depend on it?  Any suggestions on how to tackle this?  Thank you! Probability of student passing an exam There're $25$ tests, each with $2$ questions. There're total of $50$ different questions (the questions do not repeat). The student knows the answer of $44$ questions. To pass the exam, the student needs to correctly answer both questions on the first test he drew, or answer $1$ question from the test he drew first, and $1$ question from the test he drew second. (meaning he draws twice if he answers a question incorrectly on his first try)  What is the probability that the student will pass the exam?  I have never faced a problem like this one so any help is appreciated. I was thinking about approaching it "manually" with some applied combinatorics but I feel like there's a much easier way that I am not familiar with. apt-get build-dep is unable to find a source package let a,b be real  numbers and $\varepsilon&gt;0$. prove the above inequality. I dont know how to even start. please, I need your help. Question: If $G$ is a finite group such that the product of its elements (each chosen only once) is always $1$, independent of the ordering in the product, what can we say about $G$?  I was trying to conclude that $G$ must be abelian (I am not sure about this). I proceed as follows: if $|G|\leq 4$, then obviously, $G$ is abelian. Suppose $|G|&gt;4$. Then consider products of all elements in the order $a^{-1}b^{-1}ab cc^{-1}dd^{-1}....$. This, being identity, implies that $a^{-1}b^{-1}ab=1$, i.e. $G$ is abelian.  BUT, the problem is in $a^{-1}b^{-1}ab$, the elements $a$ and $a^{-1}$ should be distinct, and similarly for $b$. Otherwise, the product $a^{-1}b^{-1}ab cc^{-1}dd^{-1}....$ is not in the prescribed form as in question.  Also, note that the cyclic group of order $4$ doesn't satisfy that $abcd=1$ where $\{a,b,c,d\}\cong \mathbb{Z}_4$. What's the meaning of the transpose? I am running k-fold cross validation on my training data, and then choosing the best set of hyper parameters, re-training on the training data and testing on a new (unseen) testing data. I am getting the following testing results (results on the unseen data):  R^2: 1.000 Adj R^2: 1.000 RMSE: 0.081 MSE: 0.007 MAE: 0.045 MAPE: 0.058   Can $R^2$ have a value of 1.00 but RMSE have a  value of 0.081? Doesn't an $R^2$ of value 1 indicate no errors at all? How to send an SMS in iOS 10 Set Path for all Users (Login and Non-login Shells) Ok. So, I'm used to Ubuntu and CentOS more than redhat, so I'm hoping there's some obvious solution to this that I'm missing.  I've installed Anaconda (Python). I've placed it in:  /opt/anaconda3   I would like for myself and all users to be able to have the following in their paths:  /opt/anaconda3/bin   I have googled around and have gained a lot of conflicting information about how to "properly" accomplish my mission.  Stuff I have tried:   Adding a bash script to /etc/profile.d Editing /etc/profile Editing /etc/bashrc Adding to root bashrc Editing user .bashrc   All edits involved some form of:  PATH=/opt/anaconda3/bin:$PATH   or  export PATH=/opt/anaconda3/bin:$PATH   Option 2 yielded the addition of /opt/anaconda3/bin to the path for multiple users, but after terminal restarts still did not run the commands within bin (i.e. conda install, ipython notebook, etc.)  Any ideas? "We plan" versus "we are planning" Is there a semantic difference between the following two sentences?     In the future, we are planning to migrate our tool to the Z3 solver.         In the future, we plan to migrate our tool to the Z3 solver. Saving Mathematica kernel state? Do spells with a range of "Self" target the caster? New to D&amp;D, and thought about creating a Beast Master. I was wondering if spells with a range of "Self" would count you as the "target" of the spell. There's some debate in my group, as unlike something such as Cure Wounds, which specifies "A creature you touch," there's technically no mention of a target in a Self range spell within the description. A fair amount of people in my playgroup come from a TCG background, where the presence (or lack thereof) of keywords like "target" are essential for determining interaction.  tl;dr Would Paladin Smites or Thunderwave count as "targeting" yourself, and therefore be affected by Beast Master's Share Spell?