My dict is like,  {'A':4,'B':10,'C':0,'D':87}   I want to find max value with its key and min value with its key.  Output will be like ,  max : 87 , key is D  min : 0  , key is C  I know how to get min and max values from dict. Is there is any way to get value and key in one statement?  max([i for i in dic.values()])  min([i for i in dic.values()])
I have a dictionary: keys are strings, values are integers.  Example:   stats = {'a':1000, 'b':3000, 'c': 100}   I'd like to get 'b' as an answer, since it's the key with a higher value.  I did the following, using an intermediate list with reversed key-value tuples:  inverse = [(value, key) for key, value in stats.items()] print max(inverse)[1]   Is that one the better (or even more elegant) approach?
I tried to install wine using these commands: sudo apt-get install -y wine  And: sudo apt-get install wine  But terminal says that: Reading package lists... Done Building dependency tree        Reading state information... Done Package wine is a virtual package provided by:   winehq-staging 2.16.0~zesty   winehq-stable 2.0.2~zesty   winehq-devel 2.16.0~zesty   wine-development 2.0-3ubuntu1 You should explicitly select one to install.  E: Package 'wine' has no installation candidate  So there are 4 different version of wine. What is the difference between these versions. Which one is better? I wanted to install Internet Explorer from it and I installed winehq-stable. But I couldn't see that among applications in Winetricks. Do the other versions of wine have more applications to install? What is the difference? How can I change the registered name in Windows 7 to my own? Why Dumbledore kept mum until the very end of the "Deathly Hallows"? Graph Proof by induction. Can you prove via induction that there exists a node in a directed graph of n nodes that can be reached in at most two edges from every other node in the graph. Every node in the graph is required to have an edge with every other node that either points out or in (For every pair of nodes X and Y, either X points to Y or Y points to X). How SELECT column does not list in GROUP BY clause The query:  select year,sum(mark),sum(maxmark)  from table1  group by parameterno   yields an error message:     Column 'table1.year' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. I've been trying to work out what generic means but I'm not making much progress.   You can find an example of the usage of the word generic for example : "School on Generic Singularities in Geometry" or :  "Rigidity of generic singularities of mean curvature flow"  Here is what I have so far:  I found  which mentions   "... "generic" singularities, i.e., singularities that appear for almost all maps ..."  Just after that he mentions "generic maps" but does not elaborate on what it means. He mentions it later (kind of) by saying  "...The precise definition of a generic map is very delicate; for the moment, we say only that any map may be approached by a generic map (up to an approximation on the derivatives of order r), and that any map that is sufficiently close to a generic map, in the preceding sense, is itself generic. ..."  and later  on he gives a definition of "generic singularity of a singular set":  "... A critical point $x$ of $S_r$ will be called transversally critical, or, furthermore, generic, if the tangent planes to $ \overline{f}(\mathbb R^n) $ and $F_r$ are in general position at the point $\overline{f} (x)$ of the Grassmannian, which is assumed to be ordinary on $F_r$ . ..."  Does this mean that generic and transversally critical are synonyms?  I feel I still don't understand what generic means even after reading this definition and part of the article.      Please could someone help me understand what generic means? Why Wi-Fi is getting turned-on automatically in iOS 11 bounding a $C^1$ function that upholds $f'(t)\leq 1-f(t)^2$ Show that $d_b(x,y)=\frac{d(x,y)}{1+d(x,y)}$ is a metric. where $(X,d)$ is a metric and $x,y \in X$.  I know we need to show:   non-negativity: $d(x,y)\geq$ 0 $d(x,y)=0$ if and only if $x=y$ symmetry: $d(x,y)=d(y,x)$ $d(x,z)\leq d(x,y) + d(y,z)$   I think we need to consider the derivative of $f(t)=\frac{t}{1+t}$ however I am not sure what to do next. "Closed" form for $\sum \frac{1}{n^n}$ Earlier today, I was talking with my friend about some "cool" infinite series and the value they converge to like the Basel problem, Madhava-Leibniz formula for $\pi/4, \log 2$ and similar alternating series etc.  One series that popped into our discussion was $\sum\limits_{n=1}^{\infty} \frac{1}{n^n}$.  Proving the convergence of this series is trivial but finding the value to which converges has defied me so far. Mathematica says this series converges to $\approx 1.29129$.  I tried Googling about this series and found very little information about this series (which is actually surprising since the series looks cool enough to arise in some context).  We were joking that it should have something to do with $\pi,e,\phi,\gamma$ or at the least it must be a transcendental number :-).  My questions are:   What does this series converge to? Does this series arise in any context and are there interesting trivia to be known about this series?   I am actually slightly puzzled that I have not been able to find much about this series on the Internet. (At least my Google search did not yield any interesting results). A circle has the same center as an ellipse and passes through the foci $F_1$ and $F_2$ of the ellipse, two curves intersect in $4$ points. Consciousness is an electrical and chemical interaction in the brain, caused by neurons firing and chemical interactions. How does a mechanical "force" cause this to stop working?  i.e. How does a mechanical action (such as a punch to the head) cause this electrical/chemical system to stop working (leading to unconsciousness)? $L^p$ integrable but not $L^q$ integrable When should I use mmap for file access? POSIX environments provide at least two ways of accessing files.  There's the standard system calls open(), read(), write(), and friends, but there's also the option of using mmap() to map the file into virtual memory.  When is it preferable to use one over the other?  What're their individual advantages that merit including two interfaces? C++ STL Vector Iterator accessing members of an Object I think I've declared a Vector with an object correctly.  But, I don't know how to access it's members when looping with Iterator.  In my code, the line --->>  cout &lt;&lt; " " &lt;&lt; *Iter;  How do I print the contents of the members?  Like *Iter.m_PackLine ???  Not sure if I used the correct terminology, but appreciate the help!  Thanks  class CFileInfo {   public:       std::string m_PackLine;       std::string m_FileDateTime;       int m_NumDownloads; };  void main() {   CFileInfo packInfo;    vector&lt;CFileInfo, CFileInfo&amp;&gt; unsortedFiles;   vector&lt;CFileInfo, CFileInfo&amp;&gt;::iterator Iter;    packInfo.m_PackLine = "Sample Line 1";   packInfo.m_FileDateTime = "06/22/2008 04:34";   packInfo.m_NumDownloads = 0;   unsortedFiles.push_back(packInfo);    packInfo.m_PackLine = "Sample Line 2";   packInfo.m_FileDateTime = "12/05/2007 14:54";   packInfo.m_NumDownloads = 1;   unsortedFiles.push_back(packInfo);   for (Iter = unsortedFiles.begin(); Iter != unsortedFiles.end(); Iter++ )  {     cout &lt;&lt; " " &lt;&lt; *Iter; // !!! THIS IS WHERE I GET STUMPED     // How do I output values of the object members?   } }  // end main Proper subspaces of $ R^n $ I'm trying to prove that proper subspaces of $ R^n $ are closed and have empty interiors.  To prove that they are closed I'm trying to use the fact that inverse images of closed sets are closed sets by continuous functions. So I'm trying to find a linear map such that a proper subspace of $ R^n $ is its Kernel but I don't know how to express it so that it would work on all dimensions.  Regarding the fact that they have empty interiors, I really don't know what to do.  Thanks in advance. Counting degrees of freedom of gauge bosons Gauge bosons are represented by $A_{\mu}$, where $\mu = 0,1,2,3$. So in general there are 4 degrees of freedom. But in reality, a photon (gauge boson) has two degrees of freedom (two polarization states).   So, when someone asks about on-shell and off-shell degrees of freedom, I thought they are 2 and 4. But I read that the off-shell d.of. are 3.   And my question is how to see this? R version 3.1.1 (2014-07-10) -- "Sock it to Me" &gt; bl &lt;- c(140, 138, 150, 148, 135) &gt; fu &lt;- c(138, 136, 148, 146, 133) &gt; t.test(fu, bl, alternative = "two.sided", paired = TRUE) Error in t.test.default(fu, bl, alternative = "two.sided", paired = TRUE) :  data are essentially constant   Then I change just a single character in my fu dataset:  &gt; fu &lt;- c(138, 136, 148, 146, 132)   and it runs...  &gt; t.test(fu, bl, alternative = "two.sided", paired = TRUE)      Paired t-test   What am I missing here? How long can I store a food in the pantry, refrigerator, or freezer? How do I know if a given food or ingredient I have is still good, or if I should discard it?  How can I best preserve a food or ingredient?     This broad question is intended as a "general reference" question to quickly answer many how long will food keep for? questions. Please feel free to edit this question to expand and clarify as needed. PUA.Phishing.Bank Found