LearnFrenzy
Sign in Take a free test

Python Programming · Practice by type

Python Programming MCQ Questions and Answers

Multiple-choice questions on Python Programming concepts and common errors, topic by topic, each with the answer and a clear explanation.

  • 615 questions
  • 25 topics
  • Answers checked on a real compiler

Python Basics and Syntax 25 questions

  1. How does CPython run a .py file? Easy
  2. How does Python mark a block of code? Easy
  3. Writing a comment in Python Easy
  4. Which name is a valid identifier? Easy
  5. Which word is a Python keyword? Easy
  6. Default values of sep and end in print() Easy
  7. What type does input() return? Easy
  8. Indentation recommended by PEP 8 Easy
  9. Purpose of if __name__ == "__main__" Medium
  10. What is a docstring? Medium
  11. Continuing a statement on the next line Medium
  12. What does pass do? Easy
  13. Which statement about Python is false? Medium
  14. Several statements on one line Easy
  15. When are syntax errors reported? Hard
  16. Error: expected an indented block Easy
  17. Error: unexpected indent Easy
  18. Error: missing colon after if Easy
  19. Error: a keyword used as a variable name Easy
  20. Error: Python 2 style print Easy
  21. Error: apostrophe inside a single-quoted string Medium
  22. Error: Print with a capital P Easy
  23. Error: joining a string and a number Easy
  24. Error: arithmetic on input() Medium
  25. Bug: the sum of two inputs is wrong Medium

Variables and Data Types 25 questions

  1. What is a variable in Python? Easy
  2. Dynamic and strong typing Medium
  3. Which type is immutable? Easy
  4. Largest value of an int Easy
  5. Which value is truthy? Medium
  6. is versus == Medium
  7. The relationship between bool and int Medium
  8. What is None? Easy
  9. Converting "12.5" with int() Medium
  10. How round() treats .5 Hard
  11. Does b = a copy a list? Medium
  12. Writing a complex number Easy
  13. Why prefer isinstance()? Hard
  14. Changing a character of a string Medium
  15. Why is 0.1 + 0.2 not exactly 0.3? Medium
  16. Error: using a variable before assigning it Easy
  17. Error: int() on a decimal string Easy
  18. Error: len() of a number Easy
  19. Error: a space in a variable name Easy
  20. Error: changing one character of a string Medium
  21. Error: a variable named str Medium
  22. Error: a number with a leading zero Medium
  23. Bug: comparing floats with == Medium
  24. Bug: bool("False") is True Hard
  25. Bug: the backup changes too Medium

Operators and Expressions 25 questions

  1. The result type of / Easy
  2. Floor division with a negative number Medium
  3. The sign of the remainder Medium
  4. Associativity of ** Medium
  5. Unary minus and ** Medium
  6. What a chained comparison means Easy
  7. What or returns Medium
  8. Short-circuit evaluation Medium
  9. What does ^ do? Easy
  10. The value of ~x Medium
  11. in with a dictionary Medium
  12. Incrementing a variable Easy
  13. The walrus operator Medium
  14. Precedence of not, and, or Hard
  15. x *= 2 + 3 Hard
  16. Error: average of an empty list Easy
  17. Error: = instead of == in a condition Easy
  18. Error: using ++ Easy
  19. Error: multiplying two strings Medium
  20. Error: an incomplete range check Easy
  21. Bug: grade == "A" or "B" Medium
  22. Bug: average loses its decimals Easy
  23. Bug: wrong temperature conversion Medium
  24. Bug: ^ used as a power operator Medium
  25. Error: comparing a string with a number Medium

