Some programs are meant to run for indefinite amount of time. They don’t stop by themselves. Operators generally stop then for maintenance. Most common way to stop these types of programs is by pressing Ctr+C if the program is running in foreground or by sending SIGINT signal. Here is a simple Python program that does … Continue reading “Python | Capture Ctr+C (SIGINT)”
Tag: Python
Python | Periodic Task
Doing a periodic task is a basic programming requirement. We need it in time of implementing watchdogs, checking health of some system, sending status periodically, updating database, doing periodic backup etc. Using Loops When it comes to do something periodically, the first that comes to our mind is the ‘loop‘. First we’ll see how we … Continue reading “Python | Periodic Task”
Python | Check Whether a String is Palindrome
Palindrome string is a string that reads same from both directions – forward and backward. For example, the string, ‘ROTOR‘, is a palindrome because it reads same from both forward and backward directions. Whereas ‘MOTOR’ is not a palindrome because it does not read same from both directions. Check Palindrome by Reversing the String For … Continue reading “Python | Check Whether a String is Palindrome”
Python | Find a Substring
We can check whether a substring is present in a string using the Python find() function. If the find() function returns 0 or a positive number, the substring is present. The system of find() function. substring: The substring to be searched. start: Starting index of the range where the substring will be searched. Default value … Continue reading “Python | Find a Substring”
Python | Reverse a String
In Python we can use various methods to reverse a string. Simplest way to reverse a string is to use the slice operation. Output: General syntax of slice operation is string[start:end:step]. In our program start and end are not specified. That means the whole string will be considered. As the step is -1, the string … Continue reading “Python | Reverse a String”