Post

Python Developer
Python Developer@PythonDvz·
Comment below the output! 😃👇
Python Developer tweet media
English
14
11
118
9.4K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@Python_Dv Answer: C=10 def func(elements): Defines a function that takes a list. for x in elements: Starts looping through the list. First value is 10. return x Returns the first element immediately and exits the function. print(func([10, 20])) Function stops at 10, so output is 10.
English
0
0
0
563
Earnest Codes
Earnest Codes@Earnesto037·
@Python_Dv Answer: A. 10 The return x statement is inside the for loop, meaning the function exits immediately during the first iteration when x is assigned the value 10. The loop terminates, and the value 10 is returned
English
0
0
0
537
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@Python_Dv Answer: A Solution: Here the main trick is that... `return` takes you out of the function. Breaks out of every loop, conditional, whatever. Straight back to where the function was called from. Here func is called in the argument to print. Inside func there is a loop over +
English
0
0
0
363
墨烟行
墨烟行@CloudSwordSage·
@Python_Dv C The return will break the loop, so it'll only get elements[0]... anyway, why don't we just use elements[0] directly?
English
0
0
0
300
Paylaş