Conditional Statements 25 questions

  1. The keyword for "else if" Easy
  2. How many branches of an if-elif chain run? Easy
  3. Which if does an else belong to? Medium
  4. An empty list as a condition Easy
  5. Python's ternary syntax Easy
  6. any() and all() on an empty list Hard
  7. Which version added match-case? Easy
  8. Fall-through in match-case Medium
  9. The default case in match Easy
  10. A bare name in a case Hard
  11. What is a guard? Medium
  12. Variables created inside an if Medium
  13. Testing one value against several Medium
  14. The right way to test for None Medium
  15. Why use guard clauses? Medium
  16. Error: else if instead of elif Easy
  17. Error: elif after else Easy
  18. Error: an if block with only a comment Medium
  19. Error: else indented differently from its if Medium
  20. Error: a constant name in a case Hard
  21. Error: a variable assigned in only one branch Medium
  22. Bug: the topper is graded as a pass Medium
  23. Bug: two labels printed for one temperature Easy
  24. Bug: menu choice 1 is "invalid" Medium
  25. Bug: an 18-year-old cannot vote Easy

Loops 25 questions

  1. Is the stop value of range included? Easy
  2. Counting down with range Easy
  3. When does a loop's else run? Medium
  4. What does continue do? Easy
  5. break in nested loops Medium
  6. do-while in Python Easy
  7. The loop variable after the loop Medium
  8. What does enumerate() give? Easy
  9. zip() with lists of different lengths Medium
  10. for n in 5 Easy
  11. Looping over a dictionary Easy
  12. Removing items while looping Hard
  13. A float step in range Medium
  14. When is a while condition checked? Easy
  15. How many times does the inner body run? Medium
  16. Error: looping over an int Easy
  17. Error: an index one past the end Easy
  18. Error: a for loop without a colon Easy
  19. Error: break outside a loop Medium
  20. Bug: the sum of 1 to 10 is 45 Easy
  21. Bug: not every even number is removed Medium
  22. Error: deleting dict keys during iteration Hard
  23. Bug: the total is only the last mark Easy
  24. Bug: "not found" printed several times Medium
  25. Error: a decimal step in range Medium

Strings 25 questions

  1. Are strings mutable? Easy
  2. What does s[-1] mean? Easy
  3. A slice beyond the end Medium
  4. Reversing a string Easy
  5. find() versus index() Medium
  6. split() with no argument Medium
  7. join() with numbers Medium
  8. isdigit() on "-5" Medium
  9. How strings are compared Medium
  10. Why does s.upper() "not work"? Easy
  11. What is a raw string? Medium
  12. count() and overlapping matches Hard
  13. ord() and chr() Easy
  14. Triple-quoted strings Easy
  15. An f-string format spec Medium
  16. Error: index equal to the length Easy
  17. Error: joining numbers Easy
  18. Error: index() of a missing substring Medium
  19. Error: double quotes inside a double-quoted string Easy
  20. Bug: the name is not converted to capitals Easy
  21. Bug: "python" not found at the start Hard
  22. Bug: word count includes empty strings Medium
  23. Bug: "Madam" is not a palindrome Medium
  24. Error: append() on a string Easy
  25. Error: repeating a string a float number of times Medium

Lists 25 questions

  1. append() versus extend() Easy
  2. What does list.sort() return? Easy
  3. remove() versus pop() Easy
  4. Properties of a list Easy
  5. The [[0] * 3] * 3 trap Hard
  6. What can sorted() take? Medium
  7. What is a stable sort? Hard
  8. Shallow copy of a nested list Medium
  9. insert() at an index past the end Medium
  10. A float as a list index Medium
  11. The cost of pop(0) Hard
  12. a += [x] versus a = a + [x] Hard
  13. remove() with duplicates Easy
  14. Sorting a list of mixed types Medium
  15. What does a[:] create? Easy
  16. Error: pop() from an empty list Easy
  17. Error: remove() of an absent item Easy
  18. Error: sorting numbers and strings together Medium
  19. Error: marks = marks.sort() Medium
  20. Bug: append() where extend() was meant Easy
  21. Bug: one seat booked, a whole column booked Hard
  22. Bug: "last three" gives two items Medium
  23. Error: a missing comma in a list literal Easy
  24. Error: the middle element with / Medium
  25. Error: push() on a list Easy

