code-rag-bench/online-tutorials huggingface dataset:
Display records with more than two occurrences in MySQL?

For this, you can use GROUP BY HAVING clause. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> Subject varchar(100)
   -> );
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(Subject) values('MySQL');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable(Subject) values('MongoDB');
Query OK, 1 row affected (0.09 sec)

mysql> insert into DemoTable(Subject) values('MySQL');
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable(Subject) values('Java');
Query OK, 1 row affected (0.56 sec)

mysql> insert into DemoTable(Subject) values('SQL Server');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable(Subject) values('MongoDB');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable(Subject) values('MySQL');
Query OK, 1 row affected (0.48 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+----+------------+
| Id | Subject    |
+----+------------+
| 1  | MySQL      |
| 2  | MongoDB    |
| 3  | MySQL      |
| 4  | Java       |
| 5  | SQL Server |
| 6  | MongoDB    |
| 7  | MySQL      |
+----+------------+
7 rows in set (0.00 sec)
Following is the query to display distinct records with more than 2 occurrences in MySQL.
mysql> select Subject,count(Subject) freq from DemoTable
   -> group by Subject
   -> having count(Subject) > 2;
+---------+------+
| Subject | freq |
+---------+------+
| MySQL   | 3    |
+---------+------+
1 row in set (0.00 sec)
How to convert a string into uppercase in AngularJS?

Sometimes we may need to represent a name or a string in capital letters. To convert a string into uppercase in AngularJS, we can use the uppercase filter to change its case to uppercase.
In HTML Template Binding
{{uppercase_expression | uppercase}}
In JavaScript
$filter('uppercase')()
Create a file "uppercase.html" in your Angular project directory and copy-paste the following code snippet.
<!DOCTYPE html>
<html>

<head>
   <title>uppercase Filter</title>
   <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
</head>


<body ng-app="app"
   style="text-align:Center">
   <h1 style="color:green">
      Welcome to Tutorials Point
   </h1>
   <h2 style="color: grey;">
      AngularJS | UpperCase Filter
   </h2>
   <div ng-controller="example">
      <p>
         <h2>
            Original: {{message}}
         </h2>
         <h2>
            Modified: {{message | uppercase}}
         </h2>
      <p>
   </div>
   <script>
      angular.module('app', [])
         .controller('example',['$scope', function($scope) {
         $scope.message = 'simply learning';
      }]);
   </script>
</body>
</html>
To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.
How to change the color of the placeholder attribute with CSS?

To change the color of the placeholder attribute with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      padding: 20px;
   }
   input {
      font-size: 40px;
      font-weight: bold;
   }
   ::placeholder {
      color: rgb(70, 53, 167);
   }
   :-ms-input-placeholder {
      color: rgb(66, 51, 155);
   }
   ::-ms-input-placeholder {
      color: rgb(122, 69, 182);
   }
</style>
</head>
<body>
<h1>Placeholder color change example</h1>
<input type="text" placeholder="Some placeholder text" />
</body>
</html>
The above code will produce the following output −
Plot scatter points on polar axis in Matplotlib

To plot scatter points on polar axis in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Initialize a variable, N, for number of sample data.
Get r, theta, area and color data using numpy
Create a new figure or activate an existing figure.
Plot theta, r, colors and area, using scatter() method.
To display the figure, use show() method.
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2
colors = theta

