code-rag-bench/online-tutorials huggingface dataset:
Program to find largest element in an array in C++

In this tutorial, we will be discussing a program to find the largest element in an
array.
For this, we will be provided with an array. Our task is to find the largest number from
the elements inside the array.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
//finding largest integer
int largest(int arr[], int n){
   int i;
   int max = arr[0];
   //traversing other elements
   for (i = 1; i < n; i++)
   if (arr[i] > max)
      max = arr[i];
   return max;
}
int main(){
   int arr[] = {10, 324, 45, 90, 9808};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Largest in given array is " << largest(arr, n);
   return 0;
}
Largest in given array is 9808
Java Program to sort a List in case insensitive order

Let’s say your list is having the following elements −
P, W, g, K, H, t, E
Therefore, case sensitive order means, capital and small letters will be considered irrespective of case. The output would be −
E, g, H, K, P, t, W
The following is our array −
String[] arr = new String[] { "P", "W", "g", "K", "H", "t", "E" };
Convert the above array to a List −
List<String>list = Arrays.asList(arr);
Now sort the above list in case insensitive order −
Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
 Live Demo
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Demo {
   public static void main(String[] argv) throws Exception {
      String[] arr = new String[] { "P", "W", "g", "K", "H", "t", "E" };
      List<String>list = Arrays.asList(arr);
      System.out.println("List = "+list);
      Collections.sort(list);
      System.out.println("Case Sensitive Sort = "+list);
      Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
      System.out.println("Case Insensitive Sort = "+list);
   }
}
List = [P, W, g, K, H, t, E]
Case Sensitive Sort = [E, H, K, P, W, g, t]
Case Insensitive Sort = [E, g, H, K, P, t, W]
How to pass entire array as an argument to a function in C language?

The array is a group of related items that store with a common name. Following are the two ways of passing arrays as arguments to functions −
sending entire array as argument to function
sending individual elements as argument to function
To send entire array as argument, just send the array name in the function call.
To send entire array as argument, just send the array name in the function call.
To receive an array, it must be declared in the function header.
To receive an array, it must be declared in the function header.
#include<stdio.h>
main (){
   void display (int a[5]);
   int a[5], i;
   clrscr();
   printf ("enter 5 elements");
   for (i=0; i<5; i++)
      scanf("%d", &a[i]);
   display (a); //calling array
   getch( );
}
void display (int a[5]){
   int i;
   printf ("elements of the array are");
   for (i=0; i<5; i++)
      printf("%d ", a[i]);
}
Enter 5 elements
10 20 30 40 50
Elements of the array are
10 20 30 40 50
Let us consider another example to know more about passing entire array as argument to function −
#include<stdio.h>
main (){
   void number(int a[5]);
   int a[5], i;
   printf ("enter 5 elements\n");
   for (i=0; i<5; i++)
      scanf("%d", &a[i]);
   number(a); //calling array
   getch( );
}
void number(int a[5]){
   int i;
   printf ("elements of the array are\n");
   for (i=0; i<5; i++)
      printf("%d\n" , a[i]);
}
enter 5 elements
100
200
300
400
500
elements of the array are
100
200
300
400
500
JavaScript Date toISOString() Method

30 May, 2022
Below is the example of Date toISOString() method.
Example: 
javascript
<script>   // Here a date has been assigned   // while creating Date object   var dateobj =   new Date('October 15, 1996 05:35:32');    // Contents of above date object is converted   // into a string using toISOString() function.   var B = dateobj.toISOString();    // Printing the converted string.   document.write(B);</script>
Output:
1996-10-15T00:05:32.000Z
The date.toISOString() method is used to convert the given date object’s contents into a string in ISO format (ISO 8601) i.e, in the form of (YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ).The date object is created using date() constructor. 
Syntax:
dateObj.toISOString()
Parameters: This method does not take any parameter. It is just used along with a Date object created using Date() constructor. 
Return Values: It returns the converted string of Date() constructor contents into ISO format (ISO 8601). 
Note: The DateObj is a valid Date object created using Date()constructor. More codes for the above method are as follows: 
Program 1: Here nothing as a parameter is passed while creating date object but still toISOString() method return current day name, month name, date, year, and time. 
javascript
<script>   // Here nothing has been assigned   // while creating Date object   var dateobj = new Date();    // Contents of above date object is   // converted into a string using toISOString() method.   var B = dateobj.toISOString();    // Printing the converted string.   document.write(B);</script>
Output:
2018-04-23T10:26:00.996Z
Program 2: Here we will pass a date object toISOString() method return day name, month name, date, year, and time. 
javascript
<script>    // Here nothing has been assigned    // while creating Date object    var dateobj =    new Date('October 13, 1996 05:35:32 GMT-3:00');     // Contents of above date object is    // converted into a string using toISOString() method.    var B = dateobj.toISOString();     // Printing the converted string.    document.write(B);</script>                   
Output:
1996-10-13T08:35:32.000Z
Note: Months, Dates, hours, minutes, seconds, milliseconds should all be in their respective range of 0 to 11, 1 to 31, 0 to 23, 0 to 59, 0 to 59, 0 to 999 respectively. 
Supported Browsers: The browsers supported by JavaScript Date toISOString() method are listed below:
Google Chrome 3 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 9 and above
Opera 10.5 and above
Safari 5 and above
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
ysachin2314
simmytarika5
javascript-date
JavaScript-Methods
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Find common elements in list of lists

