हिंदी

How is yield different from return?

Advertisements
Advertisements

प्रश्न

How is yield different from return?

अंतर स्पष्ट करें
Advertisements

उत्तर

Basis of Difference yield return
Purpose Produces values from a generator Sends back a final value from a function
Execution Pauses the function and can resume later Terminates the function immediately
State Preserves local variables and execution state Function state is discarded after completion
Output Can produce a sequence of values Normally produces one result
Memory use Generally memory-efficient for large sequences May require a complete result to be created first
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 8: Exception Handling & Generate Functions - EXERCISE [पृष्ठ १५८]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 8 Exception Handling & Generate Functions
EXERCISE | Q 9. | पृष्ठ १५८
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×