Tuples 25 questions

  1. Creating a one-item tuple Easy
  2. What immutability means for tuples Easy
  3. How many methods does a tuple have? Medium
  4. What creates a tuple? Medium
  5. A list inside a tuple Medium
  6. Unpacking the wrong number of values Easy
  7. Returning several values Easy
  8. Tuples as dictionary keys Medium
  9. How tuples are compared Medium
  10. sorted() on a tuple Medium
  11. The type of a starred target Medium
  12. Why use namedtuple? Medium
  13. Adding an item to a tuple Easy
  14. t[0] += [x] where t[0] is a list Hard
  15. When to prefer a tuple Easy
  16. Error: assigning to a tuple item Easy
  17. Error: append() on a tuple Easy
  18. Error: too many values to unpack Easy
  19. Error: not enough values to unpack Medium
  20. Bug: looping over ("red") prints letters Medium
  21. Error: a list inside a tuple key Medium
  22. Error: adding an int to a tuple Easy
  23. Error: index() of an absent value Easy
  24. Bug: sorted tuple never equals the expected one Medium
  25. Error: += on a list stored in a tuple Hard

Sets 25 questions

  1. Creating an empty set Easy
  2. Properties of a set Easy
  3. Indexing a set Easy
  4. remove() versus discard() Easy
  5. The intersection operator Easy
  6. Symmetric difference Medium
  7. Is set difference commutative? Medium
  8. Which item can be added to a set? Medium
  9. 1, True and 1.0 in a set Hard
  10. Why frozenset? Medium
  11. Why test membership in a set? Medium
  12. Proper subset Medium
  13. union() versus update() Medium
  14. Order of elements in a set Medium
  15. A set comprehension Easy
  16. Error: remove() of a missing element Easy
  17. Error: indexing a set Easy
  18. Error: a list inside a set Medium
  19. Error: {} used as an empty set Medium
  20. Error: adding two sets with + Easy
  21. Bug: unique visits come out in the wrong order Medium
  22. Bug: "Python" and "python" counted twice Easy
  23. Error: removing elements while looping over a set Hard
  24. Bug: union() does not add the new members Medium
  25. Error: pop() from an empty set Medium

Dictionaries 25 questions

  1. What can be a dictionary key? Easy
  2. d[key] versus d.get(key) Easy
  3. What does in test for a dict? Easy
  4. Are dictionaries ordered? Medium
  5. A key written twice Medium
  6. What does popitem() remove? Medium
  7. Are keys() views copies? Hard
  8. What does setdefault() do? Medium
  9. What is defaultdict for? Medium
  10. Which value wins in a merge? Medium
  11. dict.fromkeys() with a list Hard
  12. Counter.most_common() Medium
  13. The key with the largest value Medium
  14. 1 and True as keys Hard
  15. The cost of a dictionary lookup Easy
  16. Error: reading a missing key with [] Easy
  17. Error: a list as a dictionary key Easy
  18. Error: append() on a dictionary Easy
  19. Error: dict() from items of the wrong length Hard
  20. Error: sum() over a dictionary Medium
  21. Bug: searching a value with in Easy
  22. Bug: one student's mark appears for everyone Hard
  23. Bug: every word is counted once Medium
  24. Error: a missing colon in a dict literal Easy
  25. Bug: changing a copy changes the original Medium

