Q221. How To Assign Values For The Class Attributes At Runtime?
We can specify the values for the attributes at runtime. We need to add an init method and pass input to object constructor. See the following example demonstrating this....
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (338 available).
We can specify the values for the attributes at runtime. We need to add an init method and pass input to object constructor. See the following example demonstrating this....
Inheritance is an OOP mechanism which allows an object to access its parent class features. It carries forward the base class functionality to the child. Python Interview...
The composition is also a type of inheritance in Python. It intends to inherit from the base class but a little differently, i.e., by using an instance variable of the ba...
Errors are coding issues in a program which may cause it to exit abnormally. On the contrary, exceptions happen due to the occurrence of an external event which interrupt...
Python lay down Try, Except, Finally constructs to handle errors as well as Exceptions. We enclose the unsafe code indented under the try block. And we can keep our fall-...
We can raise an exception based on some condition. For example, if we want the user to enter only odd numbers, else will raise an exception. # Example - Raise an exceptio...
The collection type like a list, tuple, dictionary, and set are all iterable objects whereas they are also iterable containers which return an iterator while traversing. ...
A Generator is a kind of function which lets us specify a function that acts like an iterator and hence can get used in a "for" loop. In a generator function, the yield k...
Python closures are function objects return ed by another function. We use them to eliminate code redundancy. In the example below, we've written a simple closure for mul...
Python decorator gives us the ability to add new behavior to the given objects dynamically. In the example below, we've written a simple example to display a message pre ...
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.