मराठी

What is the purpose of the yield statement?

Advertisements
Advertisements

प्रश्न

What is the purpose of the yield statement?

लघु उत्तर
Advertisements

उत्तर

The yield statement turns a function into a generator. It returns one value at a time, pauses execution, saves the function's state, and resumes from the same point during the next iteration or next() call. This saves memory because all results do not have to be stored at once.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 8: Exception Handling & Generate Functions - EXERCISE [पृष्ठ १५८]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×