12 Feb, 2019
The problem of finding the common elements in list of 2 lists is quite a common problem and can be dealt with ease and also has been discussed before many times. But sometimes, we require to find the elements that are in common from N lists. Let’s discuss certain ways in which this operation can be performed.
Method #1 : Using reduce() + lambda + set()This particular task can be achieved in just a one line using the combination of the above functions. The reduce function can be used to operate the function of “&” operation to all the list. The set function can be used to convert list into a set to remove repetition.
# Python3 code to demonstrate # common element extraction form N lists # using reduce() + lambda + set()from functools import reduce  # initializing list of liststest_list = [[2, 3, 5, 8], [2, 6, 7, 3], [10, 9, 2, 3]]  # printing original listprint ("The original list is : " + str(test_list))  # common element extraction form N lists# using reduce() + lambda + set()res = list(reduce(lambda i, j: i & j, (set(x) for x in test_list)))  # printing resultprint ("The common elements from N lists : " + str(res))
The original list is : [[2, 3, 5, 8], [2, 6, 7, 3], [10, 9, 2, 3]]
The common elements from N lists : [2, 3]

 Method #2 : Using map() + intersection()The map function can be used to convert each of the lists to set to be operated by to perform the intersection, using the set.intersection function. This is the most elegant way to perform this particular task.
# Python3 code to demonstrate # common element extraction form N lists # using map() + intersection()  # initializing list of liststest_list = [[2, 3, 5, 8], [2, 6, 7, 3], [10, 9, 2, 3]]  # printing original listprint ("The original list is : " + str(test_list))  # common element extraction form N lists# using map() + intersection()res = list(set.intersection(*map(set, test_list)))  # printing resultprint ("The common elements from N lists : " + str(res))
The original list is : [[2, 3, 5, 8], [2, 6, 7, 3], [10, 9, 2, 3]]
The common elements from N lists : [2, 3]

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 Program for Fibonacci numbers
How to specify minimum & maximum number of characters allowed in an input field in HTML ?

28 Feb, 2022
Given an input field and the task is to set the minimum/maximum number of characters allowed in an input field in HTML.
To set the maximum character limit in input field, we use <input> maxlength attribute. This attribute is used to specify the maximum number of characters enters into the <input> element.
To set the minimum character limit in input field, we use <input> minlength attribute. This attribute is used to specify the minimum number of characters enters into the <input> element.
Syntax: 
<input maxlength="number1">
<input minlength="number2"> 
Attribute Value: 
number1: It contains single value number which allows the maximum number of character in <input> element. Its default value is 524288.
number2: The minimum number of character required in input fields.
Example 1: Set the limit of maximum number of characters allowed in input fields.
HTML
<!DOCTYPE html><html> <head>    <style>        body {            text-align: center;        }         h1 {            color: green;        }    </style></head> <body>    <h1>GeeksforGeeks</h1>    <h3>        How to specify the maximum number        of characters <br>allowed in an        input field in HTML?    </h3>    <form action="#">        Username:        <input type="text" name="username"            maxlength="12"><br><br>         Password:        <input type="password" name="password"            maxlength="10"><br><br>                     <input type="submit" value="Submit">    </form></body> </html>
   
Output: 
 
 
Example 2: Set the limit of minimum number of characters allowed in input fields.
 
HTML
<!DOCTYPE html><html> <head>    <style>        body {            text-align: center;        }         h1 {            color: green;        }    </style></head> <body>    <h1>GeeksforGeeks</h1>    <h3>        How to specify the minimum number        of characters <br>allowed in an        input field in HTML?    </h3>    <form action="#">        Username:        <input type="text" name="username"            minlength="12"><br><br>         Password:        <input type="password" name="password"            minlength="10"><br><br>                     <input type="submit" value="Submit">    </form></body> </html>
Output:
varshagumber28
HTML-Attributes
HTML-Questions
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.vlines() in Python