fig = plt.figure()
ax = fig.add_subplot(projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

plt.show()
How to limit maximum items on multiple input (<input type=“file” multiple />)?

To allow multiple file uploads in HTML forms, use the multiple attributes. The multiple attributes work with email and file input types.
For limiting maximum items on multiple inputs, use JavaScript. Through this, limit the number of files to be uploaded. For example, let’s say only 2 files to be uploaded at once.
You can try to run the following code to learn how to use multiple attributes in HTML. With that, we will limit the number of files uploaded using JavaScript.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML file upload</title>
   </head>
   <body>
      <form>
         <input type="file"  action="/action_page.php"  name="name" multiple><br/>
         Upload multiple files, and click Submit.<br>
         <input type = "submit" value = "submit">
      </form>
      <script>
         $(function(){
            $("input[type = 'submit']").click(function(){
               var $fileUpload = $("input[type='file']");
               if (parseInt($fileUpload.get(0).files.length) > 3){
                  alert("You are only allowed to upload a maximum of 3 files");
               }
            });
         });
      </script>
   </body>
</html>
JavaScript Array Ranking - JavaScript

Suppose, we have three JavaScript arrays of Number like these −
const array1 = [10,23,53,74,33,56,6,0,43,45,11];
const array2 = [52,46,27,28,4,11,53,6,75,75,22];
const array3 = [26,18,10,12,31,12,5,8,44,34,65];
The length of all the arrays will always be the same.
We are required to write a JavaScript function that in any number of such arrays maps the corresponding elements of an existing array according to their rank (i.e., their order in decreasing sense).
Therefore, for the above arrays, the output should look like −
const array1= [3,2,1,1,1,1,2,3,2,2,3];
const array2= [1,1,2,2,2,2,1,2,1,1,2];
const array3= [2,3,3,3,3,3,3,1,2,3,1];
Following is the code −
const array1 = [10,23,53,74,33,56,6,0,43,45,11];
const array2 = [52,46,27,28,4,11,53,6,75,75,22];
const array3 = [26,18,10,12,31,12,5,8,44,34,65];
const transpose = (rank, arr) => {
   return arr.map((el, ind) => {
      return [...(rank[ind] || []), el];
   });
};
const ranks = arr => {
   return arr.map(
      Map.prototype.get,
      [...arr]
      .sort((a, b) => b - a)
      .reduce((r => (m, v) => m.set(v, (r++, m.get(v)) || r))(0), new Map)
   );
};
const findRanks = (...arrs) => {
   return arrs
   .reduce(transpose, [])
   .map(ranks)
   .reduce(transpose, []);
};
console.log(findRanks(array1, array2, array3));
This will produce the following output on console −
[
 [
   3, 2, 1, 1, 1,
   1, 2, 3, 3, 2,
   3
 ],
 [
   1, 1, 2, 2, 3,
   3, 1, 2, 1, 1,
   2
 ],
 [
   2, 3, 3, 3, 2,
   2, 3, 1, 2, 3,
   1
 ]
]
How to prevent text in a table cell from wrapping using CSS? - GeeksforGeeks

26 Feb, 2019
Given a table which contains the table head and body section. The task is to prevent the text in a table cell from wrapping using CSS. To achieve this we use white-space property of CSS. This property forces the contents of th to display in one line. There are many property values exists to the white-space function.
Syntax:
white-space: normal|nowrap|pre|pre-wrap|pre-line;
Example 1: This example uses white-space property to prevent cell wrapping using CSS.
<!DOCTYPE html><html>   <head>      <meta charset="utf-8">              <title>white-space property</title>              <style>         th {            white-space: nowrap;         }      </style>   </head>        <body>      <table border="1" collap>         <thead>            <tr>               <th>First Heading of GeeksforGeeks</th>               <th>Second Heading of GeeksforGeeks</th>               <th>Third Heading of GeeksforGeeks</th>               <th>Fourth Heading of GeeksforGeeks</th>            </tr>         </thead>                    <tbody>            <tr>               <td>Value</td>               <td>Value</td>               <td>Value</td>               <td>Value</td>            </tr>         </tbody>      </table>   </body></html>
Output:Before applying white-space property:After applying white-space property:
Example 2: This example uses inline white-space property.
<!DOCTYPE html><html>   <head>      <meta charset="utf-8">              <title>white-space property</title>   </head>        <body>      <table border="1" collap>         <thead>            <tr>               <th style="white-space: nowrap;">                   First Heading of GeeksforGeeks               </th>                                <th>Second Heading of GeeksforGeeks</th>                                <th style="white-space: nowrap;">                   Third Heading of GeeksforGeeks               </th>                                <th>Fourth Heading of GeeksforGeeks</th>            </tr>         </thead>                    <tbody>            <tr>               <td>Value</td>               <td>Value</td>               <td>Value</td>               <td>Value</td>            </tr>         </tbody>      </table>   </body></html>
Output:Before applying white-space property:After applying white-space property:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
HTML | DOM Audio duration Property - GeeksforGeeks

14 Nov, 2019
The Audio duration property is used for returning the length of an audio. The Audio duration property returns the value in seconds.Different browsers return different precision values such as with safari returning up to 14 decimal places followed by opera returning up to 9 decimal places.The Audio duration property is a read-only property.The Audio duration function returns “NaN” if no video is set whereas if the audio is streamed and has no predefined length, it returns “Inf” (Infinity).
Syntax:
audioObject.duration
Below program illustrates the Audio duration Property:Example: Getting the length of an audio.
<!DOCTYPE html><html>  <head>    <title>        Audio duration Property    </title></head>  <body style="text-align:center">      <h1 style="color:green">      GeeksforGeeks    </h1>    <h2 style="font-family: Impact">      Audio duration Property    </h2>    <br>      <audio id="Test_Audio" controls>        <source src="sample1.ogg"                 type="audio/ogg">        <source src="sample1.mp3"                 type="audio/mpeg">    </audio>      <p>To get the exact length of the audio,      double click the "Return Audio Length" button.    </p>    <br>      <button ondblclick="My_Audio()">      Return Audio Length    </button>      <p id="test"></p>      <script>        var a = document.getElementById("Test_Audio");          function My_Audio() {            var a = document.getElementById(              "Test_Audio").duration;            document.getElementById("test").innerHTML = a;        }    </script>  </body>  </html>
Output:
Before clicking the button:
After clicking the button:
Supported Browsers: The browser supported by HTML | DOM Audio duration Property are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Matplotlib.pyplot.acorr() in Python - GeeksforGeeks

12 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The acorr() function in pyplot module of matplotlib library is used to plot the autocorrelation of x (array-like).
Syntax: matplotlib.pyplot.acorr(x, *, data=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
x: This parameter is a sequence of scalar.
detrend: This parameter is an optional parameter. Its default value is mlab.detrend_none
normed: This parameter is also an optional parameter and contains the bool value. Its default value is True
usevlines: This parameter is also an optional parameter and contains the bool value. Its default value is True
maxlags: This parameter is also an optional parameter and contains the integer value. Its default value is 10
linestyle: This parameter is also an optional parameter and used for plotting the data points, only when usevlines is False.
marker: This parameter is also an optional parameter and contains the string. Its default value is ‘o’
Returns: This method returns the following:
lags:This method returns the lag vector
c:This method returns the auto correlation vector.
line : Added LineCollection if usevlines is True, otherwise add Line2D.
b: This method returns the horizontal line at 0 if usevlines is True, otherwise None.
The resultant is (lags, c, line, b).
Below examples illustrate the matplotlib.pyplot.acorr() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib.pyplot.acorr()# function  import matplotlib.pyplot as pltimport numpy as np  # Time series datageeks = np.array([24.40, 110.25, 20.05, 22.00,                  61.90, 7.80, 15.00, 22.80,                   34.90, 57.30])  # Plot autocorrelationplt.acorr(geeks, maxlags = 9)  # Add labels to autocorrelation plotplt.title("Autocorrelation of Geeksforgeeks' Users data")plt.xlabel('X-axis')plt.ylabel('Y-axis')  # Display the autocorrelation plotplt.show()
Output:
Example #2:
# Implementation of matplotlib.pyplot.acorr() # function  import matplotlib.pyplot as pltimport numpy as np    # Fixing random state for reproducibilitynp.random.seed(10**7)  geeks = np.random.randn(51 )  plt.title("Autocorrelation Example")plt.acorr(geeks, usevlines = True,           normed = True, maxlags = 50,           lw = 2)  plt.grid(True)plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Convert integer to string in Python
GATE | GATE CS 2019 | Question 17 - GeeksforGeeks

14 Feb, 2019
Let G be an arbitrary group. Consider the following relations on G:
R1: ∀a, b ∈ G, aR1b if and only if ∃g ∈ G such that a = g−1bg
R2: ∀a, b ∈ G, aR2b if and only if a = b−1
Which of the above is/are equivalence relation/relations?(A) R1 and R2(B) R1 only(C) R2 only(D) Neither R1 nor R2Answer: (B)Explanation: Given R1 is a equivalence relation, because it satisfied reflexive, symmetric, and transitive conditions:
Reflexive: a = g–1ag can be satisfied by putting g = e, identity “e” always exists in a group.
Symmetric:aRb ⇒ a = g–1bg for some g
⇒ b = gag–1 = (g–1)–1ag–1
g–1 always exists for every g ∈ G. 
aRb ⇒ a = g–1bg for some g
⇒ b = gag–1 = (g–1)–1ag–1
g–1 always exists for every g ∈ G. 
Transitive:aRb and bRc ⇒ a = g1–1bg1 
and b = g2–1 cg2 for some g1g2 ∈ G.
Now a = g1–1 g2–1 cg2g1 = (g2g1)–1 cg2g1
g1 ∈ G and g2 ∈ G ⇒ g2g1 ∈ G 
since group is closed so aRb and aRb ⇒ aRc



aRb and bRc ⇒ a = g1–1bg1 
and b = g2–1 cg2 for some g1g2 ∈ G.
Now a = g1–1 g2–1 cg2g1 = (g2g1)–1 cg2g1
g1 ∈ G and g2 ∈ G ⇒ g2g1 ∈ G 
since group is closed so aRb and aRb ⇒ aRc



aR2a ⇒ a = a–1 ∀a which not be true in a group. 
So, option (B) is correct.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Shell Script to Validate Integer Input - GeeksforGeeks

09 Apr, 2021
Here we are going to see a shell script which validates an integer. We are going to display whether the input entered is an integer or an invalid input. 
Approach: 
Take input from the user.Store the input of any variableNow we are going to trim the input in such a way that all the -(minus) or +(plus) signs before the input are trimmed down.Now we are going to apply a regular expression to check if the input pattern has multiple occurrences of digits 0-9.If the input pattern contains only digits, this means that the input entered is a valid integer and in all other cases, invalid integer input is shown.
Take input from the user.
Store the input of any variable
Now we are going to trim the input in such a way that all the -(minus) or +(plus) signs before the input are trimmed down.
Now we are going to apply a regular expression to check if the input pattern has multiple occurrences of digits 0-9.
If the input pattern contains only digits, this means that the input entered is a valid integer and in all other cases, invalid integer input is shown.
The Shell Script is given below:
# Asking the user to enter an input
echo "Enter an input"

# reading and storing input
read variable

# Applying the approach given above

case ${variable#[-+]} in
  *[!0-9]* | '') echo "Not an integer" ;;
  * ) echo "Valid integer number" ;;
esac
Output:
Output of the above code snippet
Picked
Shell Script
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Extracting a substring as an array of characters in Java

To extract a substring as an array of characters in Java, use the getChars() method.
Let’s say the following is our string and character array.
String str = "World is not enough!";
char[] chArr = new char[10];
Now, use the getChars() method to extract a substring.
str.getChars(13, 19, chArr, 0);
The above substring is an array of characters which can be displayed as shown in the complete example below −
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = "World is not enough!";
      char[] chArr = new char[10];
      str.getChars(13, 19, chArr, 0);
      for(char res: chArr) {
         System.out.println(res);
      }
   }
}
e
n
o
u
g
h
How to get single array from multiple arrays in JavaScript