Functions 25 questions

  1. A function without return Easy
  2. The type of *args Easy
  3. The type of **kwargs Easy
  4. When are default values evaluated? Medium
  5. Order of default parameters Easy
  6. Parameters after * Medium
  7. Parameters before / Hard
  8. The LEGB rule Medium
  9. Why the global keyword? Medium
  10. What does nonlocal do? Medium
  11. How arguments are passed Medium
  12. Cause of UnboundLocalError Hard
  13. Unpacking in a call Medium
  14. Functions as objects Easy
  15. print versus return Easy
  16. Error: a required argument is missing Easy
  17. Error: a default parameter before a required one Easy
  18. Error: incrementing a global without global Medium
  19. Bug: the square is None Easy
  20. Bug: each order contains the previous orders Hard
  21. Error: an argument given twice Medium
  22. Error: a positional argument after a keyword argument Easy
  23. Error: too many positional arguments Easy
  24. Error: using the result of a function that prints Medium
  25. Error: calling a function before defining it Easy

Recursion 25 questions

  1. The purpose of a base case Easy
  2. Recursion without a base case Easy
  3. Python's recursion limit Easy
  4. Tail-call optimisation Medium
  5. Cost of naive recursive Fibonacci Medium
  6. What does @lru_cache do? Medium
  7. Code after the recursive call Medium
  8. Local variables in recursive calls Medium
  9. Moves for Tower of Hanoi Medium
  10. Recursive binary search Medium
  11. Space used by linear recursion Hard
  12. Mutual recursion Medium
  13. lru_cache and list arguments Hard
  14. Where recursion fits best Easy
  15. The base case of factorial Easy
  16. Error: no base case Easy
  17. Error: a base case that is skipped Medium
  18. Bug: every factorial is 0 Easy
  19. Error: the recursive result is not returned Medium
  20. Bug: the "reversed" string is unchanged Medium
  21. Bug: "abca" is called a palindrome Medium
  22. Error: correct recursion that is too deep Hard
  23. Error: lru_cache with a list argument Hard
  24. Error: a def line without a colon Easy
  25. Error: a base case that does not cover the empty list Hard

Lambda Functions 25 questions

  1. What can a lambda body contain? Easy
  2. return inside a lambda Easy
  3. The name of a lambda Medium
  4. lambda versus def Easy
  5. What does map() return? Medium
  6. What filter() keeps Easy
  7. Where is reduce()? Easy
  8. The late-binding trap Hard
  9. if-else in a lambda Medium
  10. Sorting by two keys Medium
  11. Passing a function to map Medium
  12. operator.itemgetter Medium
  13. What does functools.partial do? Medium
  14. reduce() on an empty list Hard
  15. Assigning a lambda to a name Medium
  16. Error: return inside a lambda Easy
  17. Error: an assignment in a lambda Medium
  18. Error: calling a lambda with too few arguments Easy
  19. Bug: every handler reports the last item Hard
  20. Bug: the total of the prices is 0 Medium
  21. Error: a key that returns None for some items Hard
  22. Bug: zeros dropped and negatives kept Medium
  23. Error: reduce() of an empty list Medium
  24. Bug: numeric strings sort in the wrong order Easy
  25. Error: passing a call result instead of a function Medium

List Comprehensions 25 questions

  1. What does a list comprehension produce? Easy
  2. Where does a filter go? Easy
  3. Where does if-else go? Medium
  4. Order of several for clauses Medium
  5. Flattening a matrix Medium
  6. Round brackets around a comprehension Easy
  7. Iterating a generator twice Medium
  8. Does the loop variable leak? Medium
  9. A dict comprehension Easy
  10. Why use a generator in sum()? Medium
  11. Two if clauses in a row Hard
  12. Comprehensions for side effects Medium
  13. len() of a generator Medium
  14. A safe 2-D grid Medium
  15. A set comprehension Easy
  16. Error: else in the filter position Medium
  17. Error: a conditional expression without else Medium
  18. Error: using the loop variable after the comprehension Medium
  19. Error: for clauses in the wrong order Hard
  20. Bug: the second count is 0 Medium
  21. Error: len() of a generator expression Medium
  22. Bug: a comprehension used only to print Medium
  23. Bug: negatives removed instead of replaced Easy
  24. Error: converting bad data inside a comprehension Easy
  25. Bug: words of equal length overwrite each other Medium

