How can a list be split into equal sized chunks?
Correct Answer: def chunks(l, n): for i in xrange(0, len(l), n): yield l[i:i+n]
Explanation:
Note: This Question is unanswered, help us to find answer for this one
Python Skill Assessment
Your Skill Level: Poor
Retake Quizzes to improve it
More Python MCQ Questions
Writing to STDOUT and STDERR is fairly inflexible, and most of the time the print statement accomplishes the same purpose more flexibly. How many arguments can a print statement handle?
Which is the best way to reverse the string 'Test String' in Python?
What is the result of the following code: >>> import itertools >>> x = itertools.count(0) >>> x.__class__.__name__
What is the most flexible way to call the external command 'ls -l' in Python?
Which is the correct method for changing a global variable inside a function?
Divide by zero is a very common error. Which of the following handles this exception?
Which option is correct regarding the difference between __repr__ and __str__?
Read the following code snippet: >>> o1 = C() >>> o1.lst = [1,2,3] >>> o3 = copy.deepcopy(o1) >>> o1.lst.append(17) What will be the output of '>>> o3.lst' and '>>> o1.lst'?
Read the following statements: Statement 1: By default, a print statement adds a linefeed to the end of its output. Statement 2: The linefeed can be eliminated by adding a trailing comma to the statement. Which of the following is correct?
Which will close a list in Python?