18 Nov, 2021
Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python.  
 
matplotlib.pyplot.vlines() is a function used in the plotting of a dataset. In matplotlib.pyplot.vlines(), vlines is the abbreviation for vertical lines.what this function does is very much clear from the expanded form, which says that function deals with the plotting of the vertical lines across the axes. 
Syntax: vlines(x, ymin, ymax, colors, linestyles)
Example 1:  
Python3
import numpy as npimport matplotlib.pyplot as plt plt.vlines(4, 0, 5, linestyles ="dotted", colors ="k")plt.vlines(3, 0, 5, linestyles ="solid", colors ="k")plt.vlines(5, 0, 5, linestyles ="dashed", colors ="k") plt.xlim(0, 10)plt.ylim(0, 10) plt.show()
Output : 
In the above example, the first argument at the beginning of the vlines() function shows the axis-point at the vertical line is to be generated, the next argument refers to the lower limit of the total length of the vertical line, whereas the third argument refers to the upper limit of the total length of the vertical line. After these three basic arguments, the next argument we can use is linestyles which decides the type of line to be plotted (eg.dotted, solid, dashed, dashdot, etc.), the last argument used is colors which is optional, basically, it is array-like of colors.Example 2: 
Python3
import matplotlib.pyplot as plt plt.vlines((1, 3, 5,), 0, 10, colors = ("r", "g", "b"),         linestyles = ("solid", "dashed", "dotted")) plt.show()
Output: 
 
kalrap615
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Redirect to Another Page After 5 Seconds using jQuery ? - GeeksforGeeks

14 Jul, 2021
In this article, we will learn, how to redirect to another page or URL after a specified time in jQuery. The built-in function used for performing the action is as follows. The setTimeout(callback, delay) function takes two parameters a callback and a time in milliseconds. When this method is called, the callback function will be executed after the specified time. With this method, the callback function is executed only one time after the specified time.
Our goal is to redirect to another page after 5 seconds and this will happen only one time. We use jQuery setTimeout() function
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <!-- using jquery library -->    <script         src="https://code.jquery.com/jquery-git.js">    </script>    </head>  <body>    <h1 style="color: green;">      Geeksforgeeks    </h1>      <!-- Creating a button -->    <div class="redirect">        <button>Redirect me to GFG</button>    </div>      <!-- Script which will redirect          us to another page    -->    <script>        // click event on button        $("button").click(function(){            $(".redirect").text("Redirecting....")              // storing url and time            let delay = 5000;            let url = "https://www.geeksforgeeks.org/";            setTimeout(function(){                location = url;            },5000)        })    </script></body>  </html>
Output: After 5 seconds, the “geeksforgeeks” home page will open.
jQuery-Methods
jQuery-Questions
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Show and Hide div elements using radio buttons?
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
jQuery | removeAttr() with Examples
How to get the value in an input text box using jQuery ?
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?
How to change background color according to the mouse location using JavaScript ? - GeeksforGeeks

08 Jun, 2020
The background color can be changed according to the cursor position using the DOM (Document Object Model). In this article, we use the position of the cursor to set the value of the background.
Approach: The approach is to use DOM manipulation to change the background according to the cursor position at a particular time.
HTML Code: In this section, we have a simple boiler-plate code of HTML with a div tag in it.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport" content=        "width=device-width,         initial-scale=1.0" />      <title>        How to change background         color according to mouse         location using JavaScript?    </title></head>  <body>    <div class="geeks"></div></body>  </html>
CSS Code: In CSS, we have just set the background color as cover.
<style>    .geeks {        width: 100%;        height: 600px;        background-size: cover;    }</style>
Note: You can set a default background.
Javascript Code: In JS, first select the div tag using querySelector function and we have offset property to get the position of the cursor on the 2-D plane i.e. the X and Y-axis. Now we set the value of background using the co-ordinates.
<script>    var div =         document.querySelector(".geeks");      div.addEventListener(        "mousemove", function (e) {        x = e.offsetX;        y = e.offsetY;        div.style.backgroundColor             = `rgb(${x}, ${y}, ${x - y})`;    });</script>
Complete Code: It is the combination of the above three sections of code.
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta name="viewport" content="width=device-width,                 initial-scale=1.0" />    <title>        How to change background color        according to mouse location        using JavaScript ?    </title>      <style>        .geeks {            width: 100%;            height: 600px;            background-size: cover;        }    </style></head>  <body>    <div class="geeks"></div>      <script>        var div =            document.querySelector(".geeks");          div.addEventListener(            "mousemove", function (e) {                x = e.offsetX;                y = e.offsetY;                div.style.backgroundColor                    = `rgb(${x}, ${y}, ${x - y})`;            });    </script></body>  </html>
Output:
CSS-Misc
HTML-Misc
JavaScript-Misc
CSS
HTML
JavaScript
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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?
Design a web page using HTML and CSS
How to Upload Image into Database and Display it using PHP ?
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 ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
How to declare the optional function parameters in JavaScript ? - GeeksforGeeks

