Post

Vivekanand Tulaskar
Vivekanand Tulaskar@Viva_GT·
@Python_Dv B. 20 10 The function  func()  defines a local variable  value  and assigns 20 to it. When  print(value, end=" ")  is called inside the function, it prints the local value (20), not the global one. After  func()  is called, control returns to the main script, where  print(val)
English
0
0
0
47
Raghav Juneja
Raghav Juneja@theraghavjuneja·
@Python_Dv Python doesn't have any idea about variables defined outside the scope. If one wanna modifies the global one use global variable or pass as reference. So it's 20 10
English
0
0
0
0
Heshan Sanjuka
Heshan Sanjuka@hexsyro·
@Python_Dv value defined at top level is global = 10. Inside func(), assigning value = 20 creates a new local variable When func() runs, it prints its local value → 20. After the function returns, the global value is still 10, so the final print(value) outputs 10. Thus the output is 20 10.
English
0
0
1
2
Yohannes Assefa
Yohannes Assefa@codewithyoha·
@Python_Dv The var in side the function is local not using global variable so the value will not change so the the output will be 20 10
English
0
0
0
4
Penelope Stewart
Penelope Stewart@Digiai777·
@Python_Dv Innovation isn't about having new ideas. It's about executing old ideas better than anyone else. Execution beats innovation. 🚀
English
0
0
0
0
Joe Heinemann
Joe Heinemann@arnonuehm66·
@Python_Dv 20 20 of course. Python has no clue about local variables.
English
0
0
0
40
Naz Ashrafi
Naz Ashrafi@nazanin_ashrafi·
@Python_Dv I know it's either B or C because the second print() prints out the value outside of function scope. Idk the output of the function 🤭
English
1
0
1
156
K.AMMAAR
K.AMMAAR@k_ammaar12·
@Python_Dv It is 20 and 10 because you 10 is a global variable while 20 which is inside a func is a local variable so after calling the the function and printting the value it will execute 20 and 10
English
0
0
1
124
Premakumar Thevathasan (Prem Iyer)
Premakumar Thevathasan (Prem Iyer)@KumarT00623760·
@Python_Dv =>> Output will be 20 10. value = 10 # This is a global variable def func(): value = 20 # This is a local variable inside the function print(value, end=" ") func() # Call the function; prints the local value (20) print(value) # Prints the global value (10) More =>
Premakumar Thevathasan (Prem Iyer) tweet media
English
0
2
3
287
Paylaş