



























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This certification develops Python programming skills including data structures, scripting, automation, and application development. It is regulated by BeingCert. The exam evaluates coding proficiency and software development capability.
Typology: Exams
1 / 67
This page cannot be seen from the preview
Don't miss anything!




























































Question 1. Which of the following statements about the Python interpreter is correct? A) Python code is compiled to machine code before execution. B) Python is a purely functional language. C) Python source files are executed line-by-line by an interpreter. D) Python requires a separate compilation step for each module. Answer: C Explanation: The standard CPython implementation reads source code, compiles it to bytecode, and then executes it line-by-line, making Python an interpreted language. Question 2. What is the result of the expression 5 // 2 in Python? A) 2. B) 2 C) 3 D) 2. Answer: B Explanation: The // operator performs floor division, returning the integer quotient without the remainder. Question 3. Which of the following is a valid variable name in Python? A) 2nd_place B) _totalScore C) total-score D) class Answer: B
Explanation: Variable names may start with a letter or underscore; _totalScore follows this rule, while the others either start with a digit, contain a hyphen, or clash with a keyword. Question 4. In Python, what does the input() function return? A) An integer B) A float C) A string D) A list of characters Answer: C Explanation: input() always returns the entered data as a string; conversion is needed for other types. Question 5. Which operator tests whether two objects are the exact same instance? A) == B) = C) is D) != Answer: C Explanation: The is operator checks identity, i.e., whether both operands refer to the same object in memory. **Question 6. What will be printed by the following code?
x = 10 y = 3 ## Developer Ultimate Exam Explanation: Slicing is inclusive of the start index and exclusive of the stop index; indices 1-3 are returned. **Question 9. Which of the following creates an immutable sequence?** A) `list([1, 2, 3])` B) `(1, 2, 3)` C) `{1, 2, 3}` D) `dict(a=1, b=2)` Answer: B Explanation: Tuples, denoted by parentheses, are immutable; lists, sets, and dictionaries are mutable. **Question 10. What is the output of the code below? ```python a, b = (5, 10) a, b = b, a print(a, b) ```** A) `5 10` B) `10 5` C) `(5, 10) (5, 10)` D) `SyntaxError` Answer: B Explanation: Tuple unpacking allows simultaneous swapping of values; after the second line `a` becomes 10 and `b` becomes 5. ## Developer Ultimate Exam **Question 11. Which method adds a key-value pair to a dictionary only if the key does not already exist?** A) `dict.update()` B) `dict.setdefault()` C) `dict.add()` D) `dict.append()` Answer: B Explanation: `setdefault(key, default)` inserts the default value when the key is missing and returns the existing value otherwise. **Question 12. What does the expression `{1, 2, 3} & {2, 3, 4}` evaluate to? ** A) `{1, 2, 3, 4}` B) `{2, 3}` C) `{1, 4}` D) `{}` Answer: B Explanation: The `&` operator on sets returns their intersection, i.e., elements common to both sets. **Question 13. Which of the following statements about Python classes is FALSE?** A) The `__init__` method is automatically called when an instance is created. B) Class attributes are shared by all instances unless overridden. C) Private attributes are enforced by the interpreter and cannot be accessed. D) Methods defined inside a class receive the instance as the first argument. Answer: C ## Developer Ultimate Exam D) Using the `@override` decorator. Answer: B Explanation: Overriding replaces the superclass version of a method with a new one in the subclass. **Question 17. Which of the following is a correct way to declare an abstract base class in Python?** A) `class MyABC: pass` B) `from abc import ABC, abstractmethod` then `class MyABC(ABC):` with an `@abstractmethod` method. C) `class MyABC(abstract):` D) `abstract class MyABC:` Answer: B Explanation: The `abc` module provides `ABC` as a base class and the `@abstractmethod` decorator to define abstract methods. **Question 18. What will be printed by the following code? ```python class Counter: count = 0 def __init__(self): Counter.count += 1 c1 = Counter() c2 = Counter() print(Counter.count) ```** ## Developer Ultimate Exam ## A) 0 ## B) 1 ## C) 2 ## D) 3 Answer: C Explanation: `count` is a class attribute; each instantiation increments the shared value, resulting in 2 after two objects are created. **Question 19. Which statement correctly describes the difference between `*args` and `**kwargs` in a function definition?** A) `*args` collects positional arguments into a tuple; `**kwargs` collects keyword arguments into a dictionary. B) `*args` collects keyword arguments; `**kwargs` collects positional arguments. C) Both collect positional arguments but in different orders. D) They are interchangeable. Answer: A Explanation: `*args` gathers any extra positional arguments, while `**kwargs` gathers extra named arguments. **Question 20. What is the output of the following recursive function call? ```python def recurse(n): if n == 0: return 0 return n + recurse(n-1) ## Developer Ultimate Exam Explanation: `yield` pauses the function, saves its state, and produces a value each time the generator is iterated. **Question 23. Which built-in function can be used to convert an iterable into a list?** A) `list()` B) `tuple()` C) `set()` D) `dict()` Answer: A Explanation: `list(iterable)` creates a list containing the elements of the given iterable. **Question 24. Which statement correctly imports the `randint` function from the `random` module?** A) `import random.randint` B) `from random import randint` C) `import randint from random` D) `include random.randint` Answer: B Explanation: The `from … import …` syntax imports a specific name from a module. **Question 25. What is the purpose of the `if __name__ == "__main__":` block in a Python script?** A) To define a class named `__main__`. B) To ensure that code inside the block runs only when the script is executed directly, not when imported. ## Developer Ultimate Exam C) To set the interpreter’s working directory. D) To enable multi-threading. Answer: B Explanation: The conditional checks the module’s name; when the file is run as the main program, `__name__` equals `"__main__"`. **Question 26. Which of the following file modes opens a file for reading **and** writing, without truncating it?** A) `'r'` B) `'w'` C) `'a'` D) `'r+'` Answer: D Explanation: `'r+'` opens the file for both reading and writing and does not truncate existing content. **Question 27. Given a file object `f`, what does `f.readlines()` return?** A) A single string containing the whole file. B) A list of strings, each representing a line. C) An iterator over bytes. D) The number of lines in the file. Answer: B Explanation: `readlines()` reads all lines and returns them as a list. **Question 28. Which exception is raised when you try to access a list element with an out-of-range index?** A) `KeyError` ## Developer Ultimate Exam A) All four-character words in `text`. B) All occurrences of the exact string “\b\w{4}\b”. C) The first match only. D) A compiled regular expression object. Answer: A Explanation: `\b` denotes word boundaries, `\w{4}` matches exactly four word characters; `findall` returns all such matches. **Question 32. Which Tkinter widget is used to display a single line of text that the user can edit?** A) `Label` B) `Button` C) `Entry` D) `Canvas` Answer: C Explanation: `Entry` creates a single-line editable text field. **Question 33. In a Tkinter application, which method starts the event-loop? ** A) `mainloop()` B) `run()` C) `execute()` D) `start()` Answer: A Explanation: `root.mainloop()` (or any widget’s `mainloop`) begins processing events. ## Developer Ultimate Exam **Question 34. What does the following code print? ```python import re pattern = re.compile(r'(\\d+)-(\\d+)') m = pattern.search('Order 123-456') print(m.group(2)) ```** A) `123` B) `456` C) `123-456` D) `None` Answer: B Explanation: The second capture group `(\d+)` after the hyphen matches `456`; `group(2)` returns it. **Question 35. Which of the following statements about list comprehensions is TRUE?** A) They can only contain a single `for` clause. B) They evaluate lazily like generators. C) They can include an optional `if` filter. D) They must be written on multiple lines. Answer: C Explanation: List comprehensions may have an optional `if` clause to filter items. **Question 36. What is the output of the following code? ## Developer Ultimate Exam C) Raises `TypeError` D) `None` Answer: B Explanation: Empty sequences are falsy; converting an empty list to `bool` yields `False`. **Question 39. Which of the following statements about the `global` keyword is correct?** A) It creates a new global variable if the name does not exist. B) It allows a function to modify a variable defined at module level. C) It can be used inside a class to affect class attributes. D) It is required for all read-only accesses to global variables. Answer: B Explanation: `global var` tells the interpreter that assignments to `var` refer to the module-level variable. **Question 40. What is the result of `set([1,2,2,3])`?** A) `{1, 2, 2, 3}` B) `{1, 2, 3}` C) `[1, 2, 3]` D) `(1, 2, 3)` Answer: B Explanation: Converting a list to a set removes duplicate elements, yielding `{1, 2, 3}`. **Question 41. Which of the following statements about Python’s garbage collection is FALSE?** A) Reference counting is the primary mechanism. ## Developer Ultimate Exam B) Cyclic references are handled by a generational collector. C) The `gc` module can be used to disable automatic collection. D) Objects are never freed until the interpreter exits. Answer: D Explanation: Objects are deallocated when their reference count drops to zero; the interpreter does not wait until exit. **Question 42. What does the `@staticmethod` decorator do?** A) Makes a method receive the class as the first argument. B) Makes a method receive the instance as the first argument. C) Defines a method that does not receive any implicit first argument. D) Converts a function into a property. Answer: C Explanation: A static method behaves like a regular function placed inside the class namespace; it receives no `self` or `cls`. **Question 43. Which of the following will correctly open a CSV file for reading using the `csv` module?** A) `csv.reader(open('data.csv', 'r'))` B) `csv.open('data.csv')` C) `open('data.csv').csvreader()` D) `csv.read('data.csv')` Answer: A Explanation: `csv.reader` expects an iterable file object; passing `open(..., 'r')` is the proper way. **Question 44. What will be the output of the following code? ## Developer Ultimate Exam Explanation: `enumerate(iterable, start=0)` produces an iterator of (index, element) tuples without altering the source. **Question 46. What is the purpose of the `__repr__` method in a class?** A) To provide a user-friendly string representation for printing. B) To return a string that can be used to recreate the object when passed to `eval()`. C) To hide private attributes. D) To implement operator overloading for addition. Answer: B Explanation: `__repr__` should return an unambiguous representation, ideally one that could be evaluated to produce an equivalent object. **Question 47. Which of the following statements about the `with` statement is TRUE?** A) It can only be used with file objects. B) It ensures that the `__exit__` method of the context manager is called, even if an exception occurs. C) It replaces the need for `try`/`except` blocks entirely. D) It creates a new thread. Answer: B Explanation: The `with` statement guarantees resource cleanup by invoking the context manager’s `__exit__` method. **Question 48. What does the expression `all([True, False, True])` evaluate to?** A) `True` B) `False` ## Developer Ultimate Exam C) `None` D) Raises `TypeError` Answer: B Explanation: `all` returns `True` only if every element is truthy; the presence of `False` makes the result `False`. **Question 49. Which of the following will raise a `KeyError`?** A) `d = {'a':1}; d.get('b')` B) `d = {'a':1}; d['b']` C) `d = {'a':1}; d.setdefault('b', 2)` D) `d = {'a':1}; 'b' in d` Answer: B Explanation: Direct indexing with a missing key raises `KeyError`; `get` returns `None` instead. **Question 50. In the context of the `datetime` module, which class represents a date without a time component?** A) `datetime.time` B) `datetime.datetime` C) `datetime.date` D) `datetime.timedelta` Answer: C Explanation: `datetime.date` stores year, month, and day only. **Question 51. Which function from the `random` module returns a floating-point number N such that `a <= N < b`?** A) `randint(a, b)`