10 Jun, 2019
To declare optional function parameters in JavaScript, there are two approaches:
Using the Logical OR operator (‘||’):In this approach, the optional parameter is Logically ORed with the default value within the body of the function.Note: The optional parameters should always come at the end on the parameter list.Syntax:function myFunc(a,b) {
  b = b || 0;
  // b will be set either to b or to 0.
}
Example 1: In the following program the optional parameter is ‘b’:<script>    function check(a, b) {        b = b || 0;        document.write("Value of a is: " + a +                       " Value of b is: " + b +                       "<br>");    }    check(5, 3);    check(10); </script>Output:
Note: The optional parameters should always come at the end on the parameter list.
Syntax:
function myFunc(a,b) {
  b = b || 0;
  // b will be set either to b or to 0.
}

Example 1: In the following program the optional parameter is ‘b’:
<script>    function check(a, b) {        b = b || 0;        document.write("Value of a is: " + a +                       " Value of b is: " + b +                       "<br>");    }    check(5, 3);    check(10); </script>
Output:
Using the Assignment operator (“=”):In this approach the optional variable is assigned the default value in the declaration statement itself.Note: The optional parameters should always come at the end on the parameter list.Syntax:function myFunc(a, b = 0) {
   // function body
}Example 2: In the following program the optional parameter is ‘b’:<script>    function check(a, b = 0) {        document.write("Value of a is: " + a +                        " Value of b is: " + b +                        "<br>");    }    check(9, 10);    check(1); </script>Output:
Note: The optional parameters should always come at the end on the parameter list.
Syntax:
function myFunc(a, b = 0) {
   // function body
}
Example 2: In the following program the optional parameter is ‘b’:
<script>    function check(a, b = 0) {        document.write("Value of a is: " + a +                        " Value of b is: " + b +                        "<br>");    }    check(9, 10);    check(1); </script>
Output:
javascript-functions
JavaScript-Misc
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
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
Difference Between PUT and PATCH Request
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?
C++ Program to print Fibonacci Series using Class template - GeeksforGeeks

10 Oct, 2019
Given a number n, the task is to write a program in C++ to print the n-terms of Fibonacci Series using a Class templateThe Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ........
Examples:
Input: n = 2
Output: 0, 1

Input: n = 9
Output: 0, 1, 1, 2, 3, 5, 8, 13, 21

Approach:
Create a class for the Fibonacci Series
Take the first two terms of the series as public members a and b with values 0 and 1, respectively.
Create a generate() method in this class to generate the Fibonacci Series.
Create an object of this class and call the generate() method of this class using that object.
The Fibonacci Series will get printed.
Below is the implementation of the above approach:
// C++ Program to print Fibonacci// Series using Class template  #include <bits/stdc++.h>using namespace std;  // Creating class for Fibonacci.class Fibonacci {      // Taking the integers as public.public:    int a, b, c;    void generate(int);};  void Fibonacci::generate(int n){    a = 0;    b = 1;      cout << a << " " << b;      // Using for loop for continuing    // the Fibonacci series.    for (int i = 1; i <= n - 2; i++) {          // Addition of the previous two terms        // to get the next term.        c = a + b;        cout << " " << c;          // Converting the new term        // into an old term to get        // more new terms in series.        a = b;        b = c;    }}  // Driver codeint main(){    int n = 9;      Fibonacci fib;    fib.generate(n);    return 0;}
0 1 1 2 3 5 8 13 21

Fibonacci
C++ Programs
Fibonacci
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Shallow Copy and Deep Copy in C++
Passing a function as a parameter in C++
cin in C++
CSV file management using C++
C Program to Swap two Numbers
Program to implement Singly Linked List in C++ using class
C++ Program to check if a given String is Palindrome or not
Const keyword in C++
Generics in C++
How to find the minimum and maximum element of a Vector using STL in C++?
PYGLET – Unformatted Document - GeeksforGeeks

10 Jun, 2021
In this article we will see how we can create a unformatted document in PYGLET module in python. Pyglet is easy to use but powerful library for developing visually rich GUI applications like games, multimedia etc. A window is a “heavyweight” object occupying operating system resources. Windows may appear as floating regions or can be set to fill an entire screen (fullscreen). Unformatted documents are generally laid out to make copy paste easy without adding structure, such as headings, indentation, font variations. In order words we can say this document contains plain text.
We can create a window with the help of command given below 
# creating a window
window = pyglet.window.Window(width, height, title)
 
