Spam =3 eggs=4 del spam spam =8 eggs=5 print(spam*eggs) = 32 right? Why ans is 40? When i just deleted spam not eggs? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Spam =3 eggs=4 del spam spam =8 eggs=5 print(spam*eggs) = 32 right? Why ans is 40? When i just deleted spam not eggs?

24th Jan 2020, 7:07 AM
IA 19
IA 19 - avatar
3 ответов
+ 2
You will get more and better answers if u hack the code in and link it in your post. This time Jay Matthews did it for u.
24th Jan 2020, 7:21 AM
Oma Falk
Oma Falk - avatar
0
When you reassign the code for eggs it takes the value 5 the latter one, so 8*5= 40
24th Jan 2020, 7:35 AM
Navneet
Navneet - avatar
0
You are creating 'Spam' and assigning 3. You are creating 'eggs' and assigning 4. You then delete 'spam' which does not exist (case sensitive variables). You are then creating 'spam' and assigning 8. Then overwriting the value of eggs for 5. So replacing variables with values you get 'print(8*5).
24th Jan 2020, 8:48 AM
Stuart Pike