I am trying to make a median program. This is my code.  def median(list=[]):     x = 0     list = sorted(list)     if len(list) % 2 == 0:         b = int((len(list)/2))         print b         c = int(len(list)/2)         x = [list[b-1],list[c]]         print x         x = float((x[0]+x[1])/2)         print str(x)     else:         print list[((len(list)//2))]   When I run it, I get this  &gt;&gt;&gt; median([1,2,3,4]) 2 [2, 3] 2.0   What is happening?  Please note: I do not want any advice on ways to do it better, I just want help.
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
Nullable type issue with ?: Conditional Operator Could someone explain why this works in C#.NET 2.0:      Nullable&lt;DateTime&gt; foo;     if (true)         foo = null;     else         foo = new DateTime(0);   ...but this doesn't:      Nullable&lt;DateTime&gt; foo;     foo = true ? null : new DateTime(0);   The latter form gives me an compile error "Type of conditional expression cannot be determined because there is no implicit conversion between '&lt;null&gt;' and 'System.DateTime'."  Not that I can't use the former, but the second style is more consistent with the rest of my code. This is the proof, which I mostly understand except for one bit:  You have $h_1 \in H_1$ and $h_2 \in H_2$.   We also have $h_1^{-1}(h_2^{-1}h_1h_2) \in H_1$, because $h_2^{-1}h_1h_2 \in h_2^{-1}H_1h_2 = H_1$. Similarly, we have $(h_1^{-1}h_2^{-1}h_1)h_2 \in H_2$. Therefore  $$ h_1^{-1}h_2^{-1}h_1h_2 \in H_1 \cap H_2 = \{1_G\} $$  and so $h_1^{-1}h_2^{-1}h_1h_2 = \{1_G\}$. Let's first multiply everything on the left by $h_1$  $$h_1^{-1}h_2^{-1}h_1h_2 = \{1_G\}$$ $$ h_1 h_1^{-1}h_2^{-1}h_1h_2 = h_1 \{1_G\}$$ $$ h_2^{-1}h_1h_2 = h_1 \{1_G\}$$   Multiply both sides on the left by $h_2$ giving us  $$ h_1h_2 = h_2 h_1 $$  The bit I don't get is right at the beginning. Why is this correct: "We also have $h_1^{-1}(h_2^{-1}h_1h_2) \in H_1$, because $h_2^{-1}h_1h_2 \in h_2^{-1}H_1h_2 = H_1$." I want to fill a part of a picture with more or less evenly and randomly distributed circles which should not overlap. It would be okay if circles are only partly inside the shape.  The density should be like what you see on this page  with values 80-100. (But I do not need so many circles, 30 should be enough, I could repeat the pattern).   I cannot use a grid and "wobble" the circles a bit: The circles are too large and it simply does not look randomly.   Currently I am thinking about a random attempt: Get some random point, measure its distance to existing circles, either paint or throw the point away. Try 100 times and hope that you get the right number of circles (and that it does not take too long). But perhaps someone has a better idea.   The example draws the circles simply manually:  \documentclass{article} \usepackage{tikz} \usetikzlibrary{backgrounds} \begin{document}   \begin{tikzpicture}[framed,gridded,radius=0.5cm]  \draw[red](0,0) rectangle (5,5);   \draw (1,1) circle;   \draw (2.3,1.1) circle ;   \draw (4.5,0.8) circle ;   \draw (5.1,1.8) circle ;   \draw (0.4,3.3) circle ;   \draw (2.1,2.8) circle ;   \draw (3.8,3.5) circle ;   \draw (4.8,4.2) circle ;   \draw (0.8,4.9) circle ;   \draw (2.1,4.1) circle ;   \draw (3.8,2.0) circle ;   \draw (3.5,0.6) circle ;   \draw (3.0,5.0) circle ;      \draw (4.1,5.1) circle ;             \draw (0.9,2.1) circle ;  \end{tikzpicture}  \end{document} python: restarting a loop cin and getline skipping input ATI Radeon HD 7770 no GPU rendering? Should we use wheatstone bridges nowadays? For measuring strain gauges, the Wheatstone bridge is the historical choice.  In a quarter Wheatstone brigde (\$350 \Omega \$ typically (?)), with a high input impedance amplifier, and some bridge power voltage \$V\$, the ratio between the bridge output voltage w.r.t. any resistor is 1/4, which is the same ratio in a voltage divider between the output voltage w.r.t. any resistor, compared with a stable voltage reference of \$V/2\$.    A voltage divider with a voltage reference would have a voltage noise of about 35.16 nV/rtHz (from a voltage reference of 35 nV/rtHz plus two resistors), and the Wheatstone bridge a voltage noise of 4.86 nV/rtHz (from four resistors), which should be enough (?) for most ADC systems (i.e. for 24 bit, 0-5V range: 300nV resolution).  And a voltage reference (\$0.02\%\$ initial error, \$2 \ ppm/C^\circ\$, ), would be more stable and precise (?) about \$4\ ppm/C^\circ\$, than a precision resistor (\$0.005\%\$ error, \$2 \ ppm/C^\circ \$, ), about \$8 \ ppm/C^\circ\$.  Hence, why bother using Wheatstone bridges? if $f^{(n)}(x_0),g^{(n)}(x_0)$ exist and $\lim_{x\to x_0} \dfrac{f(x)-g(x)}{(x-x_0)^n}=0$ then $f^{(r)}(x_0)=g^{(r)}(x_0 )$ for all $0\leq r\leq n.$ Show:   if $f^{(n)}(x_0),g^{(n)}(x_0)$ exist and   $$\lim_{x\to x_0} \dfrac{f(x)-g(x)}{(x-x_0)^n}=0$$   then $f^{(r)}(x_0)=g^{(r)}(x_0 )$ for all $0\leq r\leq n.$   My attempt:  let n = 1,  since $f'(x_0),g'(x_0)$ exists then The taylor polynomial exists: $$T_{f,1}(x)=f(x_0)+f'(x_0)(x-x_0), \lim_{x\to x_0} \dfrac{f(x)-T_{f,1}(x)}{(x-x_0)}=0$$  $$T_{g,1}(x)=g(x_0)+g'(x_0)(x-x_0), \lim_{x\to x_0} \dfrac{g(x)-T_{g,1}(x)}{(x-x_0)}=0$$  Then, \begin{align} \lim_{x\to x_0} \dfrac{f(x)-g(x)}{(x-x_0)^n} &amp; =\lim_{x\to x_0} \dfrac{f(x)-g(x)+T_{f,1}(x)-T_{f,1}(x)+T_{g,1}(x)-T_{g,1}(x)}{(x-x_0)^n}\\ &amp;=\lim_{x\to x_0} \dfrac{f(x)-g(x)+T_{f,1}(x)-T_{f,1}(x)+T_{g,1}(x)-T_{g,1}(x)}{(x-x_0)^n}\\ &amp;=\lim_{x\to x_0} \dfrac{f(x)-T_{f,1}(x)}{x-x_0}-\lim_{x\to x_0} \dfrac{g(x)-T_{g,1}(x)}{x-x_0}+\lim_{x\to x_0} \dfrac{T_{f,1}(x)-T_{g,1}(x)}{x-x_0}\\ &amp;=\lim_{x\to x_0}\dfrac{T_{f,1}(x)-T_{g,1}(x)}{x-x_0}\\ &amp;=0 \end{align}  Then, \begin{align} \lim_{x\to x_0}\dfrac{T_{f,1}(x)-T_{g,1}(x)}{x-x_0} &amp;=\lim_{x\to x_0}\dfrac{f(x_0)+f'(x_0)(x-x_0)-g(x_0)-g'(x_0)(x-x_0)}{x-x_0}\\ &amp;=\left(f(x_0)-g(x_0)\right)\lim_{x\to x_0}\dfrac{1}{x-x_0}+f'(x_0)-g'(x_0) \\&amp;=0 \end{align} I am confused because  $\lim_{x\to x_0}\dfrac{1}{x-x_0}$ does not exist. Redirecting stdout to a file you don't have write permission on How many combinations can I make? let $n \gt 1$ be an integer, and consider $n$ people; $P_1, P_2,..., P_n$ let $A_n$ be the number of ways these $n$ people can be divided into groups, such that each group have either one or two people  determine $A_1, A_2, A_3$  So I have  $A_1 = 1$ way $A_2 = 4$ way $A_3 = 12$ way  But I am not sure if this is right... Can anyone confirm?  edit:  My way of getting this is  $A_1 = 1 $ because {P1} only has 1 way to sort  $A_2 = 4$ because {P1,P2} = {P1,P2},{P2,P1},{P1P2},{P2P1}  etc. How to make files protected? How to make some file that contains crucial data protected? For instance, suppose I have some files that are important, is there any method or strategy to make these kind of file more protected on Ubuntu? I even want to make some files ask for a password whenever someone tries to open it. Does it affect the version of Ubuntu in terms of security policy? May I use any encryption algorithm externally? Regards. There is an experimental timeline view for questions now available on meta ONLY! (Now working on SO, SF, and SU as well)  This is partially motivated by comments about how difficult it is to follow very active questions which have a lot of activity, and also the feedback on the API which was heavily dominated by "we need to know what happened in this time range" type responses.  It can only be accessed through URL hackery at the moment. To get to it, enter question URLs like so:  https://meta.stackexchange.com/posts/{id}/timeline  This is a chronological timeline of everything that happened on a question, including   initial question ask answers  revisions comments closure, deletion, reopen, undelete, etc votes   all based on when they happened in chronological order.  We are thinking about making this a fourth tab on the question, like so:  Timeline | Oldest | Newest | Votes  Please try it out and provide feedback. It is still a little rough, so we are not looking for highly detailed bug reports, just more general feedback.  Timeline view for this question: Can you use twinned spell on the same target? So me and my DM have been arguing on how Twinned spell works. Twinned spell:  When you cast a spell that targets only one creature and  doesn't have a range of self, you can spend a number of  sorcery points equal to the spell's level to target a second  creature in range with the same spell (1 sorcery point if  the spell is a cantrip).  I argued that &quot;a second creature&quot; can be a the same target as it is not worded as &quot;another creature&quot; For this example counter spell with twinned spell.  A wizard casts fireball on me I use CounterSpell#1 with Twinned Spell Wizard casts CounterSpell on my CounterSpell#1 I use him as the same target for my twinned Spell CounterSpell#2  Result countered Is this possible? How can author deal with late reviews? Another problem I personally struggle with in peer-review publication process is the situation when review takes really, really, really long. The precise definition of "long" is probably very area-specific: for example a paper in Maths will probably took longer to review than one in Physics. Many well-established journals and major publishers, sadly, prefer not to specify the "rules of the game" precisely, particularly how long the review process should normally take. Fortunately, I quite often serve as a referee with the very same journals and know the amount of time I am given to write a review. Unfortunately, when I am an author, I do not observe these deadlines to be always met. For example, a notable U.S. publisher would ask a reviewer to send a review in 2 months; but in practice a first review of my paper once took as long as 8 months.  As a rule of thumb, I usually start writing to editors with questions about "the status of my paper" in X+1 months time, when X is a deadline time for a reviewer to submit a review. This strategy is not particularly successful &mdash; what I usually get is a recommendation to be more patient. Since there is no "official" deadline time announced, there is no formal ground for complaints here.  Of course, such delays lead to a whole bunch of funny situations, particularly if a preprint is put online (e.g., on arXiv) and the results are presented in some conferences. Follow-ups with no official paper to cite, grant applications in which you can not justify by a solid publication, good research but bad bibliometrics or CV, to name just a few.   Could you recommend an efficient way to deal with this problem? Is it possible to change the color of a single bar when the bar plot is based on symbolic values? I am beginner in LaTeX, trying to use it for industrial documents. I wonder if there is a way to change the color of only one bar of the plot below, ie "TestDetails", to illustrate it is a local macro and not a LaTeX keyword. I have been trying to experiment with point meta, but could not find a way.  \documentclass{article} \usepackage{filecontents}  \usepackage{pgfplots}  \usepackage{pgfplotstable} \pgfplotsset{width=.95\textwidth, compat=newest}   \begin{document}  \begin{filecontents}{data.csv} {Occurences}, {keyword} 215, item 159, SI 134, subsubsection 106, TestDetails 58, caption \end{filecontents}  \pgfplotstableread[col sep=comma]{data.csv}{\datatable}  \begin{tikzpicture} \begin{axis}[ /pgf/number format/.cd,1000 sep={}, width=0.8\linewidth,height=6cm, xbar, xmin=30, xmax=250, xtick=\empty, enlarge x limits={value=0.1, upper}, enlarge y limits=0.1, ytick=data,  y dir=reverse, xlabel= {}, y tick label style={major tick length=0pt}, yticklabels from table={\datatable}{[index]1}, nodes near coords, nodes near coords align=horizontal, ] \addplot [draw,fill=blue!50]table[ y expr=\coordindex, x index=0]{\datatable}; \end{axis} \end{tikzpicture}  \end{document} Is it worth getting a suspension seat post as a cheap alternative to full suspension bike? I'm planning a ride from Birmingham to London on the Grand Union Canal (UK), which will be quite bumpy for most of the 145 mile distance.  I have a front suspension bike and can't afford a new full suspension bike.  Do suspension seat posts actually work?  If so, I'll get one of them.  Can anyone recommend a good model? Obtaining consistent one-hot encoding of train / production data How do I pipe each command given to the shell? I'd like to edit my .bashrc so that every command executed on the shell is piped to something, for example:   $ sudo apt update   _________________ &lt; sudo apt update &gt;  -----------------     \   ^__^      \  (oo)\_______         (__)\       )\/\             ||----w |             ||     ||   I have managed something rather similar, but not entirely:  $ bash $ exec &gt; &gt;(cowsay) $ echo "Hello AU!" $ exit  _______ &lt; Hello AU! &gt;  -------     \   ^__^      \  (oo)\_______         (__)\       )\/\             ||----w |             ||     ||   It is not the desired result, as it only happens after exiting the current shell.  It's mainly for fun/learning purposes. Use filecontents environment to write a binary file In  of mine, I was trying to show how to embed an audio file into the pdf with the multimedia package. The resulting MWE does not stand on its own because it requires an example audio file.  I guess my first question is, does TeXLive include any example audio files? The second, and potentially less uninteresting question is, can I use the filecontents environment, or some other environment, to create a binary file?  \documentclass{article} \usepackage{graphicx} \usepackage[implicit=false]{hyperref} \usepackage{multimedia}  % What goes in here to produce a usable wav file. Happy to use a different environment. \begin{filecontents}{\jobname.wav} \end{filecontents}  \begin{document} \sound[inlinesound]{\includegraphics{example-image}}{\jobname.wav} \end{document} Replace preg_replace() e modifier with preg_replace_callback