मराठी

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×