Modules and Packages 25 questions

  1. What is a module? Easy
  2. import x versus from x import y Easy
  3. Importing a module twice Medium
  4. What is sys.path? Medium
  5. The value of __name__ Easy
  6. The role of __init__.py Medium
  7. Where relative imports work Hard
  8. What does __all__ control? Medium
  9. Why avoid import *? Medium
  10. A file named random.py Medium
  11. Re-running a module Medium
  12. Why use a virtual environment? Easy
  13. ModuleNotFoundError versus ImportError Hard
  14. Using an import alias Easy
  15. What is requirements.txt for? Easy
  16. Error: a misspelt module name Easy
  17. Error: importing a name the module does not have Easy
  18. Error: calling a function without the module prefix Easy
  19. Error: a function the module does not have Easy
  20. Error: a variable that replaces a module Medium
  21. Error: from os import * replaces open() Hard
  22. Error: import math.sqrt Medium
  23. Error: a relative import in a script Hard
  24. Bug: test output appears when the module is imported Medium
  25. Bug: the edited setting is not picked up Hard

Exception Handling 25 questions

  1. When does the else of a try run? Easy
  2. When does finally run? Easy
  3. Which except clause runs? Medium
  4. Catching several types in one clause Easy
  5. The exception raised by int("abc") Easy
  6. Why avoid a bare except? Medium
  7. Base class for custom exceptions Easy
  8. raise with no arguments Medium
  9. What does raise … from do? Hard
  10. Is KeyboardInterrupt an Exception? Hard
  11. Catching a syntax error Medium
  12. When to use assert Medium
  13. What is EAFP? Medium
  14. The name bound by except … as e Hard
  15. raise with a string Easy
  16. Error: catching the wrong exception type Easy
  17. Error: a try with neither except nor finally Easy
  18. Error: else placed before except Medium
  19. Bug: a valid number is reported as invalid Medium
  20. Bug: the specific message never appears Medium
  21. Error: raising a string Easy
  22. Error: a misspelt exception name in except Hard
  23. Bug: money disappears on a failed transfer Hard
  24. Error: using a value that was never assigned Medium
  25. Error: re-raising when nothing is being handled Hard

File Handling 25 questions

  1. Opening an existing file with "w" Easy
  2. The append mode Easy
  3. The "x" mode Medium
  4. Why use with? Easy
  5. What readline() returns Medium
  6. What readlines() returns Easy
  7. Does write() add a newline? Easy
  8. The return value of write() Medium
  9. Reading a huge file Medium
  10. Reading a file a second time Medium
  11. What binary mode returns Medium
  12. Opening a missing file for reading Easy
  13. Characters versus bytes Hard
  14. Types read from a CSV file Medium
  15. "r+" versus "w+" Hard
  16. Error: reading a file that does not exist Easy
  17. Error: writing to a file opened for reading Easy
  18. Error: reading after the with block Medium
  19. Error: writing a number to a text file Easy
  20. Error: writing text to a binary file Medium
  21. Bug: the log keeps only the last entry Easy
  22. Bug: all names end up on one line Easy
  23. Bug: the second count is 0 Medium
  24. Error: "x" mode on an existing file Medium
  25. Bug: a valid user is denied Medium

OOP in Python 25 questions

  1. What is self? Easy
  2. The role of __init__ Easy
  3. Class attributes Easy
  4. Assigning a class attribute through an instance Medium
  5. __str__ versus __repr__ Medium
  6. == without __eq__ Medium
  7. Double underscore attributes Hard
  8. A single leading underscore Easy
  9. What does @property give you? Medium
  10. The first argument of a classmethod Medium
  11. What is a staticmethod? Medium
  12. A list as a class attribute Hard
  13. What @dataclass generates Medium
  14. A method defined without self Easy
  15. The pillars of OOP Easy
  16. Error: a method without self Easy
  17. Error: creating an object without a required argument Easy
  18. Error: an attribute name typo Easy
  19. Error: an attribute used without self. Medium
  20. Bug: every cart shows the same items Medium
  21. Error: assigning to a read-only property Medium
  22. Error: _init_ instead of __init__ Hard
  23. Error: a class header without a colon Easy
  24. Error: __str__ that prints instead of returning Medium
  25. Bug: two identical points are "different" Medium

