[Tutor] (no subject)

Danny Yoo dyoo at hashcollision.org
Tue Mar 3 10:45:13 CET 2015


On Mon, Mar 2, 2015 at 10:22 PM,  <chelseysp at yahoo.com.dmarc.invalid> wrote:
>
> don't understand why these execute different things…
>
>
>
>
>  total=total+10
>>>> total=total+25
>>>> total=total+25
>>>> average=total/3
>>>> total
> 110
>>>> average
> 36.666666666666664


In your first case, what's the value of 'total' *before* all the
things you've typed in?

Can you say more why you expected to see the same result here as in
the next program?  They do look textually different, so I'd expect
them to likely have a different meaning, so I'm confused as to what
your expectations are.  Say more about why you expected them to be the
same, and maybe we can understand better.





> total=0
>>>> total=total+10
>>>> total=total+25
>>>> total=total+25
>>>> average=total/3
>>>> average
> 20.0

Your second case makes sense.  10 + 25 + 25 is 60, and if we divide 60
by 3, the we'd expect the average to be twenty.


More information about the Tutor mailing list