+ 2

Why did eggs change in value?

There was a del for spam but no del for eggs why did eggs change in value?

15th May 2017, 9:35 AM
Anthony Tapias
Anthony Tapias - avatar
6 odpowiedzi
0
>eggs=2 >spam=3 >del spam >spam=4 >eggs=5 >print(spam* eggs) Answer was 20, since there was no del eggs, after del spam, do all values change after del spam?
15th May 2017, 10:47 AM
Anthony Tapias
Anthony Tapias - avatar
0
You can reassign the variable as many times in the program. Check the lesson 2 of the variables unit
15th May 2017, 1:19 PM
Piali Chatterjee
Piali Chatterjee - avatar
0
Okay, I got it. I wish the wording was a little more intuitive, it would help with clearer, instructions... As you define a variable, it is not being promted to compute, rather define... when you write a new line, it replaces the old value... So 5*4 is all you have to figure in this problem. the previous values are over written by the later commands of defining... its really easy. but... it also leads a wide open door to those who over think... or think deeply... without simple instructions. A lack of experience could be my issue, This is my first computer language I decided to learn so. Take me with a grain of salt.
19th May 2017, 4:05 PM
Imagined Self
Imagined Self - avatar
- 1
Here is why Because If u say >eggs=2 >spam=3 >del eggs >print (spam+eggs) Error
15th May 2017, 10:45 PM
Jeortizb