Inheritance and Polymorphism 25 questions

  1. Inheriting from a class Easy
  2. What does super() do? Easy
  3. Method overriding Easy
  4. A parent method calling an overridden method Medium
  5. What is the MRO? Medium
  6. The MRO of a diamond Hard
  7. Instantiating an abstract class Medium
  8. Duck typing Medium
  9. isinstance with subclasses Easy
  10. Method overloading in Python Medium
  11. Overloading + Easy
  12. Why __radd__? Hard
  13. Returning NotImplemented Hard
  14. Forgetting super().__init__() Medium
  15. Inheritance or composition? Medium
  16. Error: creating an object of an abstract class Easy
  17. Error: parent attributes never initialised Medium
  18. Error: super().__init__() without the required argument Medium
  19. Error: an impossible method resolution order Hard
  20. Bug: the parent method runs instead of the override Easy
  21. Bug: every manager is labelled an employee Medium
  22. Error: + on objects without __add__ Easy
  23. Error: sum() of objects with only __add__ Hard
  24. Bug: the shared base is initialised twice Hard
  25. Error: an override that calls itself Medium

Iterators and Generators 25 questions

  1. Iterable versus iterator Easy
  2. What signals the end of iteration? Easy
  3. next() with a default Easy
  4. What makes a generator function? Easy
  5. Calling a generator function Medium
  6. yield versus return Easy
  7. Why generators save memory Medium
  8. Reusing a generator Medium
  9. Methods of an iterator class Medium
  10. What does yield from do? Medium
  11. A return value in a generator Hard
  12. send() on a fresh generator Hard
  13. StopIteration inside a generator Hard
  14. Taking items from an infinite generator Medium
  15. Is range an iterator? Medium
  16. Error: next() after the last item Easy
  17. Error: next() on a list Easy
  18. Error: __iter__ that returns a list Hard
  19. Bug: the second report is empty Medium
  20. Bug: only the first square is produced Easy
  21. Error: indexing a generator Medium
  22. Bug: the custom range works only once Hard
  23. Error: StopIteration leaking out of a generator Hard
  24. Error: sending a value to a generator that has not started Hard
  25. Bug: prices use the new rate instead of the old one Hard

Decorators 25 questions

  1. What does @deco mean? Easy
  2. What is a decorator? Easy
  3. Why *args and **kwargs in a wrapper? Medium
  4. functools.wraps Medium
  5. When does the decorator itself run? Medium
  6. A decorator that takes arguments Hard
  7. The order of stacked decorators Medium
  8. A decorator that forgets return wrapper Medium
  9. Closures and decorators Medium
  10. Class-based decorators Medium
  11. Built-in decorators Easy
  12. A wrapper that does not return Easy
  13. Reaching the original function Hard
  14. Updating a counter in a wrapper Hard
  15. Typical uses of decorators Easy
  16. Error: the decorator does not return the wrapper Easy
  17. Error: a wrapper that accepts no arguments Easy
  18. Bug: the decorated function returns None Easy
  19. Error: @repeat used without its argument Hard
  20. Error: a plain decorator used with brackets Medium
  21. Bug: help text and name are lost Medium
  22. Bug: price formatted before the discount is applied Hard
  23. Error: a decorator not followed by a def Medium
  24. Error: updating a closure counter without nonlocal Hard
  25. Bug: a cache that ignores the second argument Hard

