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> insert into DemoTable660 values('2018-01-24'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable660 values('2019-07-10'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable660 values('2020-11-20'); Query OK, 1 row affected (0.59 sec)Display all records from the table using select statement −mysql> select *from DemoTable660;This will produce the ... Read More
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 below.Using a For LoopWe can use a for loop to iterate through number 1 till the designated number and keep multiplying at each step. In the below program we ask the user to enter the number and convert the input to an integer before using it in the loop. This ... Read More
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 we can see every value of [ (A → B) ∧ A ] → B is "True", it is a tautology.ContradictionsA Contradiction is a formula which is always false for every value of its propositional variables.Example − Prove (A ∨ B) ∧ [ ( ¬ A) ∧ (¬ B) ] ... Read More
To fetch a specific row when values are the same, use GROUP BY. Let us first create a table −mysql> create table DemoTable659(Id int, Name varchar(100), Score int); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable659 values(11, 'John', 45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable659 values(15, 'John', 59); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable659 values(15, 'Sam', 61); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable659;This will produce the ... Read More
A Logical Connective is a symbol which is used to connect two or more propositional or predicate logics in such a manner that resultant logic depends only on the input logics and the meaning of the connective used.Generally there are five connectives which are −OR (∨)AND (∧)Negation/ NOT (¬)Implication / if-then (→)If and only if (⇔).OR (∨) − The OR operation of two propositions A and B (written as A ∨ B) is true if at least any of the propositional variable A or B is true.The truth table is as follows −ABA ∨ BTrueTrueTrueTrueFalseTrueFalseTrueTrueFalseFalseFalseAND (∧) − The AND operation ... Read More
Exec function can dynamically execute code of python programs. The code can be passed in as string or object code to this function. The object code is executed as is while the string is first parsed and checked for any syntax error. If no syntax error, then the parsed string is executed as a python statement.Syntax for exec() Functionexec(object, globals, locals)WhereObject − A string or a code object passed onto the method.globals − A dictionary of available global methods and variables.locals − A dictionary of available local methods and variables.Passing StringIn the below example we pass a single line of ... Read More
A matching graph is a subgraph of a graph where there are no edges adjacent to each other. Simply, there should not be any common vertex between any two edges.MatchingLet 'G' = (V, E) be a graph. A subgraph is called a matching M(G), if each vertex of G is incident with at most one edge in M, i.e., deg(V) ≤ 1 ∀ V ∈ Gwhich means in the matching graph M(G), the vertices should have a degree of 1 or 0, where the edges should be incident from the graph G.Notation − M(G)ExampleIn a matching, if deg(V) = 1, ... Read More
The measurements of angles in mathematics are done using these two units of measurement called degree and radian. They are frequently used in math calculations involving angles and need conversion from one value to another. In python we can achieve these conversions using python functions.degrees() FunctionThis function takes radian value as parameter and return the equivalent value in degrees. The return is a float value.Example Live Demoimport math # Printing degree equivalent of radians. print("1 Radians in Degrees : ", math.degrees(1)) print("20 Radians in Degrees : ", math.degrees(20)) print("180 Radians in Degrees : ", math.degrees(180))OutputRunning the above code gives us the ... Read More
Here, we are converting time value, for example 150:50:10 to days and hours form, i.e. 6 days 6 hours.You can use CONCAT() along with HOUR() for this. Let us first create a table −mysql> create table DemoTable657(DueTime time); Query OK, 0 rows affected (3.68 sec)Insert some records in the table using insert command. Here, we have inserted the records in the form of total hours −mysql> insert into DemoTable657 values('120:30:00'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable657 values('150:50:10'); Query OK, 1 row affected (0.27 sec)Display all records from the table using select statement −mysql> select *from ... Read More
A covering graph is a subgraph which contains either all the vertices or all the edges corresponding to some other graph. A subgraph which contains all the vertices is called a line/edge covering. A subgraph which contains all the edges is called a vertex covering.Line CoveringLet G = (V, E) be a graph. A subset C(E) is called a line covering of G if every vertex of G is incident with at least one edge in C, i.e., deg(V) ≥ 1 ∀ V ∈ Gbecause each vertex is connected with another vertex by an edge. Hence it has a minimum ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP