import sqlite3 conn = sqlite3.connect('ProcessPower.db')  c = conn.cursor() user_input = (input("Enter a Type: "))  c.execute("SELECT * FROM Instrumentation WHERE Type = ?", user_input) rows = c.fetchall() for row in rows:     print(row) conn.close()
Using SQLite3 with Python 2.5, I'm trying to iterate through a list and pull the weight of an item from the database based on the item's name.  I tried using the "?" parameter substitution suggested to prevent SQL injections but it doesn't work. For example, when I use:  for item in self.inventory_names:     self.cursor.execute("SELECT weight FROM Equipment WHERE name = ?", item)     self.cursor.close()   I get the error:     sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 8 supplied.   I believe this is somehow caused by the initial creation of the database; the module I made that actually creates the DB does have 8 bindings.  cursor.execute("""CREATE TABLE Equipment      (id INTEGER PRIMARY KEY,      name TEXT,     price INTEGER,      weight REAL,      info TEXT,      ammo_cap INTEGER,      availability_west TEXT,     availability_east TEXT)""")   However, when I use the less-secure "%s" substitution for each item name, it works just fine. Like so:  for item in self.inventory_names:     self.cursor.execute("SELECT weight FROM Equipment WHERE name = '%s'" % item)     self.cursor.close()   I can't figure out why it thinks I have 8 bindins when I'm only calling one. How can I fix it?
Solve $[2^{(2^{403})}] = [a]$ in $\mathbb Z_{23}$ where $0 \le a < 23$. Solve $[2^{(2^{403})}] = [a]$ in $\mathbb Z_{23}$ where $0 \le a &lt; 23$.  I've tried to combine corollaries of Fermat's little theorem and various other methods to solve this, but have always been stuck. C# 3.0 auto-properties — useful or not? Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language.  I am used to create my properties in C# using a private and a public field:  private string title; public string Title {     get { return title;  }     set { title = value;  } }   Now, with  3.0, we got auto-properties:  public string Title { get; set; }   I know this is more a philosophical/subjective questions, but is there any reason to use these auto-properties except from saving five lines of code for each field? My personal gripe is that those properties are hiding stuff from me, and I am not a big fan of black magic.  In fact, the hidden private field does not even show up in the debugger, which is OK given the fact that the get/set functions do nothing. But when I want to actually implement some getter/setter logic, I have to use the private/public pair anyway.  I see the benefit that I save a lot of code (one vs six lines) without losing the ability to change the getter/setter logic later, but then again I can already do that by simply declaring a public field "Public string Title" without the need of the { get; set; } block, thus even saving more code.  So, what am I missing here? Why would anyone actually want to use auto-properties? Decision on rejected edits should be displayed as a notification to the editor Update, April 2014: I fully support  of adding the message where it belongs—in the actual editing form. This is less intrusive than displaying it as a notification, but it serves the same purpose. Can has?     Background  When you suggest an edit, the outcome of whether it was approved or rejected is buried deep within your profile. You have to navigate to Profile » Activity » Suggestions to find a list of your recent edits, but even those do not say anything about the outcome:    waffles♦ introduced this , but what can I learn from this page? I have to manually click through the edits to see whether they were rejected or not. This is  time-consuming or inefficient at best. There's also no learning involved at all, since there is no active feedback.     Feature request #1  If an edit was rejected, there should be a notification message displayed, linking to the page of the suggested edit (which states the reject reason).    This kind of feedback would improve the editing behavior, since otherwise, inappropriate suggestions might just continue.    Feature request #2  If the above is too intrusive, the messages in the profile's Activity section should be clearer, for example like this (compare against the first screenshot in the question):        This is similar to:     Here's some more explanation:  Let's assume the case of a user suggesting lots of edits that are in some way harmful. Maybe they were too minor, like only changing keyboard shortcuts to use kbd markup instead of boldface.   Yes, we've already had this on Super User. Since it only takes one user to approve / reject there, some of these edits might even have been wrongfully accepted, others  rejected. While this is a problem of its own, the user suggesting these edits will have a hard time even getting any kind of feedback.  They would never see the rejection messages because they're buried somewhere, unless they critically checked each suggestion in their profile. I doubt anybody would do this. Even more so, they might only look at their steadily climbing reputation, not really noticing a rejected edit.  Another case is users learning how to edit. How are we  if they're not told what they did wrong? They will just continue suggesting edits until somebody actually pings them in chat or comments somewhere.  Here's an  of a user who was completely unaware that he could see feedback somewhere in a dark corner of his profile, until he was banned from editing because he'd repeated the same mistake over and over. Read Committed Snapshot Isolation vs Read Committed - pros and cons? In Peter Jackson's film The Fellowship of the Ring, when the Council of Elrond takes place it shows a total of 22 members:    We all know the names of the ones who were part of the Fellowship, but I want to know who are the rest of the people in the council. Who are the elves that came with Legolas? The men next to the dwarves? The three old men sitting next to Boromir? Or the two elves next to Aragorn?  Starting from left to right:   Frodo Gandalf Elf Elf Legolas Elf Old Man Old Man Dwalin Gloin Gimli Nori Old Man Boromir Old Man Old Man Elf Elf Aragorn Elladan Elrond Elrohir Infinitely number of primes in the form $4n+1$ proof Question: Are there infinitely many primes of the form $4n+3$ and $4n+1$?  My attempt: Suppose the contrary that there exist finitely many primes of the form $4n+3$, say $k+1$ of them: $3,p_1,p_2,....,p_k$  Consider $N = 4p_1p_2p_3...p_k+3$, $N$ cannot be a prime of this form. So suppose that $N$=$q_1...q_r$, where $q_i∈P$  Claim: At least one of the $q_i$'s is of the form $4n+3$:  Proof for my claim: $N$ is odd $\Rightarrow q_1,...,q_r$ are odd $\Rightarrow q_i \equiv 1\ (\text{mod }4)$ or $q_i ≡ 3\ (\text{mod }4)$  If all $q_1,...q_r$ are of the form $4n+1$, then $(4n+1)(4m+1)=16nm+4n+4m+1 = 4(\cdots) +1$  Therefore, $N=q_1...q_r = 4m+1$. But $N=4p_1..p_k+3$, i.e. $N≡3\ (\text{mod }4)$, $N$ is congruent to $1\ \text{mod }4$ which is a contradiction.  Therefore, at least one of $q_i \equiv 3\ (\text{mod }4)$. Suppose $q_j\equiv 3\ (\text{mod }4)$  $\Rightarrow$ $q_j=p_i$ for some $1\leq i \leq k$ or $q_j =3$  If $q_j=p_i≠3$ then $q_j$ | $N = 4p_1...p_k + 3 \Rightarrow q_j=3$ Contradiction!  If $q_j=3$ ($\neq p_i$, $1\leq i \leq k$) then $q_j | N = 4 p_1...p_k + 3 \Rightarrow q_j=p_t$ for some $1 \leq i \leq k$ Contradiction!  In fact, there must be also infinitely many primes of the form $4n+1$ (according to my search), but the above method does not work for its proof. I could not understand why it does not work. Could you please show me?  Regards Mongodb: Possible to enlarge a capped collection? If a collection is created as capped, is it possible to increase the cap without losing data?  Or to increase the cap without recreating the whole collection?  Thanks Crop jpeg into circular tikz node \documentclass[demo]{article} \usepackage{graphicx} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[circle,draw,inner sep=2cm]{\includegraphics{myimage.jpg}}; \end{tikzpicture} \end{document}   How do I modify the above code so that the included image is adapted to the circle shape and cropped of the exceeding parts?  I want to specify a shape (a circle) and then include an image respecting the given dimension and cropped. I wanna create a new partition from the existing root partition.My root partition is about 250GB.I wanna create a new partition say 150 GB taking space from this root partition.Can anyone help me with the procedure on doing this?  output: fdisk -l  karthick@karthick:~$ sudo fdisk -l [sudo] password for karthick:   Disk /dev/sda: 250.0 GB, 250000000000 bytes 255 heads, 63 sectors/track, 30394 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x28219744  Device Boot      Start         End      Blocks   Id  System /dev/sda1   *           1          61      487424   83  Linux Partition 1 does not end on cylinder boundary. /dev/sda2              61       30395   243650561    5  Extended /dev/sda5              61         124      498688   82  Linux swap / Solaris /dev/sda6             124         186      498688   82  Linux swap / Solaris /dev/sda7             186       30395   242651136   83  Linux Notification that ‘someone might be watching what you browse’ What is the derivative of this? I have a function of the following form:  $J = \|W^TW-I\|_F^2$   Where, $W$ is a matrix and $F$ is the Frobenius Norm.  How can I find the derivative of $\frac{\partial J}{\partial W}$ ? Auto generate an Index Is there any way to auto-gererate an index for the makeidx package? I've written ~270 pages and didn't think of adding \index{} everywhere.  Do I really need to go over everything and add \index{}? Is it wasteful to use a heating element, instead of doing useful work? Consider a computer CPU consuming electrical energy to perform calculations and consequently emitting heat.  Assumption: That a CPU consuming x Watts of power, emits the same amount of heat as an incandescent heating element which consumes the same amount of power.  The rest of the question assumes that this is true: the energy has to go somewhere, and I can't see that the outcome of the calculations counts as "somewhere".  I've long repeated the claim that "wasteful" appliances such as incandescent lightbulbs, over-full kettles, computers left running, etc. are not wasting power if we make the assumptions:   the appliance is in a room which we aim to maintain at above a certain temperature, warmer than the external temperature (cf a home in winter) the room leaks heat to the outside faster than the "wasteful" appliances emit heat. the room contains an electric heater the electric heater is regulated by a thermostat   In these circumstances, I think (?), if a light bulb produces excess heat, its only effect is to cause the thermostat to switch off sooner, so what energy you've "wasted" in the light bulb, is "saved" at the heater.  I don't think that's controversial.  But my question is:   If a CPU does useful work, and emits all the input energy as heat as a side effect But a heating element emits the same heat, without doing useful work Is it therefore wasteful to use heating elements? Is it more efficient to (for example) run  on a CPU, to get "free" computation as a side-effect of heating?   One reason to heat a room with a heating element, rather than with CPUs, is that the heating element is much cheaper to produce. But ignoring the initial cost of the hardware, would a "heater" made out of 20 CPUs, each running at full capacity and consuming 50W each, output less thermal heat than a 1KW element that does nothing else useful?  To be useful, of course, the CPUs would need to output the result of their computations, which would account for a tiny amount of energy. Let's assume that's negligible.  I'm sure there's a flaw in there somewhere; probably that the assumption above is false. What have I missed? How to colorize an image as in the example? I have seen such an effect being used in many places however I haven't figured out how to replicate it via Photoshop.  I have tried desaturating the image, placing it under a layer of solid colour and then lowering the opacity of the colour. I have also tried a couple of blend modes, to no avail. The effect is nowhere near the same.  Can someone please tell me the effect used on these images? Help with proving that $\pi$ is irrational I was trying to prove that $\pi$ is irrational, just to see if I could do it. So far, I've tried to do this by using the fact that the sum   $$S=\sum\limits_{k=1}^\infty \frac{1}{k^2}=\frac{\pi^2}{6}$$ and arguing that $S$ is irrational instead, and thus implying that $\pi$ is also irrational.  To do this, I thought I could use partial sums $S_n$ of $S$:  $$S_n=\sum\limits_{k=1}^n \frac{1}{k^2}=\frac{A_n}{B_n}$$ where the fraction $A_n/B_n$ is written in lowest terms. We can note that the sequence $\lbrace S_n \rbrace$ is a strictly increasing sequence, with $\pi^2/6$ as its lowest upper bound, so I thought that maybe the sequences $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ both have no upper bound, and the sequences would tend to infinity, and if I were able to prove this, I thought I could use it to argue that $S$ is an irrational number, using the fact that every rational number can be written as the quotient between two finite integers.  We note that $A_n\geq B_n$ for all natural $n$, as $S_n\geq 1$, so all we would really need to prove in that case is that $\lbrace B_n \rbrace \rightarrow \infty$(if this assertion is even correct).  At first I thought that both $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ would be increasing sequences, but after checking with Maple I noticed that they weren't, sadly enough($S_9=\frac{9778141}{6350400}$ and $S_{10}=\frac{1968329}{1270080}$). However, they do indeed seem to get very large very quickly, so I'm thinking that my hypothesis about $\lbrace A_n \rbrace$ and $\lbrace B_n \rbrace$ is correct.  But I have trouble proving my hypothesis, and I'm kind of stuck, no knowing what to do. Is there a way to prove that $\lbrace B_n \rbrace \rightarrow \infty$? And of course, is this approach to prove that $\pi$ is irrational logically sound, or is it fundamentally flawed in some important aspect? In the latter case, what idea should I try next? What is the difference between "gerund" and "infinitive"? What is the difference between "gerund" and "infinitive"? I do not understand the differences.Can you explain them? Select from list of reasons when performing downvotes Preamble: I know that 'give a reason when downvoting' is a very common request, and I assure you that I have read these posts and the discussions in them and my request is very different. This isn't about encouraging people to comment and is more about gathering metrics.  I'd like to see a feature whereby people who are downvoted get some better feedback on why they were downvoted, especially given that people rarely leave comments in practice.  So my suggestion is that when user clicks on the downvote, they are prompted to pick from a short list (No more than 5) of common reasons. It would be a popup that replaces the existing "Please consider adding a comment" box.  The user receiving the downvote would see how many people downvoted them for each reason, but not who did it. It would significantly address the issue of people being too lazy to comment or not wanting to comment (for fear of retaliation or any other reason) while helping to ensure the user gets useful feedback.  Perhaps the downvote could also be weighted based on whether or not a reason is picked.  For questions the list might look something like:   Not a question Not relevant to the subject area Trivial question with no research effort Poorly asked question Other   And for answers, this might be:   Nonconstructive or not an answer Incorrect or dangerous answer Poor explanation Doesn't answer the original question Other Number theory counting sums of squares modulus This is an extra question from an old examination paper:     VI. Let $n&gt;1$ in $\mathbf{Z}$ and let $r(n) = \#\{(a,b)\in \mathbf{Z}^{2};n=a^{2}+b^{2}\}$ Let also $n=n&#39;n&#39;&#39;n&#39;&#39;&#39;$ where $n&#39;,n&#39;&#39;,n&#39;&#39;&#39; \in \mathbf{N}$ and   $p|n&#39; \Longrightarrow p\equiv 1\mod 4 ; p|n&#39;&#39; \Longrightarrow p=2 ; p|n&#39;&#39;&#39; \Longrightarrow p\equiv 3 \mod 4$   for $p\in \mathbf{N}$ prime.   i) Show that if $n&#39;&#39;&#39;$ is not a square, then $r(n)=0$.  ii) Show that if $n&#39;&#39;&#39;$ is a square and $n&#39; = 1$, then $r(n)=4$  iii) Show that if $n&#39;&#39;&#39;$ is a square and $1&lt;n&#39;=p_{1}^{e_{1}}\ddots p_{k}^{e_{k}}$ where $p_{1},...,p_{k}$ are different primes in $\mathbf{N}$ and $e_{1},...,e_{k} \in \mathbf{N}$, then it holds that $r(n)=r(n&#39;)=4(e_{1}+1)\ddots (e_{k}+1)$    I am completely dumbstruck and can't see how to begin (and neither did an older student who took this exam and whom I asked for hints). Help is greatly appreciated. Is there a way to start over?  No spoilers here, but after a certain point in the game I wish I had done something different, so I'd like to perhaps start over and make some different decisions based on my current game play experience. How to Customize the Email template on chatter posts