Suppose, we have an array of arrays like this −
const arr = [
   [ {"c": 1},{"d": 2} ],
   [ {"c": 2},{"d": 3} ]
];
We are required to write a JavaScript function that takes in one such array as the first and the only argument.
The function should then convert the array (creating a new array) into array of objects removing nested arrays.
Therefore, the final output should look like this −
const output = [{"c": 1},{"d": 2},{"c": 2},{"d": 3}];
const arr = [
   [ {"c": 1},{"d": 2} ],
   [ {"c": 2},{"d": 3} ]
];
const simplifyArray = (arr = []) => {
   const res = [];
   arr.forEach(element => {
      element.forEach(el => {
         res.push(el);
      });
   });
   return res;
};
console.log(simplifyArray(arr));
And the output in the console will be −
[ { c: 1 }, { d: 2 }, { c: 2 }, { d: 3 } ]
Fabric.js | Rect borderColor Property - GeeksforGeeks

20 May, 2020
In this article, we are going to see how to change the border color of the canvas rectangle using FabricJS. The canvas rectangle means rectangle is movable and can be stretched according to requirement. Further, the rectangle can be customized when it comes to initial stroke color, height, width, fill color, or stroke width.
Approach: To make it possible, we are going to use a JavaScript library called FabricJS. After importing the library, we will create a canvas block in the body tag which will contain the rectangle. After this, we will initialize instances of Canvas and Rect provided by FabricJS and change the border color of the canvas rectangle using borderColor property and render the Rect on the Canvas as given in the example below.
Syntax:
fabric.Rect({
    width: number,
    height: number,
    borderColor: string
}); 
Parameters: This function accepts three parameters as mentioned above and described below:
width: It specifies the width of rectangle.
height: It specifies the height of rectangle.
borderColor: It specifies the border color.
Example: This example uses FabricJS to change the border color of the canvas rectangle as given below. Note that you have to click on the rectangle to see the border.
<!DOCTYPE html> <html>   <head>     <title>         Fabric.js | Rect borderColor Property    </title>           <!-- Adding the FabricJS library -->    <script src= "https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">     </script> </head>   <body>     <canvas id="canvas" width="600" height="200"        style="border:1px solid #000000">     </canvas>           <script>               // Initiate a Canvas instance         var canvas = new fabric.Canvas("canvas");           // Initiate a Rect instance         var rectangle = new fabric.Rect({             width: 200,            height: 100,            fill: '',             stroke: 'green',            strokeWidth: 3,            borderColor: 'red'        });           // Render the Rect in canvas         canvas.add(rectangle);         canvas.centerObject(rectangle);    </script> </body>   </html>
Output:
Fabric.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Convert a string to an integer in JavaScript
C++ for loop

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.
The syntax of a for loop in C++ is −
for ( init; condition; increment ) {
   statement(s);
}

