MCQs > IT & Programming > Python > Which is the correct way to write a generator which will output the numbers between 1 and 100 (inclusive)?

Python MCQs

Which of the following is the correct way to write a generator which will output the numbers between 1 and 100 (inclusive)?

Answer

Correct Answer: def onehundred(start, end): current = start while current <= end: yield current current += 1 for x in onehundred(1, 100): print x

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

More Python MCQ Questions

search

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it