I'm trying to make a really simple game using python.   The game is snake ladder where the player goes from start to finish (0 - 100)  from random import randint from time import sleep  board = ["1" ,"2", "3", "4", "5", "6", "7", "8", "9", "10", "11" ,"12", "13", "14", "15",      "16", "17", "18", "19", "20", "21" ,"22", "23", "24", "25", "26", "27", "28", "29",      "30", "31" ,"32", "33", "34", "35", "36", "37", "38", "39", "40", "41" ,"42", "43",      "44", "45", "46", "47", "48", "49", "50", "51" ,"52", "53", "54", "55", "56", "57",      "58", "59", "60", "61" ,"62", "63", "64", "65", "66", "67", "68", "69", "70", "71",      "72", "73", "74", "75", "76", "77", "78", "79", "80", "81" ,"82", "83", "84", "85",      "86", "87", "88", "89", "90", "91" ,"92", "93", "94", "95", "96", "97", "98", "99",      "100"]  def print_board(board):     print ("   ".join(board[0:10]))    #first row     print ("   ".join(board[10:20]))    #second row     print ("   ".join(board[20:30]))    #third row     print ("   ".join(board[30:40]))    #fourth row     print ("   ".join(board[40:50]))    #fifth row     print ("   ".join(board[50:60]))    #six row     print ("   ".join(board[60:70]))    #seventh row     print ("   ".join(board[70:80]))    #eight row     print ("   ".join(board[80:90]))    #ninth row     print ("   ".join(board[90:100]))    #tenth row   dice = randint(1, 6)   #random number 1 - 6 def roll_dice(dice):       #function to roll the dice     print ("Rolling the dice...")     sleep(1.5)     print ("..."), dice     return   player_score = 0    #starting point / score  def player(player_score):    #for Information     print ("You are now at %d") % player_score  def main():                          #game starts     print ("Let's play a game")     while player_score &lt; 100:        #This is the problem, the while doesn't recognize player_score         print_board(board)         player_choice = input("put R for Rolling or I for Information: ")         player_choice = player_choice.upper()          if player_choice == "R":             roll_dice(dice)             if dice == 1:                 player_score = player_score + 1                 print ("Player moves.. ")                 player(player_score)                  elif dice == 2:                 player_score = player_score + 2                 print ("Player moves.. ")                 player(player_score)             elif dice == 3:                 player_score = player_score + 3                 print ("Player moves.. ")                 player(player_score)             elif dice == 4:                 player_score = player_score + 4                 print ("Player moves.. ")                 player(player_score)             elif dice == 5:                 player_score = player_score + 5                 print ("Player moves.. ")                 player(player_score)             elif dice == 6:                 player_score = player_score + 6                 print ("Player moves.. ")                 player(player_score)         elif player_choice == "I":             player(player_score)     else:         print ("Congratulations, you won the game!")   But the problem is, the loop doesn't even start. it says:     "local variable 'player_score' referenced before assignment".   Also: How can i continue the game to the player_choice again with the player_score already added?
The following code works as expected in both Python 2.5 and 3.0:  a, b, c = (1, 2, 3)  print(a, b, c)  def test():     print(a)     print(b)     print(c)    # (A)     #c+=1       # (B) test()   However, when I uncomment line (B), I get an UnboundLocalError: 'c' not assigned at line (A). The values of a and b are printed correctly. This has me completely baffled for two reasons:   Why is there a runtime error thrown at line (A) because of a later statement on line (B)? Why are variables a and b printed as expected, while c raises an error?   The only explanation I can come up with is that a local variable c is created by the assignment c+=1, which takes precedent over the "global" variable c even before the local variable is created. Of course, it doesn't make sense for a variable to "steal" scope before it exists.  Could someone please explain this behavior?
How can we run a command stored in a variable? $ ls -l /tmp/test/my\ dir/ total 0   I was wondering why the following ways to run the above command fail or succeed?  $ abc='ls -l "/tmp/test/my dir"'  $ $abc ls: cannot access '"/tmp/test/my': No such file or directory ls: cannot access 'dir"': No such file or directory  $ "$abc" bash: ls -l "/tmp/test/my dir": No such file or directory  $ bash -c $abc 'my dir'  $ bash -c "$abc" total 0  $ eval $abc total 0  $ eval "$abc" total 0 Disabled mac os SIP but still can't delete default apps I'm using mac os 11.2.1 Big Sur. My question concerns using the Terminal utility to delete Apple default apps protected by SIP. I have disabled System Integrity Protection and confirmed that it is off by typing: csrutil  Terminal duly returns &quot;disabled&quot; to confirm that SIP is definitely off. I then attempted to delete various Apple default apps, as follows: sudo rm -rf FaceTime.app/  sudo rm -rf TV.app/  sudo rm -rf Mail.app/  But nothing seems to happen. The apps are still in my Applications folder and launch normally. If I try to delete them manually, I get a beep and the deletion is rejected just as if SIP were still enabled. Can someone suggest a better way to remove Mail? Pluralization of acronyms ending in 'S' Connect Java to a MySQL database Here's my attempt at it:  $query = $database-&gt;prepare('SELECT * FROM table WHERE column LIKE "?%"');  $query-&gt;execute(array('value'));  while ($results = $query-&gt;fetch())  {     echo $results['column']; } I have a cryptography workshop question I'm having trouble with as follows;  Person A creates a cipher $E_k(m)$ which produces a ciphertext from message $m$ using key $k$. The function inside $E$ is kept secret but the length of $E_k(m)$ is known.  Person B recommends "increasing" security of the cipher by instead doing :   $(E_k(m) \oplus m)\ ||\ (E_k(m) \oplus 1111...11)$      Does this in fact increase security of the cipher or increase new problems.  My thinking is, depending on the function within $E$, xoring the output of the cipher with the plaintext message $m$ could expose the key $k$, meaning the extra complexity is for nothing. Am I on the right track, or am I missing something?  I have tried searching for examples of similar schemes and found nothing (which probably means it's not a good scheme) but I need to justify my answer.   Any steers in the right direction would be greatly appreciated, I'm more than happy to do the research myself just unsure what specifically to look for.   Unfortunately the above context is all I have been provided for this question. Proofs involving limsup and liminf I've been working with proofs involving $\limsup$ and $\liminf$, and I'm a bit confused regarding their general methodology. More specifically, I'm unsure about whether my approach to the following problem makes sense.  Problem. Let $(s_n)$ and $(t_n$) be sequences and suppose that there exists $N_0$ such that $s_n \leq t_n$ for all $n &gt; N_0$. Show that $\liminf s_n \leq \liminf t_n$ and that $\limsup s_n \leq \limsup t_n$.   The way I approached it was as follows:   Let $N &gt; N_0$. Then $\limsup_{N \rightarrow \infty} \{ s_n : n &gt; N \} \leq t_n$ as $s_n \leq t_n$, and $\limsup s_n $ is the largest possible limit of a subsequence of $s_n$. As $t_n : n &gt; N$ is (by definition) less than $\limsup_{N \rightarrow \infty} \{ t_n : n &gt; N \}$, the proof is complete.  I'm pretty sure this is incorrect, however, and I'm generally unclear about the method behind such a proof. Any help is appreciated! For all $1 \leq i < j \leq k$, the subtrees $T_i$ and $T_j$ have a vertex in common. Show that $T$ has a vertex which is in all of the $T_i$. Can someone please verify my proof or offer suggestions for improvement? I am aware that there is a similar question elsewhere, but I want help with my proof in particular.     Let $T_1, \ldots, T_k$ be subtrees of a tree $T$ such that for all $1 \leq i &lt; j \leq k$, the trees $T_i$ and $T_j$ have a vertex in common. Show that $T$ has a vertex which is in all of the $T_i$.   Suppose, for the sake of contradiction, that for every vertex $v \in V(T)$, there is a subtree $T'$ in the list $T_1, T_2, \ldots, T_k$ such that $v \notin V(T')$.  Pick $v_1 \in T_1$. There is a subtree $T^{(1)}$ such that $v_1 \notin T^{(1)}$. $T_1$ and $T^{(1)}$ have a vertex $y_1$ in common. Now, there exists a tree $T^{(2)}$ such that $y_1 \notin T^{(2)}$. But now, $T^{(2)}$ and $T^{(1)}$ have a vertex $y_2$ in common. Also, $T_1$ and $T^{(2)}$ have a vertex $y_3$ in common.  There exists a path $p_1$ in $T_1$ from $y_3$ to $y_1$. Also, there is a path $p_2$ in $T^{(1)}$ from $y_1$ to $y_2$ and a path $p_3$ in $T^{(2)}$ from $y_2$ to $y_3$. Note that the path formed by the union of $p_1$ and $p_2$ passes through $y_1$, while $p_3$ does not, since $y_1 \notin T^{(2)}$. Therefore, the union of $p_1, p_2$, and $p_3$ forms a cycle, contradicting the fact that $T$ is a tree. Therefore, it must be the case that there is a vertex $x$ in all of the $T_i$. How to call Apex REST API from Javascript? I have two different developer orgs. One contains apex REST web service, and I want to call that REST service from my second org. I have tried to call that REST service using normal ajax post request and forcetk.js, But I got following error     XMLHttpRequest cannot load   . Origin    is not allowed by   Access-Control-Allow-Origin.   I searched about this problem then I got to know that Salesforce never allows CORS (Cross-Origin-Resource-Sharing).  Initially I was using apex to call that REST web service, that time I was able to post data from apex. But as we have callout limitation in salesforce, I want to use javascript.  Can anybody please help me? We're planning to upgrade an existing farm from 2007 to 2013. I learned that the best way and maybe the only way to achieve this is by migrating in two steps. 2007 to 2010 and 2010 to 2013. The actual farm is a sql-server(2008r2 64 bit) and a sperate sharepoint-server(web-frontend, etc....) I want to keep the sql-server as it is, if possible and we want to install a new 64bit host for sharepoint 2013. We will design a new branding for 2013 afterwards, so we need to keep the content, but not the layout. There's so much about migration available on the web, but Can I find something like best practises? I have to prove that $$\lim_{n\to\infty} \left(1+n^2\right)^{\frac1n}$$ converges and give its limit. What I did was the following: $$\lim_{n\to\infty} \left(1+n^2\right)^\frac{1}{n} = \lim_{n\to\infty}(n^2)^{\frac1n}\lim_{n\to\infty}\left(\frac1{n^2} + 1\right)^\frac1n= \lim_{n\to\infty}(n^2)^{\frac1n}$$ Now that is where I am stuck - how to I continue with $\lim_{n\rightarrow\infty}(n^2)^{\frac{1}{n}}$? I really don't have any ideas left... Thank you very much! FunkyPeanut When is $2^n \pm 1$ a perfect power Is there an easy way of showing that $2^n \pm 1$ is never a perfect power, except for $2^3 + 1 = 3^2 $?  I know that   gives the result directly, but I'm hopefully for a more elementary method.    I can show that it is never a square, except for $2^3 + 1$.  Proof: Cases $n=1, 2, 3$ are easily dealt with. Henceforth, let $n\geq4$.  $2^n -1 \equiv 3 \pmod{4}$ hence is never a square.     If $2^n +1 =x^2$, then $2^n = (x-1)(x+1)$ and both of these are powers of 2. Thus we must have $(x-1) = 2, (x+1) = 4$. This gives the solution of $2^3 + 1 = 3^2$.    Let's now do an odd prime.  Say $2^n +1 = x^p$. Then $2^n = x^p - 1 = (x-1)(x^{p-1}+x^{p-2} + \ldots +1)$, so both terms are powers of 2. We have $ x = 2^m+1$ is odd. But the other term is the sum of $p$ odd numbers, hence is odd. Since this is clearly greater than 1, we get a contradiction.  Say $2^n -1 = x^p$. Then $2^n = x^p + 1 = (x+1)(x^{p-1} - x^{p-2} + \ldots -x +1 )$, so both terms are powers of 2. We have $x = 2^m -1$ is odd. But the other term is the sum of $p$ odd numbers, hence is odd. Since $x^p + 1 \neq x+1$ except for $p=1$, this means that the term is greater than 1. Hence we get a contradiction. How to prevent upper case in page header? I just came across this small problem which I can't seem to fix. I have a section which looks like this:  \section{Properties of $C_q$}   The problem is that the header of the page uses upper case and so it displays this section title as if I had written  \section{Properties of $C_Q$}   How can I make sure the q is always lower case? Creating a .desktop file for a new application I just installed the lastest version of . I works fine but in order to use it, I have to enter the following in the terminal: cd ugene-1.11.5/ then execute ./ugene -ui to launch UGENE GUI.   This takes too long. I would like to build a .desktop file for UGENE to be used in Ubuntu 12.04 so that I can simply open it from the unity launcher.  Not sure if this is helpful but the website says: By default ugene script launches the command-line version of UGENE.  Here's what I have (not sure if it's right):  [Desktop Entry] Version=1.0 Name=my Unipro UGENE GenericName=Integrated Bioinformatics Suite Comment=Unipro UGENE is a cross-platform visual environment for DNA and protein sequence analysis. MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++; Exec=/home/samuel/ugene-1.11.5 ./ugene -ui -c %F Icon=/usr/share/icons/hicolor/scalable/apps/ugene.svg Type=Application Terminal=true Categories=Utility;Development; StartupWMClass=UGENE   I added the launcher named my Unipro UGENE to my unity bar and tried opening it but it doesn't appear. I must be missing something. I don't know what the StartWMCClass field is suppose to be nor do I know whether I entered the correct MimeType. How do suggested edits work? When clicking &quot;edit&quot; I see:  Your edit will be placed in a queue until it is peer reviewed. We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.  Like:     Likewise, when I am not logged in, clicking &quot;improve this question&quot; or &quot;improve this answer&quot; shows:  You are not . Your edit will be placed in a queue until it is .  And when I click 'Save', I get:  Thanks for submitting an edit. It is only visible to you until it's been approved by trusted community members  Like:     Who can suggest an edit? Where do suggested edits go? Who can vote on a suggested edit? How do suggested edits get reviewed? Can I earn reputation? What about abuse or bad edits? Sometimes the Community user approves or rejects my edit. Why is that? When can I not suggest an edit? Is there a minimum change requirement for a suggested edit? How do I check my suggested edit history? I disagree with the reasons why my suggested edit was rejected. What can I do? How do I know whether there are edits waiting for review? Someone suggested an edit to my own post, and the reviewers took the wrong action. What can I do? Are tag wikis included in this scheme? What do the &quot;Improve Edit&quot; and &quot;Reject and Edit&quot; buttons do? Why are apparently valid links to rejected edits resulting in 404 errors?   For more information about editing, see &quot;&quot; in the . From what I understand, entropy is a concept defined by the experimentalist due to his ignorance of the exact microstate of a system. To say the number of accessible microstates $W$ of the universe is constantly increasing is nothing more than saying 'ignorance begets ignorance'.  I have often encountered the argument of ever increasing entropy for the presence of an inherent time asymmetry, most prominently in the works of Penrose. It just doesn't seem to make sense.  Let us imagine alien beings who are experiencing time in reverse. For them, increasing ignorance is in the direction of our decreasing ignorance. So how can perpetual increase in entropy indicate an 'arrow of time'?  One possible explanation (I thought of) for this argument was the fact that there may never be a mechanism to reduce ignorance. I will pose this as a question:  An observer determines the number of possible microstates of system+observer to be $W_0$ at time $t_0$. After improving his measurements, can he (at a later time) measure $W'$ (where $W_0&gt;W'$) as the number of possible microstates? Assume that all the microstates are equally probable in this case.  Unless the above in false in general, how else can anyone claim that entropy reveals an arrow of time?  EDIT: I am performing this discussion for isolated systems (the universe or it's parts if relevant). The means I propose to reduce entropy in the present, is by redefinition of macroscopic variables and of microscopic models used to count the number of distinguishable micro-states (that obviously yield the same macro-state). This is essentially an argument against the robustness of entropy via redefinition. Maclaurin series of $\ln(1-x+x^2)$ Is there a closed form expression for $\text{n}^{\text{th}}$ coefficient of Maclaurin series of  $$\ln(1-x+x^2)$$ Scaling in object and edit mode My question is: why do Object mode scaling and Edit mode scaling seem to be incompatible? I'm quite new to blender, so I may not know sth important about these modes. The actual case is:  I create a cube, which is 2×2×2 metres in metric units by default  (it's also shown under 'dimensions')    Then, with the cube selected, I switch to Edit mode, and enable 'Edge info: Length' under 'Mesh display'    And it shows the cube's measurements, which are 2m on each edge.  Now I use the scale tool in Edit mode, making the edges 2.244m    That's good so far. Changing back to Object mode, the changes can be seen under 'dimension'    However, when I use the scale tool in Object mode, the scale and dimensions also change, but changing back to Edit mode, the measurements shown remain the same      So the question is, why does the scale tool work differently and have different effects in Ojbect mode and Edit mode? Also, how can I enter the desired size of my cube manually to get an accurate result, without using the scale tool in Edit mode, and without changing the scale ratio in object mode? Systems of linear differential equations - eigenvectors How do I reset my main keychain and completely delete the old one? I changed my password and its been coming up with all of these popups asking for my new password when I first login. If anyone can help with updating my keychain I would appreciate it or you can just help me completely delete and reset it.