Enter value to produce keys in dictionary [Python] I have made my own Morse Code translator where you can enter the code and the corresponding letter prints out. However, what I want to do is that whenever I enter a letter, the code prints out. Here's my code:  MorseCode = {'.-':'A',             '-...':'B',             '-.-.':'C',             '-..':'D',             '.':'E',             '..-.':'F',             '--.':'G',             '....':'H',             '..':'I',             '.---':'J',             '-.-':'K',             '.-..':'L',             '--':'M',             '-.':'N',             '---':'O',             '.--.':'P',             '--.-':'Q',             '.-.':'R',             '...':'S',             '-':'T',             '..-':'U',             '...-':'V',             '.--':'W',             '-..-':'X',             '-.--':'Y',             '--..':'Z',             '.----':1,             '..---':2,             '...--':3,             '....-':4,             '.....':5,             '-....':6,             '--...':7,             '---..':8,             '----.':9,             '-----':0 }  print "Type 'help' for the morse code." print "Type 'end' to exit the program.\n" while True:     code = raw_input("Enter code:")     if code in MorseCode:         print MorseCode[code]   So the question is: Is there a way to somehow invert this dictionary so whenever I enter 'A', '.-' will print out? I'm only studying python for two weeks now so I'm still mastering the basics before I move on to the more advanced levels. Thank you!
Reverse / invert a dictionary mapping Given a dictionary like so:  my_map = {'a': 1, 'b': 2}   How can one invert this map to get:  inv_map = {1: 'a', 2: 'b'}
While writing a proposal at work today I needed to mention a list of things and within that list were multi-part items. It seems like replacing the comma with a semi-colon in this situation would make the sentence easier to understand, but is it correct usage?  With standard punctuation this could get confusing:       Some of my favorite things to do are   camping, playing football and   baseball, watching Laurel and Hardy   Movies, and traveling.   Proposed alternative. Is this acceptable usage?       Some of my favorite things to do are   camping; playing football and   baseball; watching Laurel and Hardy   Movies; and traveling. I have an older Nvidia video card and my PC crashes when installing the driver for the video card in Ubuntu 16.04. When I get to the login screen but no further: after entering my password, the system went into a loop and returned always back to the login screen [with funny stripes present].   How do I fix this problem? How do you calculate the likelihood of drawing certain cards in your opening hand? In Magic, at the start of the game, you draw 7 cards. How would you calculate the likelihood of drawing a specific card in your opening hand?  For example, let's say I have a 60 card deck, and I'm running 4 . What is the percent chance that I will have at least one Bird in my opening hand? Process substitution and pipe I was wondering how to understand the following:     Piping the stdout of a command into the stdin of another is a powerful   technique. But, what if you need to pipe the stdout of multiple   commands? This is where process substitution comes in.   In other words, can process substitution  do whatever pipe can do?   What can process substitution do, but pipe cannot? What is the progression route in Terraria? I know Americans commonly use &quot;damn&quot; or &quot;damned&quot; to describe things. Sometimes, more appropriately, it's even &quot;darn&quot; or &quot;darned&quot;. For example,  This damn/damned computer is too slow.  However, I can't wrap my head around when to use &quot;damn&quot; and when to use &quot;damned&quot;. Or is only one of them correct? PNG figures in black and white I'm trying to include a png figure and it works when I see it in dvi, but the ps comes in black and white.  If I compile directly to pdf there is no problem. However I'm using psTricks for a different figure, so I need to use ps first.  Any suggestions? gedit: search and replace with regular expressions I want to replace this with gedit:   1299465 |  2003415 | 2015-09-06 05:35:34.59662+02  1299449 |  2009400 | 2015-09-06 05:35:32.301683+02  1299450 |  2008465 | 2015-09-06 05:35:32.451393+02  1299457 |  2015211 | 2015-09-06 05:35:33.451049+02   to that:  2003415 2009400 2008465 2015211   How can I do this with gedit?  Background: I want to do it with gedit and not sed/python/.... since the replace needs to be done interactive. still frame camera solve I've found a number of how-tos for solving video but I'm just looking to put an element in a photo and can't seem to find a how-to for that.  Is it possible in blender to do a camera solve with a still image?  Thanks. Sometimes when you're downloading an image and the connection breaks mid stream, you are left with a half downloaded image. If you try to view it you get the upper part of the image and the bottom part is usually coloured grey or green or some other color.  In other words, it is corrupted.  Is there a way to check whether the image is damaged in that way or otherwise corrupted? I couldn’t find any proof on the internet. I would appreciate an elementary proof , but any help would be appreciated!  Thank you. a, b are integers. p is prime. I want to prove: $(a+b)^{p} \equiv a^p + b^p \pmod p$  I know about Fermat's little theorem, but I still can't get it I know this is valid: $(a+b)^{p} \equiv a+b \pmod p$ but from there I don't know what to do.  Also I thought about $(a+b)^{p} = \sum_{k=0}^{p}\binom{p}{k}a^{k}b^{p-k}=\binom{p}{0}b^{p}+\sum_{k=1}^{p-1} \binom{p}{k} a^{k}b^{p-k}+\binom{p}{p}a^{p}=b^{p}+\sum_{k=1}^{p-1}\binom{p}{k}a^{k}b^{p-k}+a^{p}$ Any ideas?  Thanks! Why does this CSS margin-top style not work? Simple past or past perfect with "by" and years What is the difference between      He became a star by 1990's.     He had become a star by 1990's.    Is the first sentence correct? If yes, then please tell me the difference between the two. So a couple of weeks ago my network manager icon stopped appearing; I still get automatically connected to my saved networks and the internet works fine, etc. If I go into System Settings and look at the Network settings I can still see all the networks, only the icon that's normal in the top bar is missing.  I have no idea what caused this, I don't remember installing anything. I think it just happened after a regular update.  I tried these commands to make sure I was properly up-to-date, (which I found on another forum post):  sudo apt-get -f install sudo apt-get update sudo apt-get upgrade   That didn't do it so I found this post:  and I followed the instructions in those answers:  sudo apt-get purge network-manager-gnome &amp;&amp; \ sudo apt-get install network-manager-gnome   And, quoted from an answer there:     Add nm-applet to the Startup Applications (which may be found by   entering "Startup Applications" in the Dash).   I restarted and then saw no Unity interface at all! So I tried those 3 commands above to update again and thankfully that fixed Unity but I still don't have my network manager.  If I try the command nm-applet in a terminal it says:  nm-applet-Message: using fallback from indicator to GtkStatusIcon   So.... I'm pretty much stumped. Any help would be appreciated. LLC-SCorp to self - actually, does the corp pay payroll taxes? In the USA. Here are the two common scenarios for the self-employed:  A. Joe makes 100,000 over the year. It's paid to him as 1099 payments from his various clients.  Joe pays the many taxes on that.  B. Joe makes 100,000 over the year.  He has an LLC as SCorp (or maybe an SCorp per se).  The clients pay $100,000 to the entity JoeCorp.  JoeCorp pays Joe a certain salary (it might be the whole 100,000, or, it might be (let's say) half of that and the rest is taken as profit distribution, not relevant here).  So, JoeCorp (his LLC) pays Joe say $50,000.  In fact: does JoeCorp have to pay "payroll taxes" on that??  Does it perhaps make a difference if it is an LLC with S-Corp election v. S-Corp?  (I realize there are many questions on here about "1099 v. corp" .... but I've never really understood this and can't seem to google it up.) Is it possible to only allow specific packages updates from a PPA Let us say I have added a PPA that has X package that I want but it also has Y package that I do not want to use or receive updates from. How can I, from the same PPA, receive updates for a specific package but deny updates from the same PPA for other packages.  A step by step example would be good since this has happened to me in several PPAs that have a particular package I want but also add a whole bunch of others that I do not yet want to update. Android app should send edits to edit queue if necessary rather than rejecting them No group of order 400 is simple Integrating $\int_1^2 \int_0^ \sqrt{2x-x^2} \frac{1}{((x^2+y^2)^2} dydx $ in polar coordinates I'm having a problem converting $\int\limits_1^2  \int\limits_0^ \sqrt{2x-x^2}   \frac{1}{(x^2+y^2)^2}  dy dx $ to polar coordinates.  I drew the graph using my calculator, which looked like half a circle on the x axis.  I know that $\frac{1}{(x^2+y^2)^2}  dydx$ turns to $ \frac{r}{(r^2)^2}drd\theta$, which would be $ \frac{1}{r^3}$  The region of integration in  $\theta $ is I guess $0 \leq  \theta  \leq  \frac{1}{4}  \pi $, but I'm stuck for r. The lower boundary is $x=1=rcos\theta \rightarrow r=1/cos\theta=sec\theta$, but what is the upper boundary?? Is it  $\sqrt{2rcos\theta-r^2cos^2\theta}$? I tried this but I couldn't integrate my equation...  Could someone please help me out?  Also, how can I draw the graph of $y= \sqrt{2x-x^2} $? I could only know how it looked like by using my calculator...