How to split a string in Python

Pradeep Elance
Published on 25-Aug-2019 06:07:16
Manytimes we need to split a given string into multiple parts based on some delimiter. Python provides a function named split() which can be used to achieve this. It also provides a way to control the delimiter and number of characters to be considered as delimiter.ExampleIn the below example we ... Read More

MySQL to Implementing OR operator in a WHERE clause?

AmitDiwan
Published on 25-Aug-2019 06:07:16
The OR operator gives true result when any one operand is true. Let us now see an example and create a table −mysql> create table DemoTable663(ClientId int, ClientName varchar(100), ClientAge int); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable663 ... Read More

Display only the default values set for columns in MySQL

AmitDiwan
Published on 25-Aug-2019 06:07:16
Let us first create a table and set default values −mysql> create table DemoTable803(UserId int DEFAULT 101, UserName varchar(100) DEFAULT 'Chris'); Query OK, 0 rows affected (1.18 sec)Insert some records in the table using insert command. For the values we are not inserting, the default values will get set automatically ... Read More

Help function in Python

Pradeep Elance
Published on 25-Aug-2019 06:07:16
Many times we need to look into the python documentation for some help on functions, modules etc. Python provides a help function that gives us this needed results.SyntaxHelp(‘term’) Where term is the word on which we want the help.ExampleIn the below example we seek to find help on the word ... Read More

How to extract from datetime column in MySQL by comparing only date and ignoring whitespace?

AmitDiwan
Published on 25-Aug-2019 06:07:16
To extract from datetime column, you can use date() along with trim(). Here, trim() is used to remove whitespace while comparing. Let us first create a table −mysql> create table DemoTable661(Duedate datetime); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Filter in Python

Pradeep Elance
Published on 25-Aug-2019 06:07:16
We sometimes arrive at a situation where we have two lists and we want to check whether each item from the smaller list is present in the bigger list or not. In such case we use the filter() function as discussed below.SyntaxFilter(function_name, sequence name)Here Function_name is the name of the ... Read More

Is there a way to subtract number of days from a date in MySQL?

AmitDiwan
Published on 25-Aug-2019 06:07:16
Yes, you can use date_sub() to subtract number of days from a date. Following is the syntax −select date_sub(yourColumnName, Interval yourAmountOfDays day) from yourTableName;Let us first create a table −mysql> create table DemoTable660(AdmissionDate datetime); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> ... Read More

factorial() in Python

Pradeep Elance
Published on 25-Aug-2019 06:07:16
Finding the factorial of a number is a frequent requirement in data analysis and other mathematical analysis involving python. The factorial is always found for a positive integer by multiplying all the integers starting from 1 till the given number. There can be three approaches to find this as shown ... Read More

Mathematical Logical Terms and Definitions

Mahesh Parahar
Published on 25-Aug-2019 06:07:16
TautologiesA Tautology is a formula which is always true for every value of its propositional variables.Example − Prove [ (A → B) ∧ A ] → B is a tautologyThe truth table is as follows −ABA → B(A → B) ∧ A[ (A → B) ∧ A ] → BTrueTrueTrueTrueTrueTrueFalseFalseFalseTrueFalseTrueTrueFalseTrueFalseFalseTrueFalseTrueAs ... Read More

Execute a String of Code in Python

Pradeep Elance
Published on 25-Aug-2019 06:07:16
There are times when you need the entire block of code as a string and want this code to execute as part of a bigger python program. IN this article we will see how we can pass code as a string to a variable and then use that variable in ... Read More
Advertisements