Here is the flow of control in a for loop −
The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears.
The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears.
Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and flow of control jumps to the next statement just after the for loop.
Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and flow of control jumps to the next statement just after the for loop.
After the body of the for loop executes, the flow of control jumps back up to the increment statement. This statement can be left blank, as long as a semicolon appears after the condition.
After the body of the for loop executes, the flow of control jumps back up to the increment statement. This statement can be left blank, as long as a semicolon appears after the condition.
The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the for loop terminates.
The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the for loop terminates.
#include <iostream>
using namespace std;
 
int main () {
   // for loop execution
   for( int a = 10; a < 20; a = a + 1 ) {
      cout << "value of a: " << a << endl;
   }
 
   return 0;
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Displaying rotatable 3D plots in IPython or Jupyter Notebook

By creating a 3D projection on the axis and iterating that axis for different angles using view_init(), we can rotate the output diagram.
Create a new figure, or activate an existing figure.
Create a new figure, or activate an existing figure.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement with nrow = 1, ncols = 1, index = 1, and projection = '3d'.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement with nrow = 1, ncols = 1, index = 1, and projection = '3d'.
Use the method, get_test_data to return a tuple X, Y, Z with a test dataset.
Use the method, get_test_data to return a tuple X, Y, Z with a test dataset.
Plot a 3D wireframe with data test data x, y, and z.
Plot a 3D wireframe with data test data x, y, and z.
To make it rotatable, we can set the elevation and azimuth of the axes in degrees (not radians), using view_init() method.
To make it rotatable, we can set the elevation and azimuth of the axes in degrees (not radians), using view_init() method.
To show the figure, use plt.show() method.
To show the figure, use plt.show() method.
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride=5, cstride=5)

