sleep(): A pre-defined method belongs to “time” module. Sleep() method is used to stop the current thread execution for specified number of seconds. The following example explains clearly about sleep() method. When multiple threads are …
Multi threaded application: Define a Custom thread and execute along with Default thread. Every Custom thread inherits the functionality from “Thread” class. “Thread” class is belongs to “threading” module. We must define thread logic by …
Life cycle of Thread: Every thread executes according to Life cycle. Life cycle consists Creation phase by programmer Execution phase by scheduler(OS) As a programmer, we need to define and start the thread. All threads …
Single threaded application: Every python program is single threaded. In single threaded application, execution starts at main() and ends at same. Main() thread is called default thread.
Multi-tasking: Performing more than one task parallel is called Multi tasking. In computer, every task execute by the processor. When we perform multi tasking, the process space will be shared among the tasks. One processor …
Exceptions in Banking application: Runtime error is called Exception. When we perform the transaction, in case of any error in the middle of transaction called “Runtime error”. We must define every error as Exception. The …
raise: It is a keyword. It is used to raise Custom Exception explicitly by the programmer. Pre-defined exceptions will be raised automatically when problem occurs. If we don’t handle the exception, Default Exception Handler handles. …
Custom Exceptions: Python library is providing number of exception classes. As a programmer, we can define custom exceptions depends on application requirement. Every custom exception should extends the functionality of pre-defined Exception class.
Open and Close the File using Finally block: open() is pre-defined and it is used to open the file in specified path. If the file is not present, it raises Exception. When we connect any …
Finally block: “finally” is a keyword. “finally” block is used to provide “Resource releasing logic”. All resources (connected to program) must be closed from finally block. Note: Finally block executes whether or not an exception …