In order to create window we use pyglet.text.document.UnformattedDocument( methodSyntax : pyglet.text.document.UnformattedDocument(text)Argument : It takes string as argumentReturn : It returns UnformattedDocument object  
Below is the implementation  
Python3
# importing pyglet moduleimport pygletimport pyglet.window.key  # width of windowwidth = 500  # height of windowheight = 500  # caption i.e title of the windowtitle = "Geeksforgeeks"  # creating a windowwindow = pyglet.window.Window(width, height, title)  # texttext = "GeeksforGeeks Learn and Grow"  # batch objectbatch = pyglet.graphics.Batch()  # creating a unformatted document# unlike formatted document it is just plain textdocument = pyglet.text.document.UnformattedDocument(text)  # setting style to the documentdocument.set_style(0, len(document.text), dict(font_name ='Arial', font_size = 16, color =(255, 255, 255, 255)))  # creating a incremental text layoutlayout = pyglet.text.layout.IncrementalTextLayout(document, 400, 350, batch = batch)  # creating a caretcaret = pyglet.text.caret.Caret(layout, color =(150, 255, 150))      # caret to window push handlerswindow.push_handlers(caret)  # setting caret stylecaret.set_style(dict(font_name ="Arial"))  # on draw event@window.eventdef on_draw():          # clear the window    window.clear()          # draw the batch    batch.draw()          # caret to window push handlers    window.push_handlers(caret)        # key press event   @window.eventdef on_key_press(symbol, modifier):      # key "C" get press    if symbol == pyglet.window.key.C:                  # closing the window        # window.close()        pass     # image for iconimg = pyglet.resource.image("gfg.png") # setting image as iconwindow.set_icon(img)   # start running the applicationpyglet.app.run()
Output :  
 
anikakapoor
Python-gui
Python-Pyglet
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Python Program to find the Quotient and Remainder of two numbers - GeeksforGeeks

29 Aug, 2020
Given two numbers n and m. The task is to find the quotient and remainder of two numbers by dividing n by m.
Examples:
Input:
n = 10
m = 3
Output:
Quotient:  3
Remainder 1

Input
n = 99
m = 5
Output:
Quotient:  19
Remainder 4

Method 1: Naive approach
The naive approach is to find the quotient using the double division (//) operator and remainder using the modulus (%) operator.
Example:
Python3
# Python program to find the# quotient and remainder  def find(n, m):          # for quotient    q = n//m    print("Quotient: ", q)          # for remainder    r = n%m    print("Remainder", r)      # Driver Codefind(10, 3)find(99, 5)
Output:
Quotient:  3
Remainder 1
Quotient:  19
Remainder 4

Method 2: Using divmod() method
Divmod() method takes two numbers as parameters and returns the tuple containing both quotient and remainder.
Example:
Python3
# Python program to find the# quotient and remainder using# divmod() method    q, r = divmod(10, 3)print("Quotient: ", q)print("Remainder: ", r)  q, r = divmod(99, 5)print("Quotient: ", q)print("Remainder: ", r)
Output:
Quotient:  3
Remainder 1
Quotient:  19
Remainder 4

Number Divisibility
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Possible Words using given characters in Python - GeeksforGeeks

13 Jun, 2019
Given a dictionary and a character array, print all valid words that are possible using characters from the array.Note: Repetitions of characters is not allowed.Examples:
Input : Dict = ["go","bat","me","eat","goal","boy", "run"]
        arr = ['e','o','b', 'a','m','g', 'l']
Output : go, me, goal. 

This problem has existing solution please refer Print all valid words that are possible using Characters of Array link. We will this problem in python very quickly using Dictionary Data Structure. Approach is very simple :
Traverse list of given strings one by one and convert them into dictionary using Counter(input) method of collections module.Check if all keys of any string lies within given set of characters that means this word is possible to create.
Traverse list of given strings one by one and convert them into dictionary using Counter(input) method of collections module.
Check if all keys of any string lies within given set of characters that means this word is possible to create.
# Function to print words which can be created# using given set of characters      def charCount(word):    dict = {}    for i in word:        dict[i] = dict.get(i, 0) + 1    return dict    def possible_words(lwords, charSet):    for word in lwords:        flag = 1        chars = charCount(word)        for key in chars:            if key not in charSet:                flag = 0            else:                if charSet.count(key) != chars[key]:                    flag = 0        if flag == 1:            print(word)  if __name__ == "__main__":    input = ['goo', 'bat', 'me', 'eat', 'goal', 'boy', 'run']    charSet = ['e', 'o', 'b', 'a', 'm', 'g', 'l']    possible_words(input, charSet)
Output:
go 
me
goal

vijaymaddukuri
Python dictionary-programs
python-dict
Python
Strings
python-dict
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Write a program to reverse an array or string
Reverse a string in Java
Write a program to print all permutations of a given string
C++ Data Types
Longest Common Subsequence | DP-4
How to remove all .pyc files in Python? - GeeksforGeeks

19 Dec, 2021
In this article, we are going to see how to remove all .pyc files in Python.
A *.pyc file is created by the Python interpreter when a *.py file is imported into any other python file. The *.pyc file contains the “compiled bytecode” of the imported module/program so that the “translation” from source code to bytecode can be skipped on subsequent imports of the *.py file. Having a *.pyc file saves the compilation time of converting the python source code to byte code, every time the file is imported. Thus speeding startup a little. But it’s still interpreted. Once the *.pyc file is generated, there is no need for the *.py file, unless the *.py file is modified. In Python 3.2, the compiled files (.pyc) are placed in a __pycache__ subdirectory and are named differently depending on which Python interpreter created them.
Before executing a python program python interpreter checks for the .pyc file. If the file is present, the virtual machine executes it. If not found, it checks for the .py file. If found, compile it to a .pyc file and then the python virtual machine executes it.
while working on a project having the extra .pyc file unnecessarily increases the file size. or to solve any terrible importing error, the .pyc are needed to be removed.
On OS X and Linux find method can be used to find all of the .pyc files, and then use its delete option to delete them. (In windows open windows terminal to use the find method).
The command to find all .pyc files in all folders, starting with the current one is:
find. -name '*.pyc'
If you want to delete all the files found, just add the -delete option:
find.  -name '*.pyc' -delete
Picked
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Indexing in MongoDB

04 Jul, 2022
MongoDB is leading NoSQL database written in C++. It is high scalable and provides high performance and availability. It works on the concept of collections and documents. Collection in MongoDB is group of related documents that are bound together. The collection does not follow any schema which is one of the remarkable feature of MongoDB. 
Indexing in MongoDB : MongoDB uses indexing in order to make the query processing more efficient. If there is no indexing, then the MongoDB must scan every document in the collection and retrieve only those documents that match the query. Indexes are special data structures that stores some information related to the documents such that it becomes easy for MongoDB to find the right data file. The indexes are order by the value of the field specified in the index. 
Creating an Index : MongoDB provides a method called createIndex() that allows user to create an index. 
Syntax –  
db.COLLECTION_NAME.createIndex({KEY:1}) 
The key determines the field on the basis of which you want to create an index and 1 (or -1) determines the order in which these indexes will be arranged(ascending or descending). 
Example –  
db.mycol.createIndex({“age”:1})
{
“createdCollectionAutomatically” : false,
“numIndexesBefore” : 1,
“numIndexesAfter” : 2,
“ok” : 1
} 
The createIndex() method also has a number of optional parameters. These include:  
background (Boolean) 
unique (Boolean) 
name (string) 
sparse (Boolean) 
expireAfterSeconds (integer)
hidden (Boolean) 
storageEngine (Document) 
Drop an index: In order to drop an index, MongoDB provides the dropIndex() method. 
Syntax –  
db.NAME_OF_COLLECTION.dropIndex({KEY:1}) 
The dropIndex() methods can only delete one index at a time. In order to delete (or drop) multiple indexes from the collection, MongoDB provides the dropIndexes() method that takes multiple indexes as its parameters. 
Syntax –  
db.NAME_OF_COLLECTION.dropIndexes({KEY1:1, KEY2, 1}) 
The dropIndex() methods can only delete one index at a time. In order to delete (or drop) multiple indexes from the collection, MongoDB provides the dropIndexes() method that takes multiple indexes as its parameters. 
Get description of all indexes : The getIndexes() method in MongoDB gives a description of all the indexes that exists in the given collection. 
Syntax –  
db.NAME_OF_COLLECTION.getIndexes() 
It will retrieve all the description of the indexes created within the collection. 
sagar0719kumar
khushb99
DBMS
MongoDB
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Relational Model in DBMS
Introduction of Relational Algebra in DBMS
Types of Functional dependencies in DBMS
Difference between Where and Having Clause in SQL
MySQL | Regular expressions (Regexp)
MongoDB Cursor
Upsert in MongoDB
MongoDB - Index Types
Mongoose | findByIdAndUpdate() Function
Upload and Retrieve Image on MongoDB using Mongoose
Grouping Selectors in CSS

The CSS grouping selector is used to select multiple elements and style them together. This reduces the code and extra effort to declare common styles for each element. To group selectors, each selector is separated by a space.
The syntax for CSS grouping selector is as follows −
element, element {
   /*declarations*/
}
The following examples illustrate CSS grouping selector −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
article, p, img {
   display: block;
   margin: auto;
   text-align: center;
   border-bottom: double orange;
}
</style>
</head>
<body>
<article>Demo Text</article>
<p>This is demo text.</p>
<br/>
<img src="https://www.tutorialspoint.com/swing/images/swing.jpg">
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div::after,p::after{
   content: "Demo text";
   margin: 4px;
   box-shadow: inset 0 0 4px darkorange;
}
</style>
</head>
<body>
<div></div>
<p>This is example text.</p>
</body>
</html>
This gives the following output −
numpy.random.choice() in Python

15 Jul, 2020
With the help of choice() method, we can get the random samples of one dimensional array and return the random samples of numpy array.
Syntax : numpy.random.choice(a, size=None, replace=True, p=None)
Parameters:
1) a – 1-D array of numpy having random samples.
2) size – Output shape of random samples of numpy array.
3) replace – Whether the sample is with or without replacement.
4) p – The probability attach with every samples in a. 
Output : Return the numpy array of random samples.
Example #1 :
In this example we can see that by using choice() method, we are able to get the random samples of numpy array, it can generate uniform or non-uniform samples by using this method.
Python3
# import choiceimport numpy as npimport matplotlib.pyplot as plt  # Using choice() methodgfg = np.random.choice(13, 5000)  count, bins, ignored = plt.hist(gfg, 25, density = True)plt.show()
Output :
Example #2 :
Python3
# import choiceimport numpy as npimport matplotlib.pyplot as plt  # Using choice() methodgfg = np.random.choice(5, 1000, p =[0.2, 0.1, 0.3, 0.4, 0])  count, bins, ignored = plt.hist(gfg, 14, density = True)plt.show()
Output :
Python numpy-Random
Python-numpy
Python
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()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
BeautifulSoup – Find tags by CSS class with CSS Selectors

