Skip to main content

Featured

What is Coroutine in Android?

Coroutines are available for the Kotlin language. Coroutines are simply cooperative functions.   Our Android applications often have multiple concurrent and interdependent functionalities. We provide instructions to the system through code, also known as a program, to perform a set of sequential instructions.  During the execution of these instructions, a specific instruction may take longer than expected, causing the next line of code to wait until the previous line of code has completed its execution. This scenario is known as blocking program execution. To avoid blocking program execution, the code must be executed on a separate thread. A thread is a single sequential flow of control. However, creating and handling multiple threads can be difficult and expensive in terms of OS operations and memory usage. To address this issue, we can use Coroutines in Kotlin. Coroutines are cooperative functions that are executed on threads as needed in a cooperative manner. They help manage long-r

Python String Functions

Hello All,

String is very commonly used Data type in any programming language.So In this post we will look after some very useful string functions in python. These functions are very helpful in our day to day life.

Functions :
  1. capitalize()
  2. count()
  3. endswith()
  4. find()
  5. len()
  6. lower()
  7. upper()
  8. lstrip()
  9. rstrip()
  10. strip()
  11. split()
  12. title()

1.capitalize() :
  • This Function is useful when we want to capitalize first character of string and rest charcters will be converted to lowercase. 
  • If string already having first word as capital letter then it will not make any change to it.


2.count(substring,[start_index],[end_index]) :
  • This inbuilt function returns number of time a sub-string occurs in that string.
  • It takes 1 mandatory parameter and 2 optional parameter start-index and end-index.
  • If you want to search between some specific range of string then you can pass this parameter values to function


3.endswith(string) :
  • This function will check if String ending with some specified characters or not. 
  • If it ends with that then returns True otherwise return False.


4.find(string,[start_index],[end_index]) :
  • This function finds the sub-string in original string and returns starting index of first occurrence of that sub-string. 
  • If sub-string not found within that string then it returns -1.
  • You can also provide optional parameters as start-index and end-index if you want to search within a specific range in the string.


5.len() :
  • This function finds length of the string. 




6.lower():
  • This function Converts all uppercase characters to lowercase in given string.
  • If no uppercase characters are there in string it will return original string.




7.upper():
  • This will convert all lowercase characters to uppercase letters in given string. 
  • It return original string if there is no lowercase characters in string.




8.lstrip([chars]):
  • This function removes specified set of characters from left side of given string. 
  • Parameter is optional if no parameters are specified then it will remove white space from left side of string.




9.rstrip([chars]):
  • This function is opposite of lstrip() function as it removes set of characters from right side of given string. 
  • Parameter is optional , if not specified then it will remove white space from right side of string.




10.strip([chars]):
  • This function will remove specified characters from both left and right side of the given string. 
  • If characters are not specified then it will remove white space from the both side.




11.split([separator[,maxsplit]]):
  • This function helps us to break down given string with specified separator. 
  • This function takes 2 parameter. These two are optional parameters.
  • This function return list as result.
  • separator : This is  delimiter. The given string will be spitted by this specified separator. As this is optional parameter , if not specified then separator is space.
  • maxsplit : This parameter specified maximum number of split . Default value of this is -1. Which means there is not limit for number of splits.

12.title():
  • title() function will convert each letter of first word to uppercase. i.e. , all words begins with uppercase and rest are as it is.

Comments

Popular Posts