why Second 33 is not 13 !? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

why Second 33 is not 13 !?

input : x = 20 y = 13 z = x + y print (z) del (x) print (z) output : 33 33 So why Second 33 is not 13 !? i had deleted x(20) https://code.sololearn.com/c0ecarzU2Epr/?ref=app

27th Oct 2019, 8:00 AM
AmirReza Nejat
AmirReza Nejat - avatar
3 Answers
+ 8
del operator just removes "z" variable and doesn't affect previously constructed variables from it. For example: x=1 y=x del (x) print(y) will output 1
27th Oct 2019, 8:14 AM
Qasem
+ 7
z stores the result of x + y, it doesn't matter if x or y change, z will keep it's value until you assign a new one.
27th Oct 2019, 8:11 AM
Anton Böhler
Anton Böhler - avatar
+ 2
وقتی یک مقدار روی یک متغیر شما تأثیر بذاره حذف کردن اون مقدار قبلی باعث نمیشه که متغیر تأثیر یافته از مقدار قبلی شما دوباره دچار تغییر بشه. «متغیر تا زمانی که دوباره مقدار دهی نشود با تغییر یا حذف دیگر متغیر ها دچار تغییر نمی شود»
19th Dec 2019, 3:40 PM
babi Eshghi
babi Eshghi - avatar