Regular Expressions 25 questions

  1. match() versus search() Easy
  2. When to use fullmatch() Medium
  3. Why raw strings for patterns? Medium
  4. The result of a failed search Easy
  5. What findall returns Easy
  6. What \w matches Easy
  7. Greedy versus lazy Medium
  8. ^ and $ Easy
  9. The word boundary \b Medium
  10. findall and groups Hard
  11. Backreferences in re.sub Medium
  12. Matching a literal dot Easy
  13. What is a lookahead? Hard
  14. Case-insensitive matching Easy
  15. A non-capturing group Hard
  16. Error: calling group() when nothing matched Easy
  17. Error: an unbalanced parenthesis in the pattern Medium
  18. Bug: \b without a raw string Hard
  19. Bug: no amount found in the sentence Easy
  20. Bug: one quoted word captures too much Medium
  21. Bug: a fake domain passes the check Medium
  22. Bug: only the domain endings are returned Hard
  23. Bug: a 7-digit PIN is accepted Medium
  24. Error: a number as the replacement Medium
  25. Error: searching inside a number Easy

Python Built-in Functions 25 questions

  1. round(2.5) Medium
  2. What sorted() returns Easy
  3. max() with a key Easy
  4. max() of an empty list Medium
  5. The start value of sum() Medium
  6. any() and all() on empty input Medium
  7. zip() and different lengths Easy
  8. What reversed() returns Medium
  9. divmod() with a negative number Hard
  10. pow() with three arguments Medium
  11. isinstance with several types Easy
  12. getattr() with a default Medium
  13. enumerate() with start Easy
  14. Why is eval() dangerous? Medium
  15. Naming a variable sum Medium
  16. Error: max() of an empty list Easy
  17. Error: sum() of strings Easy
  18. Error: a variable named list Medium
  19. Bug: 2.675 rounds to 2.67 Hard
  20. Error: zip(strict=True) with unequal lengths Medium
  21. Bug: ₹99.99 becomes ₹99 Easy
  22. Error: len() of a number Easy
  23. Bug: the "largest" score is 9 Medium
  24. Error: chr() with an invalid code point Medium
  25. Error: getattr() without a default Medium

Tricky Python Output Questions 20 questions

  1. Does assignment copy a list? Easy
  2. When are default arguments evaluated? Medium
  3. Late binding in closures Hard
  4. Rounding .5 values Medium
  5. // versus int() Medium
  6. What and/or return Medium
  7. The value of nums.sort() Easy
  8. 1, 1.0 and True as keys Hard
  9. Truthiness versus equality Medium
  10. Iterating a generator twice Medium
  11. Error: reading a variable before a local assignment Medium
  12. Error: a list as a dictionary key Easy
  13. Error: adding keys while iterating Medium
  14. Bug: every student gets the previous student's subjects Medium
  15. Bug: one negative number survives Medium
  16. Error: changing a tuple item Easy
  17. Error: using the result of sort() Medium
  18. Bug: editing a copy changes the original board Hard
  19. Error: __str__ that formats self Hard
  20. Error: calling a method through the class Medium

Python Coding Interview Questions 20 questions

  1. Average cost of a dict lookup Easy
  2. Removing from the front of a list Medium
  3. What kind of heap is heapq? Easy
  4. Complexity of sorted() Easy
  5. Requirement for binary search Easy
  6. Recognising a sliding window problem Medium
  7. Shortest path in an unweighted grid Medium
  8. Optimal two sum Medium
  9. Recognising dynamic programming Medium
  10. Space used by recursion Hard
  11. Error: hi starts one past the end Medium
  12. Bug: maximum subarray of negatives is 0 Medium
  13. Bug: one element used twice Medium
  14. Error: popping from an empty stack Easy
  15. Bug: "top 3 scores" are the lowest Medium
  16. Bug: "most frequent" sorted alphabetically Easy
  17. Error: counting with d[k] += 1 Easy
  18. Bug: reversing a linked list loses nodes Hard
  19. Error: heap entries that cannot be compared Hard
  20. Bug: intervals merged without sorting Medium

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links