Error with subtraction with variables

I keep getting this error,

       line 37, in <module>
    ahealth = ahealth - attackdmg
TypeError: unsupported operand type(s) for -: 'int' and 'tuple'

It was for this line of code.

if playerab == ('Attack'):
        attackdmg = randint(2,4)
        pcrit = randint(1,4)
        sleep(1)
        if  pcrit == randint(1,4):
            attackdmg = attackdmg * (2,5)
            print('CRIT!')
        print('You decide to attack the Orc.')
        sleep(1)
        ahealth = ahealth - attackdmg
        print('You hit the orc for', (attackdmg))
        sleep(1)
        print('The Orc has', (ahealth), ('health remaining.'))
        print
        orcturn = True
        playerturn = False

I don't understand what is going on here, all of these variables are numbers.

Thanks :)

The line attackdmg = attackdmg * (2,5) should presumably be attackdmg = attackdmg * 2.5.

Error Analysis, assume that the quantities a, b, etc. have errors which are uncorrelated and 1 Addition or Subtraction Suppose you have a variable x with uncertainty δx. Hello, I am trying to subtract cells from data that was imported from my insurance company. However no matter what I do I get the #VALUE error, even if trying to autosum etc. I have copied and pasted the cells "as values" into new sheets and new workbooks to remove any formatting but I still have the same result.

The problem is the line attackdmg = attackdmg * (2,5) where you are multiplying an integer by the tuple (2,5).

I don't know what you were trying to do there, but that line of code works like this: if attackdmg = 1, you get (2,5), if attackdmg = 2, you get (2,5,2,5), and so on.

As you are new to python, it may be useful to explain what a tuple is. A tuple is a type of list that is immutable. It can contain one or more values. To get an item from a tuple, simply use tup[index] where 'tup' is the tuple and 'index' is the index of the value you want to return.

[PDF] A Summary of Error Propagation 1 Addition or Subtraction, The line attackdmg = attackdmg * (2,5) should presumably be attackdmg = attackdmg * 2.5 . Adding and subtracting numbers with errors When you add or subtract two numbers with errors, you just add the errors (you add the errors regardless of whether the numbers are being added or subtracted).

I just missed randint before the (2,5). So it was a tuple instead.

Error with subtraction with variables, (otherwise we could simply subtract it and report the true value) 2 Errors for functions of one variable estimate the error in the new variable given the errors. Re: Subtracting two variables. To expand my answer: yes, it's difficult (and time-consuming) to modify this variables but maybe there is a possibility to add a paremeter to the vAdoptionMinDate, vAdoptionMaxDate and vAdoptionStartRollingYear variables (and by extension to vAdoptionRangeDate, vUsersLoggingCalls_Level2

[PDF] How to combine errors, A Subtraction Problem. In this lesson, we'll talk about solving subtraction problems that have more than one variable. These are math problems that involve the  You must add or subtract from both sides of the equation by the number that is being added to or subtracted from the variable. For instance, if the equation was “x - 5 = 15,” then you would need to add 5 to both sides of the equation. The resulting sum would be x = 20.

Solving Subtraction Equations with Two or More Variables, Propagation of Error (or Propagation of Uncertainty) is defined as the effects on a It can be written that x is a function of these variables: x=f(a Addition, subtraction, and logarithmic equations leads to an absolute standard  and similar, do not actually modify anything, to save the subtraction back in the variables, use the -= operator instead. health -= 5 or you can also say . health = health - 5 The above two examples both achieve the same result. When you just say health - 5 you don't actually save it anywhere.

Propagation of Error, Step 2: Remember that when subtracting to negative numbers that the first negative stays the same while the minus sign changes to addition. Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

Comments
  • when you do attackdmg = attackdmg * (2,5), it is returning a tuple of (2,5) repeated attackdmg times
  • What did you want that line to do? Multiply by 2.5? Multiply by a random number from 2 to 5? Something different?