Docsity

Python Programming Exam Questions and Answers, Exams of Computer Science

Toggle sidebar
bg1
Python Tutorial exam | 2025| 2026
Latest | rated A+
Self - ✔️✔️✔️✔️Self is a python convention to denote a self reference to the
object/class being instantiated. It's passed in as the first argument explicitly.
__init_method__ - ✔️✔️✔️✔️The __init__() method initializes the attributes of an
object and is called immediately after an object has been newly created
Tuples - ✔️✔️✔️✔️Tuples are static or immutable data types. Tuples are faster and
better performance wise.
Lists - ✔️✔️✔️✔️Lists are mutable.
What's a "Meta Class" - ✔️✔️✔️✔️A metaclass is an instance of a class. A metaclass
is not part of an object's class hierarchy whereas base classes are. So when an object
does "obj.some_method()" it will not search the metaclass for this method however the
metaclass may have created it during the class' or object's creation.
Describe the Map Function - ✔️✔️✔️✔️"A Map is used to..." Apply function to every
item of iterable and return a list of the results. [...] The iterable arguments may be a
sequence or any iterable object; the result is always a list.
__new__ - ✔️✔️✔️✔️Static Method that is called to create an instance of the class
__del__ - ✔️✔️✔️✔️The __del__() method is invoked when an object is about to be
destroyed.This method is invoked only when an object is no longer in use.
__str__ - ✔️✔️✔️✔️The __str__() method is called by the built-in str() function and by
the print statement. It differs from __repr__() in that the string it returns can be more
concise and informative to the user. If this method is undefined, the __repr__() method
is invoked.
The Attribute Operator (.) - ✔️✔️✔️✔️The dot (.) operator is used to access the
attributes of an object.
What's a "Generator?" - ✔️✔️✔️✔️A generator is a function that produces values for
use in iteration.
1
pf2

Partial preview of the text

Download Python Programming Exam Questions and Answers and more Exams Computer Science in PDF only on Docsity!

Python Tutorial exam | 2025| 2026

Latest | rated A+

Self - ✔️ ✔️ ✔️ ✔️ Self is a python convention to denote a self reference to the object/class being instantiated. It's passed in as the first argument explicitly. init_method - ✔️ ✔️ ✔️ ✔️ The init() method initializes the attributes of an object and is called immediately after an object has been newly created Tuples - ✔️ ✔️ ✔️ ✔️ Tuples are static or immutable data types. Tuples are faster and better performance wise. Lists - ✔️ ✔️ ✔️ ✔️ Lists are mutable. What's a "Meta Class" - ✔️ ✔️ ✔️ ✔️ A metaclass is an instance of a class. A metaclass is not part of an object's class hierarchy whereas base classes are. So when an object does "obj.some_method()" it will not search the metaclass for this method however the metaclass may have created it during the class' or object's creation. Describe the Map Function - ✔️ ✔️ ✔️ ✔️ "A Map is used to..." Apply function to every item of iterable and return a list of the results. [...] The iterable arguments may be a sequence or any iterable object; the result is always a list. new - ✔️ ✔️ ✔️ ✔️ Static Method that is called to create an instance of the class del - ✔️ ✔️ ✔️ ✔️ The del() method is invoked when an object is about to be destroyed.This method is invoked only when an object is no longer in use. str - ✔️ ✔️ ✔️ ✔️ The str() method is called by the built-in str() function and by the print statement. It differs from repr() in that the string it returns can be more concise and informative to the user. If this method is undefined, the repr() method is invoked. The Attribute Operator (.) - ✔️ ✔️ ✔️ ✔️ The dot (.) operator is used to access the attributes of an object. What's a "Generator?" - ✔️ ✔️ ✔️ ✔️ A generator is a function that produces values for use in iteration.

How do you create a package? - ✔️ ✔️ ✔️ ✔️ A package is defined by creating a directory with the same name as the package and creating the file init.py in that directory. How do you write a function that accepts any # of arguments? - ✔️ ✔️ ✔️ ✔️ Use a * argument What are decorators? - ✔️ ✔️ ✔️ ✔️ By definition, decorator is a function that takes another function and extends the functionality of the latter without explicitly modifying it. Explain the Unit Testing Process - ✔️ ✔️ ✔️ ✔️ 1. Instantiates the MainTest Class to get a MainTest object.

  1. It runs the test method inside the try and accept block.
  2. If an assertion error is raised (failed assertion) then it records a failed test.
  3. Otherwise it records a success test. What's a List Comprehension - ✔️ ✔️ ✔️ ✔️ What's Dependency Injection - ✔️ ✔️ ✔️ ✔️ Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies.