Degrees and Radians in Python

Pradeep Elance
Updated on 23-Aug-2019 12:08:06

794 Views

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

Convert MySQL Time Value to Days and Hours

AmitDiwan
Updated on 23-Aug-2019 11:57:08

819 Views

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

Line Edge Covering

Mahesh Parahar
Updated on 23-Aug-2019 11:54:44

349 Views

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

Counting Frequencies in a List Using Dictionary in Python

Pradeep Elance
Updated on 23-Aug-2019 11:53:22

3K+ Views

In this article we develop a program to calculate the frequency of each element present in a list.Using a dictionaryHere we capture the items as the keys of a dictionary and their frequencies as the values.Example Live Demolist = ['a', 'b', 'a', 'c', 'd', 'c', 'c'] frequency = {} for item in list:    if (item in frequency):       frequency[item] += 1    else:       frequency[item] = 1 for key, value in frequency.items():    print("% s -> % d" % (key, value))OutputRunning the above code gives us the following result −a -> 2 b -> 1 c ... Read More

Kirchhoff's Theorem

Mahesh Parahar
Updated on 23-Aug-2019 11:50:24

3K+ Views

Kirchoff's theorem is useful in finding the number of spanning trees that can be formed from a connected graph.ExampleThe matrix 'A' be filled as, if there is an edge between two vertices, then it should be given as '1', else '0'.

MySQL Stored Procedure Won't Fetch the Whole Table

AmitDiwan
Updated on 23-Aug-2019 11:46:35

180 Views

You can use SELECT *FROM yourTableName in stored procedure. Let us first create a table −mysql> create table DemoTable654 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100) ); Query OK, 0 rows affected (0.70 sec)Insert some records in the table using insert command −mysql> insert into DemoTable654(StudentFirstName) values('John'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable654(StudentFirstName) values('Sam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable654(StudentFirstName) values('Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable654(StudentFirstName) values('Robert'); Query OK, 1 row affected (0.12 sec)Display all records from the table using ... Read More

Isomorphism and Homeomorphism of Graphs

Mahesh Parahar
Updated on 23-Aug-2019 11:44:45

8K+ Views

IsomorphismIf two graphs G and H contain the same number of vertices connected in the same way, they are called isomorphic graphs (denoted by G ≅ H).It is easier to check non-isomorphism than isomorphism. If any of these following conditions occurs, then two graphs are non-isomorphic −The number of connected components are differentVertex-set cardinalities are differentEdge-set cardinalities are differentDegree sequences are differentExampleThe following graphs are isomorphic −HomomorphismA homomorphism from a graph G to a graph H is a mapping (May not be a bijective mapping) h: G → H such that − (x, y) ∈ E(G) → (h(x), h(y)) ∈ ... Read More

chr() Function in Python

Pradeep Elance
Updated on 23-Aug-2019 11:42:08

1K+ Views

This function return the string representing a character whose Unicode code point is the integer supplied as parameter to this function. For example, chr(65) returns the string 'A', while chr(126) returns the string '~'.SyntaxThe syntax of the function is as below.chr(n) where n is an integer valueExampleThe below program shows how the chr() is used. We supply various integer values as parameter and get back the respective characters. Live Demo# Printing the strings from chr() function print(chr(84), chr(85), chr(84), chr(79), chr(82))Running the above code gives us the following result −T U T O RUsing a series of numbersWe can take help ... Read More

Change Order of Items in MySQL

AmitDiwan
Updated on 23-Aug-2019 11:39:37

482 Views

To change order of items in MySQL, use ORDER BY alias name. Let us first create a table −mysql> create table DemoTable653 (Product1Amount int, Product2Amount int); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable653 values(400, 250); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable653 values(500, 300); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable653 values(40, 400); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable653 values(200, 450); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable653 values(50, 20); Query ... Read More

Search Record with Specific Value in MySQL using LIKE or REGEXP

AmitDiwan
Updated on 23-Aug-2019 11:33:17

473 Views

Let us first create a table −mysql> create table DemoTable651 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value varchar(100)); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable651(Value) values('Title'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable651(Value) values('course'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable651(Value) values('subject'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select *from DemoTable651;This will produce the following output −+----+---------+ | Id | Value | +----+---------+ | 1 | ... Read More

Advertisements