16 Jan, 2022
Prerequisites: Beautifulsoup
Beautifulsoup is a Python library used for web scraping. BeautifulSoup object is provided by Beautiful Soup which is a web scraping framework for Python. Web scraping is the process of extracting data from the website using automated tools to make the process faster. The BeautifulSoup object represents the parsed document as a whole. This powerful python tool can also be used to modify HTML webpages. This article depicts how beautifulsoup can be employed to find tag by CSS class with CSS Selectors. For this, find_all() method of the module is used.
Syntax:
find_all(class_=”class_name”)
Returns tags having a particular CSS class.
Approach:
Import module
Scrap data from a webpage.
Parse the string scraped to HTML.
Use find_all() function to get a list of tag with the given class name.
Print tags.
Example 1:  Finding all tags of a particular CSS class from an HTML file.
Python3
# importing modulefrom bs4 import BeautifulSoup markup = """ <!DOCTYPE><html>  <head><title>Example</title></head>    <body>        <div class="first"> Div with Class first        </div>        <p class="first"> Para with Class first        </p>          <div class="second"> Div with Class second        </div>        <span class="first"> Span with Class first        </span>    </body></html>""" # parsering string to HTMLsoup = BeautifulSoup(markup, 'html.parser') # printing tags with given class namefor i in soup.find_all(class_="first"):    print(i.name)
Output:
div
p
span
Example 2: Finding all tags of a particular CSS class from a URL.
Python3
# importing modulefrom bs4 import BeautifulSoupimport requests URL = "https://www.geeksforgeeks.org/"html = requests.get(URL) # parsering string to HTMLsoup = BeautifulSoup(html.content, "html5lib") # printing tags with given class namefor i in soup.find_all(class_="article--container_content"):    print(i.name)
Output:
div
saurabh1990aror
Picked
Python BeautifulSoup
Python bs4-Exercises
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Python PIL | ImageSequence.Iterator()

02 Aug, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageSequence module contains a wrapper class that lets you iterate over the frames of an image sequence.
ImageSequence.Iterator() This class implements an iterator object that can be used to loop over an image sequence. You can use the [ ] operator to access elements by index. This operator will raise an IndexError if you try to access a nonexistent frame.
Syntax: PIL.ImageSequence.Iterator(im)
Parameters:im – An image object.
Returns: An Image object.
Image Used:
     # importing Image class from PIL package from PIL import Image, ImageSequence  # creating a object im = Image.open(r"C:\Users\System-Pc\Desktop\home.png")index = 1for frame in ImageSequence.Iterator(im):    frame.save("frame % d.png" % index)    index = index + 1  im.getdata()im.show()
Output:
Another Example:Here we use another image .jpg extension.
Image Used:
     # importing Image class from PIL package from PIL import Image, ImageSequence  # creating a object im = Image.open(r"C:\Users\System-Pc\Desktop\tree.jpg")index = 1for frame in ImageSequence.Iterator(im):    frame.save("frame % d.jpg" % index)    index = index + 1  im.getdata()im.show()
Output:
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MoviePy – Inserting Text in the Video

30 Aug, 2020
In this article we will see how we can insert text to a video clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Video is formed by the frames, combination of frames creates a video each frame is an individual image. VideoClip is the base class for all the other video clips in MoviePy. In order to do this we need to have ImageMagick installed else it will not work. Adding text to a video is similar to creating composite video.
In order to do so we have to do the following :1. Import the moviepy module2. Load the video file3. Create a text clip and set its position and duration4. Create a composite video clip using video file and the text clip.5. Show the final video.
Below is the implementation
# Import everything needed to edit video clips from moviepy.editor import *    # loading video dsa gfg intro video clip = VideoFileClip("dsa_geek.mp4")     # clipping of the video  # getting video for only starting 10 seconds clip = clip.subclip(0, 10)     # Reduce the audio volume (volume x 0.8) clip = clip.volumex(0.8)     # Generate a text clip txt_clip = TextClip("GeeksforGeeks", fontsize = 75, color = 'black')     # setting position of text in the center and duration will be 10 seconds txt_clip = txt_clip.set_pos('center').set_duration(10)     # Overlay the text clip on the first video clip video = CompositeVideoClip([clip, txt_clip])     # showing video video.ipython_display(width = 280) 
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# Import everything needed to edit video clips from moviepy.editor import *    # loading video file clipclip = VideoFileClip("geeks.mp4")     # clipping of the video  # getting video for only starting 10 seconds clip = clip.subclip(0, 5)     # Reduce the audio volume (volume x 0.5) clip = clip.volumex(0.5)     # Generate a text clip txt_clip = TextClip("GfG-MoviePy", fontsize = 75, color = 'green')     # setting position of text in the center and duration will be 5 seconds txt_clip = txt_clip.set_pos('bottom').set_duration(5)     # Overlay the text clip on the first video clip video = CompositeVideoClip([clip, txt_clip])     # showing video video.ipython_display(width = 280) 
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Python-MoviePy
Python
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
C program to create hard link and soft link - GeeksforGeeks