# rotate the axes and update
for angle in range(0, 360):
   ax.view_init(30, angle)

plt.show()
Logging in Node.js

Logging is a very essential part in any application whether it is made in Node.js or any other programming languages. Logging helps us to detect weird behaviours of an application along with real-time errors and exceptions. One should definitely put logical logs in their application. These logs help the user to identify any mistakes and resolve it on urgent basis.
There are 5 different log levels which are present at the moment with the user. These log levels are used to define different kinds of logs and helps the user to identify different scenarios. The log levels must be carefully configured to get the best deal out of these logs −
error
error
warn
warn
info
info
verbose
verbose
debug
debug
You can put this middleware in the request pipeline so that you can directly use the power of debug module to print logs. The best advantage of debug module is that almost all the modules use debug for printing logs. You can use the debug module to print logs and errors.
This middleware is mainly used for acting as a middle pipeline – you can pass logs in this pipeline which will be printed in the log file. Requests and responses are also passed through this middleware for logging purposes. It is very beneficial in an Express app. Setting up middleware is easy and can be done in any frameworks being used.
application
const app = express()
const logMiddleware = require('my-logging-middleware')
app.use(logMiddleware)
router
const router = express.Router()
const routeLoggingMiddleware = require('my-route-logging-middleware')
router.use(routeLoggingMiddleware)
errors
const app = express();
const errorLoggingMiddleware = require('my-error-logging-middleware')
app.use(errorLoggingMiddleware)
You can also use the winston package for logging purposes. It also provides different log levels, queries as well as a profiler.
application
const app = express()
const winstonPackage = require('winston')
const consoleTransport = new winstonPackage.transports.Console()
const myWinstonOptions = {
   transports: [consoleTransport]
}
const logger = new winstonPackage.createLogger(myWinstonOptions)

function logRequest(req, res, next) {
   logger.info(req.url)
   next()
}
app.use(logRequest)

function logError(err, req, res, next) {
   logger.error(err)
   next()
}
app.use(logError)
Handling Overflowing Content using CSS

We can use CSS overflow property to manage/handle the overflowing content of an element. This property allows user to clip content, provide scrollbars to view clipped content, render content outside the container thus the name overflow.
Following is the syntax for CSS Overflow property −
Selector {
   overflow: /*value*/
}
Let us see an example for CSS overflow property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Overflow</title>
<style>
form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
   margin:5px;
}
input[type="button"] {
   border-radius: 10px;
}
#containerDiv {
   margin: 0 auto;
   height: 110px;
   overflow: scroll;
}
</style></head>
<body>
<form>
<fieldset>
<legend>CSS Overflow</legend>
<div id="containerDiv">
This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text. This is paragraph 1 with some dummy text.</div>
<input type="button" onclick="add()" value="Remove Scrollbars">
</fieldset>
</form>
<script>
function add() {
   document.querySelector('#containerDiv').style.overflow = "hidden";
}
</script>
</body>
</html>
Before clicking ‘Remove Scrollbars’ button −
After clicking ‘Remove Scrollbars’ button −
Let’s see another example for the CSS overflow property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>CSS Overflow</title>
<style>
form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
   margin:5px;
}
input[type="button"] {
   border-radius: 10px;
}
#containerDiv {
   margin: 0 auto;
   height: 100px;
   width: 100px;
   overflow: auto;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>CSS Overflow</legend>
<div id="containerDiv">
<img id="image" src="https://www.tutorialspoint.com/sas/images/sas-mini-logo.jpg">
</div>
<input type="button" onclick="fitHeight()" value="Remove Scrollbars">
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var imgSelect = document.getElementById("image");
var containerDiv = document.getElementById("containerDiv");
function fitHeight() {
   containerDiv.style.height = imgSelect.height+'px';
   containerDiv.style.width = imgSelect.width+'px';
   containerDiv.style.overflow = 'hidden';
}
</script>
</body>
</html>
Before clicking any button −
After clicking ‘Remove Scrollbars’ button −
MySQL Syntax to create Foreign Key?

The syntax to create a foreign key is as follows −
alter table yourSecondTableName ADD CONSTRAINT yourConstraintname FOREIGN KEY(yourForeignKeyColumnName)
references yourFirstTableName (yourPrimaryKeyColumnName);
To understand the above syntax, let us create two tables. The query to create the first table is as follows −
mysql> create table Department_Table
   -> (
   -> Department_Id int not null auto_increment primary key,
   -> Department_Name varchar(30)
   -> );
Query OK, 0 rows affected (0.83 sec)
The query to create the second table is as follows −
mysql> create table Employee_Table
   -> (
   -> EmployeeID int not null auto_increment primary key,
   -> EmployeeName varchar(80),
   -> Job varchar(30),
   -> Department_Id int not null references department(departmentID)
   -> );
Query OK, 0 rows affected (1.12 sec)
The above Department_Id int, not null references department(departmentID) does not create a foreign key. Now follow the above syntax to create a foreign key.
The query is as follows −
mysql> alter table Employee_Table ADD CONSTRAINT fk_Department_Id FOREIGN KEY(Department_Id)
   -> references Department_Table(Department_Id);
Query OK, 0 rows affected (2.82 sec)
Records: 0 Duplicates: 0 Warnings:
Find number of days between two given dates | Practice | GeeksforGeeks

Given two dates, find the total number of days between them.
Note: The system follows Gregorian calender from the beginning of time.
 
Example 1:
Input:
d1 = 10, m1 = 2, y1 = 2014
d2 = 10, m2 = 3, y2 = 2015
Output:
393
Explanation:
By counting manually, we find out there
are 393 days between the two dates.
Example 2:
Input:
d1 = 10, m1 = 2, y1 = 2001
d2 = 10, m2 = 2, y2 = 2002
Output:
365
Explanation:
By counting manually, we find out there
are 365 days between the two dates.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function noOfDays() which takes Integers d1,m1,y1 for the first date and d2,m2,y2 as the second date as input and returns the answer.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= d1,d2 <= 31
1 <= m1,m2 <= 12
1 <= y1,y2 <= 3000
-1
Panu7 months ago
Panu
int noOfDays(int d1, int m1, int y1, int d2, int m2, int y2) {        int monthdays[12]={31,28,31,30,31,30,31,31,30,31,30,31};        long int n1=y1*365+d1;        for(int i=0;i<m1-1;i++) n1+="monthdays[i];" n1+="countleapyears(y1,m1);" long="" int="" n2="y2*365+d2;" for(int="" i="0;i&lt;m2-1;i++)" n2+="monthdays[i];" n2+="countleapyears(y2,m2);" if(n2="">n1)            return n2-n1;        else            return n1-n2;    }
0
Panu
This comment was deleted.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Calculating percentage in a MySQL query and round off the result

For this, you can use CONCAT() and round(). Let us first create a table −
mysql> create table DemoTable1844
     (
     Number int,
     TotalNumber int
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1844 values(50,500);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1844 values(80,500);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1844 values(98,500);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1844 values(45,500);
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1844;
This will produce the following output −
+--------+-------------+
| Number | TotalNumber |
+--------+-------------+
|     50 |         500 |
|     80 |         500 |
|     98 |         500 |
|     45 |         500 |
+--------+-------------+
4 rows in set (0.00 sec)
Here is the query to calculating percentage in a query and rounding off the result −
mysql> select concat(round(((Number / TotalNumber) * 100 ),2), '%') as Result from DemoTable1844;
This will produce the following output −
+--------+
| Result |
+--------+
| 10.00% |
| 16.00% |
| 19.60% |
| 9.00%  |
+--------+
4 rows in set (0.00 sec)
What is the difference between VAR and DYNAMIC keywords in C#?

Store any type of value in the dynamic data type variable created using dynamic keyword. Type checking for these types of variables takes place at run-time. Dynamic are dynamically typed variables.
The following is the syntax for declaring a dynamic type −
dynamic <variable_name> = value;
The following is an example −
dynamic val1 = 100;
dynamic val2 = 5;
dynamic val3 = 20;
The dynamic types are similar to object types except that type checking for object type variables takes place at compile time, whereas that for the dynamic type variables takes place at runtime.
The "var" keyword initializes variables with var support. Just assign whatever value you want for the variable, integer, string, float, etc. It is a statically typed variable.
 Live Demo
using System;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         var myInt = 5;
         var myString = "Amit";
         Console.WriteLine("Rank: {0} \nName: {1}",myInt,myString);
      }
   }
}
Rank: 5
Name: Amit
Google Colab - Executing External Python Files

Suppose, you already have some Python code developed that is stored in your Google Drive. Now, you will like to load this code in Colab for further modifications. In this chapter, we will see how to load and run the code stored in your Google Drive.
Tools / Command palette

You will see the list of commands as shown in this screenshot −
Type a few letters like “m” in the search box to locate the mount command. Select Mount Drive command from the list. The following code would be inserted in your Code cell.
# Run this cell to mount your Google Drive.
from google.colab import drive
drive.mount('/content/drive')

If you run this code, you will be asked to enter the authentication code. The corresponding screen looks as shown below −
Open the above URL in your browser. You will be asked to login to your Google account. Now, you will see the following screen −
If you grant the permissions, you will receive your code as follows −
Cut-n-paste this code in the Code cell and hit ENTER. After a while, the drive will be mounted as seen in the screenshot below −
Now, you are ready to use the contents of your drive in Colab.
You can list the contents of the drive using the ls command as follows −
!ls "/content/drive/My Drive/Colab Notebooks"

This command will list the contents of your Colab Notebooks folder. The sample output of my drive contents are shown here −
Greeting.ipynb hello.py LogisticRegressionCensusData.ipynb LogisticRegressionDigitalOcean.ipynb MyFirstColabNotebook.ipynb SamplePlot.ipynb

Now, let us say that you want to run a Python file called hello.py stored in your Google Drive. Type the following command in the Code cell −
!python3 "/content/drive/My Drive/Colab Notebooks/hello.py"

The contents of hello.py are given here for your reference −
print("Welcome to TutorialsPoint!")

You will now see the following output −
Welcome to TutorialsPoint!

Besides the text output, Colab also supports the graphical outputs. We will see this in the next chapter.

    20 Lectures 
     2.5 hours 

 Asif Hussain

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    33 Lectures 
     2.5 hours 

 Sasha Miller

    22 Lectures 
     1.5 hours 

 Zach Miller

    16 Lectures 
     1.5 hours 

 Sasha Miller

    23 Lectures 
     2.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Python | Mean of tuple list

18 Oct, 2019
Sometimes, while working with Python tuple list, we can have a problem in which we need to find the average of tuple values in the list. This problem has the possible application in many domains including mathematics. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopsThe first approach that can be thought of to solve this problem can be a brute force approach in which we just loop each tuple to add element and then just divide it by number of tuples in the list.
# Python3 code to demonstrate working of# Mean of tuple list# Using loops  # Initializing listtest_list = [(1, 4, 5), (7, 8), (2, 4, 10)]  # printing original listprint("The original list is : " + str(test_list))  # Average of tuple list# Using loopssum = 0for sub in test_list:    for i in sub:        sum = sum + ires = sum / len(test_list)  # printing resultprint("The mean of tuple list is : " + str(res))
The original list is : [(1, 4, 5), (7, 8), (2, 4, 10)]
The mean of tuple list is : 13.666666666666666

 
Method #2 : Using chain() + sum()In order to reduce the line of codes, the chain() functionality can be used so that all the elements can be extracted and then can be added using sum().
# Python3 code to demonstrate working of# Mean of tuple list# Using chain() + sum()from itertools import chain  # Initializing listtest_list = [(1, 4, 5), (7, 8), (2, 4, 10)]  # printing original listprint("The original list is : " + str(test_list))  # Average of tuple list# Using chain() + sum()temp = list(chain(*test_list)) res = sum(temp)/ len(test_list)  # printing resultprint("The mean of tuple list is : " + str(res))
The original list is : [(1, 4, 5), (7, 8), (2, 4, 10)]
The mean of tuple list is : 13.666666666666666

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
CSS | column-rule Property

29 Apr, 2021
The column-rule property in CSS is used to specify the width, style, and color of the rules between the columns.Syntax:  
column-rule: column-rule-width column-rule-style column-rule-color|
initial|inherit;
Property Values:  
column-rule-width: This value is used to set the width of the rule between the columns. The default value of this property-value is medium.
column-rule-style: This value is used to set the style of the rule between columns. The default value of this property-value is none.
column-rule-color: This value is used to set the color of the rule between columns. The default value of this property value is the color of the element.
initial: This value is used to set default value of this column-rule property.
inherit: This value tells the column-rule property to inherit the property from its parent.
Example:  
html
<!DOCTYPE html><html><head>    <title>The column-rule Property</title>         <style>    .gfg {        -webkit-column-count: 3;        -moz-column-count: 3        column-count: 3;                 -webkit-column-gap: 40px;        -moz-column-gap: 40px;        column-gap: 40px;                 -webkit-column-rule: 4px double #ff00ff;        -moz-column-rule: 4px double #ff00ff;        column-rule: 4px double #ff00ff;    }         h1 {        color:green;    }    h1, h2 {        text-align:center;    }    </style></head><body>    <h1>        GeeksforGeeks    </h1>    <h2>        The column-rule Property    </h2>          <p>        The column-rule property sets the width, style,        and color of the rule between the columns of        the element:    </p>          <div class="gfg">        The course is designed for students        as well as working professionals to prepare        for coding interviews. This course is going        to have coding questions from school level        to the level needed for product based companies        like Amazon, Microsoft, Adobe, etc.    </div></body></html>                   
Output:  
Supported Browsers: The browsers supported by column-rule Property are listed below; 
Google Chrome: 50.0, 4.0 -webkit-
Internet Explorer: 10.0
Firefox: 52.0, 2.0 -moz-
Opera: 37.0, 15.0 -webkit-, 11.1
Safari: 9.0, 3.1 -webkit-
 
arorakashish0911
CSS-Properties
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?