I am a history student who was challenged to make this program so please assume I have little knowledge of coding.  I thought my program was approaching completion but am getting an error that the variables inside the roll function are not defined. However, when I run the roll function on its own there is no problem. I'm sure this is a simple mistake but, would like to know how to correct it, and why. (learning things is cool)  import random  def roll():     die1 = random.randint(1, 6)     die2 = random.randint(1, 6)               r =  die1 + die2 return r  def Turn():     pScore = 0     cScore = 0     turn = True     while turn == True:         pChoice = str(input("Would you like to roll? Type yes or no."))         if pChoice == "yes":             roll()             if r == 2:                 turn = False                 pScore = 0                 print("You have rolled snake eyes. Your turn is over and         your score is 0.")             elif die1 == 1 or die2 == 1:                 turn = False                 pScore += r                 print("You rolled {}, {} and your score is {}. your turn is     over".format(die1, die2, pScore))             else :                 turn = True                 pScore += r             print("You rolled {}, {} and your score is {}".format(die1, die2, pScore))         if pChoice == "no":             turn = False             print("You have chosen not to roll. Your score is {}.".format(pScore))      while turn == False:         roll()         if r == 2:             turn = True             cScore = 0             print("The computer has rolled snake eyes. It's turn is over")         elif die1 == 1 or die2 == 1:             turn = true             print("The computer {}, {} and its score is {}. Its turn is over".format(die1, die2, cScore))         else:             turn = False             pScore =+ r             print("The computer {}, {} and its score is {}.".format(die1, die2, cScore))  def main():     pScore = 0     cScore = 0     while pScore &lt;100 and cScore &lt;100:         Turn()     if pScore &gt;= 100:         print("Your score is {} you win!".format(pScore))             return     elif cScore &gt;= 100:         print("The computer score is {} you lose!".format(cScore))         return main()
What exactly are the Python scoping rules?  If I have some code:  code1 class Foo:    code2    def spam.....       code3       for code4..:        code5        x()   Where is x found?  Some possible choices include the list below:   In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop   Also there is the context during execution, when the function spam is passed somewhere else. And maybe  pass a bit differently?  There must be a simple reference or algorithm somewhere.  It's a confusing world for intermediate Python programmers.
Theoretically if I were able to build some sort of device that let me sit 1 foot away from the surface of the Sun (or any star for that matter) without being vaporized, would a star produce any sort of audible sound at that distance?   From my understanding, sound waves need a medium to propagate through (air, water, etc).   Does this mean that all stars are completely silent (in the audible spectrum of frequencies at least) as they fuse  hydrogen into helium?   I know stars emit radio, xray, infrared, ultraviolet electromagnetic waves, but how about audible (20 Hz to 20Khz) frequencies?   For some reason it seems like this process would produce some sort of sound. Why is 4 not an instance of Number? Just curious:    4 instanceof Number => false new Number(4) instanceof Number => true?   Why is this? Same with strings:    'some string' instanceof String returns false new String('some string') instanceof String => true String('some string') instanceof String also returns false ('some string').toString instanceof String also returns false   For object, array or function types the instanceof operator works as expected. I just don't know how to understand this.  [new insights]  Object.prototype.is = function() {         var test = arguments.length ? [].slice.call(arguments) : null            ,self = this.constructor;         return test ? !!(test.filter(function(a){return a === self}).length)                : (this.constructor.name ||                   (String(self).match ( /^function\s*([^\s(]+)/im )                     || [0,'ANONYMOUS_CONSTRUCTOR']) [1] ); } // usage var Newclass = function(){};  // anonymous Constructor function var Some = function Some(){}; // named Constructor function (5).is();                     //=&gt; Number 'hello world'.is();           //=&gt; String (new Newclass()).is();        //=&gt; ANONYMOUS_CONSTRUCTOR (new Some()).is();            //=&gt; Some /[a-z]/.is();                 //=&gt; RegExp '5'.is(Number);               //=&gt; false '5'.is(String);               //=&gt; true I am presenting a paper at a computer science conference.  The paper I submitted to the conference mentioned future work that would significantly enhance the utility of the method.  This work was work that was always planned to be part of the same "project" as the work in the paper, indeed the conference paper is presented as a part way step towards doing X, and the future work is what takes it all the way.  The extension was quite involved (and not quite complete when I submitted the paper for review). They day before I left for the conference that work was "completed", in that a journal article about it was submitted for review.  Now when I present at the conference, in the conclusion I want to mention the future work&nbsp;&ndash; at least to the extent that it was described in the conference paper. Should I go into more detail? Should I even mention that "This work is now complete, and is under review for publication"? Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loop What are the differences between the original Kaito Kid specials vs. the new Kaito Kid 1412 series? I am currently watching . Should I watch the other  anime films?  What's the difference between this version and the 1412 version?  And another question, what's the meaning of 1412? I'm creating a beamer presentation, in which I use TikZ.  I am making a figure, on which I would like to highlight something (using \only&lt;&gt; command). My figure contains an ellipse that is decorated with random steps:  ... \node[ellipse,minimum width=1cm,black!30,decorate,decoration={random steps,segment length=0.2cm,amplitude=.1cm}] {};  \only&lt;1&gt;{ \node (n) at (0,0) {A}; } \only&lt;2&gt;{ \node (n) at (0,0) {B}; }   The ellipse is rendered in differenlty. How can I make it to render the same? or what other decoration can I use to get a similar effect to random steps? Is Lambert Academic Publishing a reputable company? I was contacted by the Acquisition editor of Lambert Academic Publishing (LAP) to publish my bachelor's thesis as a printed book. Is LAP any good? I have no idea about it; I have just heard that it's a freelance publishing house. What happens if I beat Ganon in Zelda: Breath of the Wild? I'm close to maxing out my character and I want to beat Ganon solely for the TRUE ending, but I'm too scared of losing some of my personal favorites from the Guardian Spear++ to fighting those damned Guardians (it was so fun).  So, after beating Ganon    Do monsters disappear? - Including the corrupted Guardians, but also the blood moons, I don't want to just face off against the Yiga Clan... Am I gonna run out of resources? - As a survival game Zelda BOTW has some emphasis on the survival genre but to me it is a survival-esque action-adventure game. Are special weapons still available when you max out? - Like the Savage Lynel Spears or Swords) Moderncv package - cventry date width I am writing my CV using moderncv package, everythig is nice but I have a problem with \cventry command. I have something like this:   (it means 2010 - now)  I would want to have this in one line, rather than in two lines. I tried looking into the moderncv style files but with no success. What can I do to achieve the effect I want? I'm training a neural network and the training loss decreases, but the validation loss doesn't, or it decreases much less than what I would expect, based on references or experiments with very similar architectures and data. How can I fix this?    As for question        to which this question is inspired, the question is intentionally left general so that other questions about how to reduce the generalization error of a neural network down to a level which has been proved to be attainable, can be closed as duplicates of this one.  See also dedicated thread on Meta: The space $ C^1[0,1] $- the space of all continuously differentiable functions on $ [0,1]$ is not a Banach space with respect to the sup norm,$ \|.\|_{\infty} $ since the uniform limit of a continuously differentiable function need not be differentiable.  How can I illustate this statement using a counter example? Can I use $ f_{n}=\frac1 n \sin nx $ as a counter example?  Also, is $ C^1[0,1] $ is same as the space given by $ X=\{f\in C^1[0,1]:f(0)=0 \}$. Can I use the same example to show that this is not a Banach space?  More help is appreciated! Thanks! When playing with the complete elliptic integral of the first kind and its Fourier-Legendre expansion, I discovered that a consequence of $\sum_{n\geq 0}\binom{2n}{n}^2\frac{1}{16^n(4n+1)}=\frac{1}{16\pi^2}\,\Gamma\left(\frac{1}{4}\right)^4 $ is:     $$\int_{0}^{1}\frac{\arctan x}{\sqrt{x(1-x^2)}}\,dx = \tfrac{1}{32}\sqrt{2\pi}\,\Gamma\left(\tfrac{1}{4}\right)^2\tag{A}$$   which might be regarded as a sort of Ahmed's integral under steroids.  I already have a proof of this statement (through Fourier-Legendre expansions), but I would be happy to see a more direct and elementary proof of it, also because it might have some consequences about the moments of $K(x)$ of the form $\int_{0}^{1}K(x)\,x^{m\pm 1/4}\,dx$, which are associated with peculiar hypergeometric functions. What's the grammar behind "A'warring", from the lyrics of Symphony of Destruction? What's the grammar behind A'warring, from the lyrics of Symphony of Destruction by Megadeth? It's the first time I'm seeing the use of such apostrophe. I recently bought  white LED reading lamp. I like it a lot, but the "white" light produced is significantly blue; I'll guess its  is about 5000K.  I've noticed that, when this is the only source of light, printed text appears slightly fuzzy, and is more difficult to read than with a standard incandescent reading lamp. My guess is that this is  causing color fringing in my eyes, making it harder to read with this new lamp.  Is there a way to make this lamp less blue using some sort of transparent/translucent filter over the lens? This could filter out some of the blue end of the spectrum, or include a  to convert some of the blue to yellow (as  do). The fluorescence idea would be better, as there'd be less light lost. I don't want to go too far, though; a strongly yellow lamp might be worse for reading than this currently blueish lamp. How to test hypothesis of no group differences? How do I set an environment variable on the command line and have it appear in commands? If I run  export TEST=foo echo $TEST   It outputs foo.  If I run  TEST=foo echo $TEST   It does not. How can I get this functionality without using export or a script? GNOME has grey bar on top and bottom after upgrade from 17.04 to 17.10, how do I fix it to how it's supposed to look? This is how my desktop looks after the update, the top bar turning grey and the addition of the bottom bar happened after the update.    From my searching of screenshots this does not appear to be how it is supposed to be. Is there any way to fix it? I have recently begun self-studying Number Theory, and am working on proving:     Show that every integer $n&gt;0$ can be uniquely written as $$n = \sum_{i=0}^mc_i3^i$$ where $c_i \in \{ -1,0,1\}$ and $c_m \neq 0$.   I believe I have already shown the existence portion of this proof correctly, and now I am looking for some hints on the uniqueness part. So far what I have tried is:     Suppose for the sake of contradiction that there is an alternate representation of $n$ besides $n = \sum_{i=0}^mc_i3^i$, say $n = \sum_{i=0}^pb_i3^i$ where we still have $b_p \neq 0$ and $b_i \in \{-1,0,1\}$.    At this point I felt that I first need to establish that $m=p$, and second show $c_i=b_i$ for each $i \in \{1,2,\dots,  m\}$. To show the former, I left off in my proof by contradiction with      Without loss of generality suppose $p&gt;m$. We know there is an integer $q$ such that $m+q=p$. We have two ways of writing $n$, which means $$ \sum_{i=0}^pb_i3^i-\sum_{i=0}^mc_i3^i=0 \\ \implies \left(\sum_{i=0}^mb_i3^i+\sum_{i=m+1}^{m+q}b_i3^i\right)-\sum_{i=0}^mc_i3^i=0 \\ \implies \sum_{i=0}^m(b_i-c_i)3^i+\sum_{i=m+1}^{m+q}b_i3^i=0 \\ \implies \sum_{i=m+1}^{m+q}b_i3^i=\sum_{i=0}^m(c_i-b_i)3^i$$   At this point I am stuck. If anyone has any hints to help me find the contradiction or feel that there is a better way to establish uniqueness, please let me know! I have a group of objects of the same colour, consisting of compound paths, regular paths and groups of these. How to change the colour of all objects at once? When I tried to use colour picker or change it through color palette the colour remained the same but the graphics was rendered with a very tiny outline of the new colour, which I guess is not printable. Usually I had to change the colour of all objects individually.  Edit: I'm sorry if I was not too precise. I mean to apply new colour / swatch to all member objects of the group at once, not to change properties of a commonly shared swatch.    Edit 2: I received very useful answers, however my goal was to pick a colour from another object, serving as a source. When I tried to select all objects, for example with ctrl-a, and then use a eyedropper to pick up a desired colour, it didn't work for some objects in some groups. Please have a look at my answer where several methods are listed. Sometimes I'm looking for date-sensitive information and don't want to see results more than a certain age.  Is there a way to specify this in a Google search?