Soru
What is the output of the following code? x=10 def my function(): x=20 print(x) my function() print (x) error 10 . 20 20 , 10 20 , 20
Çözüm
4.7234 Voting
Veli
Profesyonel · 6 yıl öğretmeniUzman doğrulaması
Cevap
The output of the code is:<br /><br />```<br />20<br />20<br />```<br /><br />Explanation:<br />1. The variable `x` is initially assigned the value `10`.<br />2. The function `my_function` is defined, of `x` to `20` within the function's scope.<br />3. When `my_function` is called, it prints the value of `x` inside the function, which is `20`.<br />4. After the function call, the value of `x` outside the function remains unchanged at `10`, so the final print statement outputs `20`.
Derecelendirmek için tıklayın: