
Return multiple values from a function in python
Python can return multiple values at a time. See below for a simple example. def multipleValueFunc(): z = 11 b = 22 return z, b j,k = multipleValueFunc () print(j, k)
Python can return multiple values at a time. See below for a simple example. def multipleValueFunc(): z = 11 b = 22 return z, b j,k = multipleValueFunc () print(j, k)
Use the rstrip method to return the string with all occurrences of the trailing characters removed. For e.g. inputString = “devxyyy”inputString.rstrip(???y???) gives ???devx???
Its pretty ease to reverse a string in Python. ???Devx Jan???[::-1] gives ???naJ xveD???
To avoid null exceptions, we usually validate against null and emptiness as shown: if(object != null && !object.equals(“”)) {} We can simplify this as below: if(!””.equals(object)){}
MySQL has various ways to search for or lookup a given string. One such powerful mechanism is by using FIND_IN_SET. This function enables a lookup for a given string in a set (probably comma separated ones). Example: CREATE TABLE ‘CITIES’ (‘ID’ INT(11) NOT NULL AUTO_INCREMENT,’CITY’ VARCHAR(25) NOT NULL,’COUNTRY’ VARCHAR(25) NOT
Get all the tables with a count of their records with the following query: CREATE TABLE #Temp ( TableName VARCHAR(MAX), Rows INT ); EXEC sp_MSForEachTable @command1 = ‘INSERT INTO #Temp(TableName, Rows) SELECT ”?”, COUNT(*) FROM ?’ SELECT * FROM #Temp ORDER BY Temp.Rows DESC; DROP TABLE #Temp;
For better readability, C# provides a way to shorten the namespaces with an alias. Please see below for an example: using ExcelInterop = Microsoft.Office.Interop.Excel;var excelInteropApplication = new ExcelInterop.Application();
The following code shows you how to compute the n Fibonacci number recursively: int fibonacci(int k) { if (k return k; } return fibonacci(k – 2) + fibonacci(k – 1);}
We use a lot of ng-templates in our HTML and have cases where we would need to swap one with another based on a condition. ngSwitch comes handy in this case. Please see below for an example. ………