30 Nov, 2021
There are two types of links, i.e., a soft link and a hard link to a file. C library has a function link() that creates a new hard link to an existing file. The function symlink() to create a soft link. If the link file/path already exists, it will not be overwritten. Both function link() and symlink() return 0 on success. If any error occurs, then -1 is returned. Otherwise, ‘errno’ (Error Number) is set appropriately.
Soft Link: A soft link (also known as a Symbolic link) acts as a pointer or a reference to the file name. It does not access the data available in the original file. If the earlier file is deleted, the soft link will point to a file that does not exist anymore.
Hard Link: A hard link acts as a copy (mirrored) of the selected file. It accesses the data available in the original file.If the earlier selected file is deleted, the hard link to the file will still contain the data of that file.
Function to create a Hard Link:
L = link(FILE1, FILE2), creates a hard link named FILE2 to an existing FILE1.
where, L is the value returned by the link() function.
Function to create a Soft Link:
sL = symlink(FILE1, FILE2), creates a soft link named FILE2 to an existing FILE1.
where, sL is the value returned by the symlink() function
Program 1: Below is the C program to create a hard link to an existing file:
C
// C program to create an Hard Link// to the existing file#include <stdio.h>#include <stdlib.h>#include <unistd.h>  // Driver Codeint main(int argc, char* argv[]){    // Link function    int l = link(argv[1], argv[2]);      // argv[1] is existing file name    // argv[2] is link file name    if (l == 0) {        printf("Hard Link created"               " succuessfuly");    }      return 0;}
Output:
Program 2: Below is the C program to create a Soft link to an existing file:
C
// C program to create an Soft Link// to the existing file#include <stdio.h>#include <stdlib.h>#include <unistd.h>  // Driver Codeint main(int argc, char* argv[]){    // Symlink function    int sl = symlink(argv[1], argv[2]);      // argv[1] is existing file name    // argv[2] is soft link file name    if (sl == 0) {        printf("Soft Link created"               " succuessfuly");    }      return 0;}
Output:
madeng5555
File Handling
C Language
C Programs
File Handling
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Strings in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
UDP Server-Client implementation in C
Header files in C/C++ and its uses