Assigned value to variable in function, variable undefined after function call What i want to do is have a function which checks some conditions and assigns a value according to which condition is true. But the variable assignment in the function does not affect the value outside. (Scopes)  While the following code won't work, is there any way to not have to write the if-elif block again and again?   def calc():     if o==1:         z=x+y     elif o==2:         z=x-y  calc() print(z)
Using global variables in a function How can I create or use a global variable in a function?  If I create a global variable in one function, how can I use that global variable in another function? Do I need to store the global variable in a local variable of the function which needs its access?
Blender image output is greyish and not white I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an ON clause in C#.  How do you represent the following in LINQ to SQL:  select DealerContact.* from Dealer  inner join DealerContact on Dealer.DealerID = DealerContact.DealerID Prove if $\operatorname{ord}(a)=m$, $\operatorname{ord}(b)=n$, and $\operatorname{gcd}(m,n)=1$, then $\operatorname{ord}(ab)=mn$.   I was reading this and was thinking how this proof would look like. I tried to do it and am not sure if this is correct. Here is what I did:  If $a$ and $b$ commute then $(ab)^{mn} = a^{mn} * b^{mn} = (a^m)^n * (b^n)^m = 1 * 1 = 1.$ So $ord(ab) | mn$.  Now, take $k = \operatorname{ord}(ab) = m^\prime * n^\prime$ where m' is relatively prime with $n$ and $n'$ is relatively prime with $m$. By the result above $m' | m$ and $n' | n$. Now we have $((ab)^k)^{m/m'} = 1$ since $(ab)^k=1$. But on the other hand, by the commutativity:  $$((ab)^k)^(m/m') =$$  $$((ab)^(m' * n'))^(m/m') =$$  $$ a^{n'm} * b^{n'm} = $$  $$(a^m)^{n'} * b^{n'm'}=$$  $$b^{n'm'} = 1$$  This implies that $n' * m'$ is divisible by $n$. But $m'$ is relatively prime with $n$, so we must have $n' = n.$ By symmetry, $m' = m$. So $ord(ab) = mn$.  Just to say this again, I want to prove if $a$ and $b$ commute and $m$ and $n$ are relatively prime then   $$ord(ab)=mn.$$   The comments are vague. I guess this must be the answer then and there probably is not another way to do this. I need help with this exercise. What I've done so far is prove the exercise when $n=1$. So:  $$n=1$$ $$1!\ge2^{(1-1)}$$ $$1\ge2^0$$ $$1\ge1$$ Which is true  Therefore, now that I assume that the assumption is correct, I want to prove that with $n+1$, it will also be true. So, what I've done now is:  $$P(n) \implies P(n+1) $$ $$n!+n+1\ge 2^{(n-1)}...$$ And my  problem is that I do not know how to add the $n+1$ in the right side of the equation, therefore I'm not been able to finish the exercise.  Thank you so much for your help. If something's not very clear, please let me know. I'll try to be clearer next time :) BeanFactory vs ApplicationContext Find roots of $3^x+x^3=17$ Find $x$ in the following equation: $$3^x+x^3=17$$ I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?   Input:  hoho hihi haha hede   Code:  grep "&lt;Regex for 'doesn't contain hede'&gt;" input   Desired output:  hoho hihi haha Why is find not accepting '-exec cp {} dir +'? I have a directory, dir1 which contains many files whose names end in either .jpg or .png. I want to copy all the .png files to dir2 which is empty.  This command works:  find dir1 -name '*.png' -exec cp {} dir2 \;   but this command doesn't:  find dir1 -name '*.png' -exec cp {} dir2 + find: missing argument to `-exec'   I also tried:  find dir1 -name '*.png' -exec cp {} -t dir2 + find: missing argument to `-exec'   and:  find dir1 -name '*.png' -exec cp {} dir2 \+ find: missing argument to `-exec'   After looking at , I even tried:  find dir1 -name '*.png' -exec cp {} dir2 {} + find: Only one instance of {} is supported with -exec ... +    says that:     -exec {} + was added in [version] 4.2.12 in 2005   My version of find is 4.4.2.  What am I doing wrong? Why is there free space at the end of NTFS Partitioned Drives? I've been wondering this for a while, why is there free space at the end of a drive that was formatted to NTFS in windows?  You can only see the unallocated space in Linux. So why is it there? Does it serve a purpose? book recommendation on functional analysis I was surprised to discover my dictionary had this entry for dilemma:     a situation in which a difficult choice has to be made between two or more alternatives, esp. equally undesirable ones   The notion of dilemma meaning two or more flies against what I was taught about the word. The very idea of a  is specifically based on the number two.  Has my dictionary merely updated its definition to encapsulate the many people who use dilemma for more than two equal choices? Or was someone in my youth being unnecessarily pedantic? Is there a free or open source library to read Excel files (.xls) directly from a C# program?   It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd like to eliminate the manual step. I want to display the pages 'famous' and 'mschief'.  Using this code, WP_query() doesn't return any result:  $args = array( 'post_type' =&gt; 'page', 'pagename' =&gt; 'famous,mschief', 'posts_per_page' =&gt; 3 );   This code returns one of the 2 pages:  $args = array( 'post_type' =&gt; 'page', 'pagename=famous,mschief', );   And this code returns the 2 pages correctly:  $args = array( 'post_type' =&gt; 'page', 'pagename=famous,mschief', 'posts_per_page' =&gt; 3 );   Why does the first piece of code (the only correct one to me) doesn't work? And why the two others produce these results? Why was a fox able to think about the hobbits on the road to Rivendell? How do I run two isolated instances of firefox? For testing purposes, I want to install two different instances of firefox on ubuntu - so that they don't share cookies. (I want to simultaneously login with both instances as different users to our website).  How do I do that? I do it with Firefox &amp; Opera, but I prefer Firefox (because of firebug). For some reason, I can no longer access the Winterbash 2015 page--when I try, I get redirected to the  instead, just like Winterbash is over. Except, we should still have almost another two weeks. Also, I can no longer see hat-related features on SE sites. What happened to the hats?!  UPDATE: The hats seem to be back now. But the question still remains, why did they disappear, and is it going to happen again? What is the fastest lens available for a DSLR? I've seen references to f1.2 lenses. I was wondering, are there any faster lenses available for a DSLR mount? I'm considering buying the MacBook Pro (Late 2016) with Touch Bar. As I'm a programmer and a Ubuntu user, could anyone tell me if the Touch Bar is compatible with Ubuntu? What are 'user' and 'system' times measuring in R system.time(exp) output? Are "beginner questions" allowed on Stack Overflow?