code-rag-bench/online-tutorials huggingface dataset:
Python - Check for Sublist in List - GeeksforGeeks

16 Feb, 2022
Sometimes, while working with Python Lists, we can have a problem in which we need to check if a particular sublist is contained in an exact sequence in a list. This task can have application in many domains such as school programming and web development. Let’s discuss certain ways in which this task can be performed. 
Input : test_list = [5, 6, 3, 8, 2, 1, 7, 1], sublist = [8, 2, 3] Output : FalseInput : test_list = [5, 6, 3, 8, 2, 3, 7, 1], sublist = [8, 2, 3] Output : True  
Method #1 : Using loop + list slicing The combination of the above functions can be used to solve this problem. In this, we perform the task of checking for sublist by incremental slicing using the list slicing technique. 
Python3
# Python3 code to demonstrate working of# Check for Sublist in List# Using loop + list slicing # initializing listtest_list = [5, 6, 3, 8, 2, 1, 7, 1] # printing original listprint("The original list : " + str(test_list)) # initializing sublistsublist = [8, 2, 1] # Check for Sublist in List# Using loop + list slicingres = Falsefor idx in range(len(test_list) - len(sublist) + 1):        if test_list[idx : idx + len(sublist)] == sublist:            res = True            break         # printing resultprint("Is sublist present in list ? : " + str(res))
The original list : [5, 6, 3, 8, 2, 1, 7, 1]
Is sublist present in list ? : True
 
 Method #2 : Using any() + list slicing + generator expression The combination of the above functions is used to solve this problem. In this, we perform the task of checking for any sublist equating to desired using any(), and list slicing is used to slice incremental list of the desired length. 
Python3
# Python3 code to demonstrate working of# Check for Sublist in List# Using any() + list slicing + generator expression # initializing listtest_list = [5, 6, 3, 8, 2, 1, 7, 1] # printing original listprint("The original list : " + str(test_list)) # initializing sublistsublist = [8, 2, 1] # Check for Sublist in List# Using any() + list slicing + generator expressionres = any(test_list[idx : idx + len(sublist)] == sublist        for idx in range(len(test_list) - len(sublist) + 1))         # printing resultprint("Is sublist present in list ? : " + str(res))
The original list : [5, 6, 3, 8, 2, 1, 7, 1]
Is sublist present in list ? : True
 
reenadevi98412200
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
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?
CSS | 3 Digit Hex Color - GeeksforGeeks

23 Aug, 2019
The 3 Digit Hex Color code is similar to 6 Digit Hex Color it’s shorthand for 6 Digit Hex Color. In 3 Digit Hex Color shrink into single character those have twins in 6 Digit Hex Color the effect will be same but reduce the color variant. The 3 Digit Hex Color contains 3 character followed by hash(#) like #RGB. The #RGB define Red, Green and Blue component.Syntax:
#RGB

Example 1:
<!DOCTYPE html><html>    <head>    <title>CSS 3 Digit Hex Color</title>    <style>        body {            background-color: #666600;        }                    h1 {            color: green;        }                    article {            background-color: #FFF;            border: 5px solid green;            margin: 15px;            text-align: center;        }    </style></head>    <body>    <article>        <h1>GeeksforGeeks</h1>    </article></body>    </html>
Output:Example 2:
<!DOCTYPE html><html>   <head>    <title>CSS 3 Digit Hex Color</title>       <style>        body {            background-image: url('https://media.geeksforgeeks.org/wp-content/uploads/20190806202057/Screenshot-from-2019-08-02-10-51-372.png');            background-attachment: fixed;            background-size: cover;        }                   h2 {            color: green;        }                   article {            background-color: #FFF;            border: 2px solid green;            background-position: center center;            text-align: center;        }    </style></head>   <body>    <article>        <h2>GeeksforGeeks</h2>    </article></body>   </html>
Output:
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
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 ?
Difference between var, let and const keywords in JavaScript
C program to invert (making negative) an image content in PGM format - GeeksforGeeks

06 Jan, 2022
Given an image in PGM format and the task is to invert the image color (making negative) content in PGM format. Prerequisite: c-program-to-write-an-image-in-pgm-formatPGM image represents a gray scale graphic image. PGM is the abbreviation of Portable Gray Map. This image file contains one or more PGM images file. Significance of data chunks: The data which are used to create PGM image listed below:  
P2 is the type of image that is grey image
4 4 is the image dimension
255 is the maximum grey level
Since, the image data are stored in matrix format and each row indicates the image row and the value indicates the grey level of corresponding pixel. The maximum value (255) is used for white and minimum value (0) is used for black.
Example:  
P2
4 4
255
255 0   255 0
0   255 0   255
100 200 150 100
50  150 200 0
The input image looks like:  
How to invert the image data? Invert the grey image means change the grey level of an image using (255 – grey level) i.e. if grey level of a pixel is 150 then grey level in negative image is (255 – 150) = 105. It means 255 will changes with 0 and 0 will change with 255. It is changing of proportion of black and white present in grey. Example:  
P2
4 4
255
0   255 0   255
255 0   255 0
155 55  105 155
205  105 55 255
The output image looks like:  
 
C
#include<stdio.h>#include<process.h>#include<stdlib.h>void main(){    int i, j, temp = 0;    int width = 4, height = 4;         // Suppose the 2D Array to be converted to Image    // is as given below    int img[10][10] = {        {255, 0, 255, 0},        {0, 255, 0, 255},        {100, 200, 150, 100},        {50, 150, 200, 0}    };         // file pointer to store image file    FILE *pgmfile, *negative_pgmfile;     // Open an image file    pgmfile = fopen("img.pgm", "wb");         // Open an negative image file    negative_pgmfile = fopen("neg_img.pgm", "wb");         fprintf(pgmfile, "P2 \n %d %d \n 255 \n", width, height);    fprintf(negative_pgmfile, "P2 \n %d %d \n 255 \n", width, height);         // Create PGM image using pixel value    for(i = 0; i < height; i++) {        for(j = 0; j < width; j++)            fprintf(pgmfile, "%d ", img[i][j]);        fprintf(pgmfile, "\n");    }         // Create negative PGM image using pixel value    for(i = 0; i < height; i++) {        for(j = 0; j < width; j++)            fprintf(negative_pgmfile, "%d ", (255 - img[i][j]));        fprintf(negative_pgmfile, "\n");    }         fclose(pgmfile);    fclose(negative_pgmfile);}
Output: Original Image  
Negative (Invert) Image  
 
gulshankumarar231
Image-Processing
C Language
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Command line arguments in C/C++
Different methods to reverse a string in C/C++
Strings in C
UDP Server-Client implementation in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
Header files in C/C++ and its uses
Dart Programming - remainder Method

It returns the truncated remainder after dividing the two numbers.
Number.remainder(x)

x − represents a divisor
x − represents a divisor
Returns the remainder of a division.
void main() { 
   var a = 10; 
   var b = 17; 
   
   print(a.remainder(2)); 
   print(b.remainder(2)); 
}
It will produce the following output −.
0 
1


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.6 - Show Python

#The try block will raise an error when trying to write to a read-only file:
​
try:
  f = open("demofile.txt")
  try:
    f.write("Lorum Ipsum")
  except:
    print("Something went wrong when writing to the file")
How I can convert a Python Tuple into Dictionary?

A dictionary object can be constructed using dict() function. This function takes a tuple of tuples as argument. Each tuple contains key value pair.
>>> t=((1,'a'), (2,'b'))
>>> dict(t)
{1: 'a', 2: 'b'}
If you want to interchange key and value,
>>> t=((1,'a'), (2,'b'))
>>> dict((y, x) for x, y in t)
{'a': 1, 'b': 2}
Get a list of Foreign Key constraints in MySQL

Let’s say we have a database “business” with number of tables. If you want to show only foreign key constraints, then use the following query −
mysql> select *
   −> from information_schema.referential_constraints
   −> where constraint_schema = 'business';
The following is the output displaying only foreign key constraints −
+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME          | UNIQUE_CONSTRAINT_CATALOG | UNIQUE_CONSTRAINT_SCHEMA | UNIQUE_CONSTRAINT_NAME | MATCH_OPTION | UPDATE_RULE | DELETE_RULE | TABLE_NAME       | REFERENCED_TABLE_NAME |
+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
| def                | business          | ConstChild               | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | childdemo         | parentdemo |
| def                | business          | ConstFK                  | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | tblf | tblp |
| def                | business          | constFKPK                | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | foreigntable      | primarytable1 |
| def                | business          | FKConst                  | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | foreigntabledemo | primarytabledemo |
| def                | business          | primarytable1demo_ibfk_1 | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION | primarytable1demo| foreigntable1 |
| def                | business          | StudCollegeConst         | def                       | business                 | PRIMARY                | NONE         | NO ACTION   | NO ACTION   | studentenrollment| college |
+--------------------+-------------------+--------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+-------------------+-----------------------+
6 rows in set (0.07 sec)
How to create a 4-column layout grid with CSS?

To create a 4-column layout grid 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;
   }
   * {
      box-sizing: border-box;
   }
   .first, .second, .third, .fourth {
      float: left;
      width: 25%;
      color: white;
      padding: 10px;
      height: 500px;
      text-align: center;
   }
   .first {
      background-color: tomato;
   }
   .second {
      background-color: teal;
   }
   .third {
      background-color: rgb(166, 71, 255);
   }
   .fourth {
      background-color: rgb(255, 71, 194);
   }
   .container:after {
      clear: both;
   }
</style>
</head>
<body>
<h1 style="text-align: center;">Four Column grid example</h1>
<div class="container">
<div class="first">
<h1>Some text on the first div</h1>
</div>
<div class="second">
<h1>Some text on the second div</h1>
</div>
<div class="third">
<h1>Some text on the third div</h1>
</div>
<div class="fourth">
<h1>Some text on the fourth div</h1>
</div>
</div>
</body>
</html>
The above code will produce the following output −
SAP Universe Designer - Aggregate Awareness

In UDT, you have an option to run query against the aggregated tables in database. A condition can be set, and that query will run against aggregated tables for query optimization. This method of using aggregated tables is known as aggregate awareness.
To use aggregate awareness in Universe, you can use a function called @Aggregate_Aware in “Select” statement for an object that directs a query to be run against aggregate tables rather than a table containing non aggregated data.
To use aggregate awareness in a Universe, you need to arrange objects by aggregation level and objects are built using @aggregate_awareness function. To build aggregated aware objects, you need to first identify the objects: measure or dimension objects. You need to find out all possible combinations of aggregate objects in all tables and then arrange them in aggregate level order.
For example −
AAYEAR.Profit is the highest level of aggregation.
AAQTR.Profit is the next level.
AAMONTH.Profit is the lowest level of aggregation.
Using @aggregate_aware function directs an object to query all aggregate tables as its parameters. You can see an object using @aggregate_aware function in “Select” statement −
The syntax to be used for aggregate_aware function is as follows −
@Aggregate_Aware(sum(agg_table_1), ... sum(agg_table_n))

Pass the names of all aggregated tables as arguments. Agg_table_1 is aggregate with highest level of aggregation and agg_table_n is aggregate with lowest level of aggregation.
Open edit properties dialog box for the object → Click “>>” button next to the dialog box.
In the "Edit Select Statement" dialog box, you need to click at the beginning of the SELECT statement.
Alternately, click anywhere in the select box if the object does not have a SELECT statement.
You can see @aggregate_aware function under list of functions on right side. As per description of this function: “@Aggregate_Aware(sum(aggregate table1),...,sum(aggregate tableN)) Defines a measure object using precalculated aggregate tables”.

    25 Lectures 
     6 hours 

 Sanjo Thomas

    26 Lectures 
     2 hours 

 Neha Gupta

    30 Lectures 
     2.5 hours 

 Sumit Agarwal

    30 Lectures 
     4 hours 

 Sumit Agarwal

    14 Lectures 
     1.5 hours 

 Neha Malik

    13 Lectures 
     1.5 hours 

 Neha Malik
 Print
 Add Notes
 Bookmark this page
numpy.setdiff1d() function in Python

17 May, 2020
numpy.setdiff1d() function find the set difference of two arrays and return the unique values in arr1 that are not in arr2.
Syntax : numpy.setdiff1d(arr1, arr2, assume_unique = False)
Parameters :arr1 : [array_like] Input array.arr2 : [array_like] Input comparison array.assume_unique : [bool] If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False.
Return : [ndarray] 1D array of values in arr1 that are not in arr2. The result is sorted when assume_unique = False, but otherwise only sorted if the input is sorted.
Code #1 :
# Python program explaining# numpy.setdiff1d() function    # importing numpy as geek import numpy as geek    arr1 = [5, 6, 2, 3, 4]arr2 = [1, 2, 3]   gfg = geek.setdiff1d(arr1, arr2)   print (gfg)
Output :
[4 5 6]

 Code #2 :
# Python program explaining# numpy.setdiff1d() function    # importing numpy as geek import numpy as geek    arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]arr2 = [1, 3, 5, 7, 9, 11, 13, 15]   gfg = geek.setdiff1d(arr1, arr2)   print (gfg)
Output :
[2 4 6 8]

Python numpy-arrayManipulation
Python-numpy
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 | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Python OpenCV | cv2.imread() method

02 Aug, 2019
OpenCV-Python is a library of Python bindings designed to solve computer vision problems.cv2.imread() method loads an image from the specified file. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format) then this method returns an empty matrix.
Syntax: cv2.imread(path, flag)
Parameters:path: A string representing the path of the image to be read.flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR
Return Value: This method returns an image that is loaded from the specified file.
Note: The image should be in the working directory or a full path of image should be given.
All three types of flags are described below:
cv2.IMREAD_COLOR: It specifies to load a color image. Any transparency of image will be neglected. It is the default flag. Alternatively, we can pass integer value 1 for this flag.cv2.IMREAD_GRAYSCALE: It specifies to load an image in grayscale mode. Alternatively, we can pass integer value 0 for this flag.cv2.IMREAD_UNCHANGED: It specifies to load an image as such including alpha channel. Alternatively, we can pass integer value -1 for this flag.
Image used for all the below examples:
Example #1: Using default flag
# Python program to explain cv2.imread() method  # importing cv2 import cv2  # pathpath = r'C:\Users\Rajnish\Desktop\geeksforgeeks.png'  # Using cv2.imread() methodimg = cv2.imread(path)  # Displaying the imagecv2.imshow('image', img)
Output:
Example #2:Loading an image in grayscale mode
# Python program to explain cv2.imread() method  # importing cv2 import cv2  # pathpath = r'C:\Users\Rajnish\Desktop\geeksforgeeks.png'  # Using cv2.imread() method# Using 0 to read image in grayscale modeimg = cv2.imread(path, 0)  # Displaying the imagecv2.imshow('image', img)
Output:
OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Convert integer to string in Python
Python | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
How CSS transition work with linear gradient background button?

22 May, 2020
In CSS, you can smoothly make transitions between two or more colors. CSS has two types of gradients:
Linear gradient: It goes down/up/left/right/diagonally and makes smooth transitions of colors. To make a linear transition you first have to choose two color stops. Color stops are the color among which you want to make the transitions. You can also select a starting point and a direction(an angle) for the transition.background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
Radial gradient: It is defined by the center. Here also you have to specify at least two color spots.
Syntax:
background-image: radial-gradient(shape size at position, 
start-color, ...);
Example:
<!DOCTYPE html><html>    <head>        <title>            Transition work with linear gradient            background button        </title>        <style>            button {                background-image:                 linear-gradient(to bottom right, green, white);            }            button:hover {                background-image:                 linear-gradient(to bottom right, green, yellow);            }                          h1 {                color: green;            }        </style>    </head>    <body>        <center>            <h1>GeeksforGeeks</h1>            <b>Hover over the bytton</b>            <br>            <br>            <button>Click me</button>        </center>    </body></html>
Output:
CSS-Misc
HTML-Misc
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Form validation using jQuery
Design a web page using HTML and CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
HTTP headers | Content-Type
MongoDB OR operator ( $or )

11 Sep, 2021
MongoDB provides different types of logical query operators and $or operator is one of them. This operator is used to perform logical OR operation on the array of two or more expressions and select or retrieve only those documents that match at least one of the given expression in the array. 
You can use this operator in methods like find(), update(), etc. according to your requirements.
You can also use this operator with text queries, GeoSpatial queries, and sort operations.
When MongoDB evaluating the clauses in the $or expression, it performs a collection scan. Or if all the clauses in $or expression are supported by indexes, then MongoDB performs index scans.
You can also nest $or operation.
Syntax:  
{ $or: [ { Expression1 }, { Expression2 }, ..., { ExpressionN } ] }
In the following examples, we are working with:
Database: GeeksforGeeks Collection: contributor Document: three documents that contain the details of the contributors in the form of field-value pairs.
In this example, we are retrieving only those employee’s documents whose branch is ECE or joiningYear is 2017. 
Python3
db.contributor.find({$or: [{branch: "ECE"},                     {joiningYear: 2017}]}).pretty()
In this example, we are retrieving only those employee’s documents whose age is 24 or state is Delhi. 
Python3
db.contributor.find({$or: [{"personal.age": 24},                     {"personal.state": "Delhi"}]}).pretty()
In this example, we are retrieving only those employee’s documents that at least match one of value in the given array. 
Python3
db.contributor.find({$or: [{language: {$in: ["Java", "C"]}}]}).pretty()
adnanirshad158
MongoDB
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ConcurrentLinkedQueue isEmpty() method in Java - GeeksforGeeks

26 Nov, 2018
The isEmpty() method of ConcurrentLinkedQueue is used to check if this queue is empty or not. It returns true if ConcurrentLinkedQueue contains zero number of elements means if the ConcurrentLinkedQueue is empty.
Syntax:
public boolean isEmpty()
Returns: This method returns true if this ConcurrentLinkedQueue contains zero number of elements.
Below programs illustrate isEmpty() method of ConcurrentLinkedQueue:
Example 1:
// Java Program Demonstrate isEmpty()// method of ConcurrentLinkedQueue  import java.util.concurrent.*;  public class GFG {    public static void main(String[] args)    {          // create an ConcurrentLinkedQueue        ConcurrentLinkedQueue<String>            queue = new ConcurrentLinkedQueue<String>();          // Add String to queue        queue.add("Aman");        queue.add("Amar");        queue.add("Sanjeet");        queue.add("Rabi");          // Displaying the existing ConcurrentLinkedQueue        System.out.println("ConcurrentLinkedQueue: " + queue);          // check whether queue isEmpty or not        boolean response1 = queue.isEmpty();          // print after applying isEmpty method        System.out.println("Is Queue empty: " + response1);    }}
ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi]
Is Queue empty: false

Example 2:
// Java Program Demonstrate isEmpty()// method of ConcurrentLinkedQueue  import java.util.concurrent.*;  public class GFG {    public static void main(String[] args)    {          // create an ConcurrentLinkedQueue        ConcurrentLinkedQueue<Integer>            queue = new ConcurrentLinkedQueue<Integer>();          // Displaying the existing ConcurrentLinkedQueue        System.out.println("ConcurrentLinkedQueue: " + queue);          // check whether queue is Empty        boolean response1 = queue.isEmpty();          // print after applying isEmpty method        System.out.println("Is queue empty  : " + response1);    }}
ConcurrentLinkedQueue: []
Is queue empty  : true

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html#isEmpty–
Java - util package
java-basics
Java-Collections
Java-ConcurrentLinkedQueue
Java-Functions
java-queue
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Different ways of Reading a text file in Java
Stream In Java
Constructors in Java
Generics in Java
Exceptions in Java
Functional Interfaces in Java
Comparator Interface in Java with Examples
Commonly Asked Java Programming Interview Questions | Set 2
HashMap get() Method in Java
Strings in Java
HTML - <select> Tag

The HTML <select> tag is used within a form for defining a select list.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML select Tag</title>
   </head>

   <body>
      <form action = "/cgi-bin/dropdown.cgi" method = "post">
         
         <select name = "dropdown">
            <option value = "Data Structures" selected>Data Structures</option>
            <option value = "Data Mining">Data Mining</option>
         </select>
         
         <input type = "submit" value = "Submit" />
      </form>
   </body>

</html>
This will produce the following result −
This tag supports all the global attributes described in − HTML Attribute Reference
The HTML <select> tag also supports the following additional attributes −
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
How to exclude a specific row from a table in MySQL?

Use <> i.e. not equal in MySQL to exclude a specific row from a table. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> FirstName varchar(100)
   -> );
Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1,'John');
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable values(2,'Chris');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable values(3,'Robert');
Query OK, 1 row affected (0.26 sec)

mysql> insert into DemoTable values(4,'David');
Query OK, 1 row affected (0.13 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-----------+
| Id   | FirstName |
+------+-----------+
|    1 | John      |
|    2 | Chris     |
|    3 | Robert    |
|    4 | David     |
+------+-----------+
4 rows in set (0.00 sec)
Here is the query to exclude a specific row from the table −
mysql> select Id,FirstName from DemoTable where Id <> 2;
This will produce the following output −
+------+-----------+
| Id   | FirstName |
+------+-----------+
| 1    | John      |
| 3    | Robert    |
| 4    | David     |
+------+-----------+
3 rows in set (0.00 sec)
Redis - Security

Redis database can be secured, such that any client making a connection needs to authenticate before executing a command. To secure Redis, you need to set the password in the config file.
Following example shows the steps to secure your Redis instance.
127.0.0.1:6379> CONFIG get requirepass 
1) "requirepass" 
2) "" 

By default, this property is blank, which means no password is set for this instance. You can change this property by executing the following command.
127.0.0.1:6379> CONFIG set requirepass "tutorialspoint" 
OK 
127.0.0.1:6379> CONFIG get requirepass 
1) "requirepass" 
2) "tutorialspoint" 

After setting the password, if any client runs the command without authentication, then (error) NOAUTH Authentication required. error will return. Hence, the client needs to use AUTH command to authenticate himself.
Following is the basic syntax of AUTH command.
127.0.0.1:6379> AUTH password 

127.0.0.1:6379> AUTH "tutorialspoint" 
OK 
127.0.0.1:6379> SET mykey "Test value" 
OK 
127.0.0.1:6379> GET mykey 
"Test value"


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
Inline virtual function in C++

Virtual functions in C++ use to create a list of base class pointers and call methods of any of the derived classes without even knowing kind of derived class object. Virtual functions are resolved late, at the runtime.
The main use of the virtual function is to achieve Runtime Polymorphism. The inline functions are used to increase the efficiency of the code. The code of inline function gets substituted at the point of an inline function call at compile time, whenever the inline function is called.
Whenever a virtual function is called using base class reference or pointer it cannot be inlined, but whenever called using the object without reference or pointer of that class, can be inlined because the compiler knows the exact class of the object at compile time.
 Live Demo
#include<iostream>
using namespace std;
class B {
   public:
      virtual void s() {
         cout<<" In Base \n";
      }
};

class D: public B {
   public:
      void s() {
         cout<<"In Derived \n";
      }
};

int main(void) {
   B b;
   D d; // An object of class D
   B *bptr = &d;// A pointer of type B* pointing to d
   b.s();//Can be inlined as s() is called through object of class
   bptr->s();// prints"D::s() called"
   //cannot be inlined, as virtualfunction is called through pointer.
   return 0;
}
In Base
In Derived
Delete N nodes after M nodes of a linked list in C++ program

In this tutorial, we are going to learn how to delete N nodes after M nodes in a linked list.
Let's see the steps to solve the problem.
Write a struct Node for the linked list node.
Write a struct Node for the linked list node.
Initialize the linked list with the dummy data.
Initialize the linked list with the dummy data.
Write a function to delete N nodes after M nodes.Initialize a pointer with the head pointer.Iterate till the end of the linked list.Move the pointer to the next node until M nodes.Delete the N nodesMove the pointer to the next node
Write a function to delete N nodes after M nodes.
Initialize a pointer with the head pointer.
Initialize a pointer with the head pointer.
Iterate till the end of the linked list.
Iterate till the end of the linked list.
Move the pointer to the next node until M nodes.
Move the pointer to the next node until M nodes.
Delete the N nodes
Delete the N nodes
Move the pointer to the next node
Move the pointer to the next node
Print the linked list
Print the linked list
Let's see the code.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
struct Node {
   int data;
   Node *next;
};
void insertNode(Node ** head_ref, int new_data) {
   Node* new_node = new Node();
   new_node->data = new_data;
   new_node->next = (*head_ref);
   *head_ref = new_node;
}
void printLinkedList(Node *head) {
   Node *temp = head;
   while (temp != NULL) {
      cout<< temp->data << " -> ";
      temp = temp->next;
   }
   cout << "Null" << endl;
}
void deleteNNodesAfterMNodes(Node *head, int M, int N) {
   Node *current = head, *temp;
   int count;
   while (current) {
      // skip M nodes
      for (count = 1; count < M && current!= NULL; count++) {
         current = current->next;
      }
      // end of the linked list
      if (current == NULL) {
         return;
      }
      // deleting N nodes after M nodes
      temp = current->next;
      for (count = 1; count <= N && temp != NULL; count++) {
         Node *deletingNode = temp;
         temp = temp->next;
         free(deletingNode);
      }
      current->next = temp;
      current = temp;
   }
}
int main() {
   Node* head = NULL;
   int M = 1, N = 2;
   insertNode(&head, 1);
   insertNode(&head, 2);
   insertNode(&head, 3);
   insertNode(&head, 4);
   insertNode(&head, 5);
   insertNode(&head, 6);
   insertNode(&head, 7);
   insertNode(&head, 8);
   insertNode(&head, 9);
   cout << "Linked list before deletion: ";
   printLinkedList(head);
   deleteNNodesAfterMNodes(head, M, N);
   cout << "Linked list after deletion: ";
   printLinkedList(head);
   return 0;
}
If you run the above code, then you will get the following result.
Linked list before deletion: 9 -> 8 -> 7 -> 6 -> 5 -> 4 -> 3 -> 2 -> 1 -> Null
Linked list after deletion: 9 -> 6 -> 3 -> Null
If you have any queries in the tutorial, mention them in the comment section.
Align flex items around on different screen sizes in Bootstrap

To align flex items around on different screen sizes, use the justify-content-*-around class.
You can achieve the following result that justifies content on small and medium screen sizes −
To implement the justify-content-*-around class in Bootstrap −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>

  <div class="container mt-3">
    <p>Default</p>
    <div class="d-flex justify-content-around bg-warning mb-5">
      <div class="p-2 bg-danger">ANS 1</div>
      <div class="p-2 bg-info">ANS 2</div>
      <div class="p-2 bg-secondary">ANS 3</div>
    </div>
    <p>Small Screen Size</p>
    <div class="d-flex justify-content-sm-around bg-warning mb-5">
      <div class="p-2 bg-danger">ANS 1</div>
      <div class="p-2 bg-info">ANS 2</div>
      <div class="p-2 bg-secondary">ANS 3</div>
    </div>
    <p>Medium Screen Size</p>
    <div class="d-flex justify-content-md-around bg-warning mb-5">
      <div class="p-2 bg-danger">ANS 1</div>
      <div class="p-2 bg-info">ANS 2</div>
      <div class="p-2 bg-secondary">ANS 3</div>
    </div>
    <p>Large Screen Size</p>
    <div class="d-flex justify-content-lg-around bg-warning mb-5">
      <div class="p-2 bg-danger">ANS 1</div>
      <div class="p-2 bg-info">ANS 2</div>
      <div class="p-2 bg-secondary">ANS 3</div>
    </div>
  </div>

</body>
</html>
Rexx - Loops

So far we have seen statements which have been executed one after the other in a sequential manner. Additionally, statements are provided in Rexx to alter the flow of control in a program’s logic. They are then classified into a flow of control statements which we will study in detail.
A loop statement allows us to execute a statement or group of statements multiple times. The following illustration is the general form of a loop statement in most of the programming languages.
Let us discuss various loops supported by Rexx.
The do loop is used to execute a number of statements for a certain number of times. The number of times that the statement needs to be executed is determined by the value passed to the do loop.
The do-while statement is used to simulate the simple while loop which is present in other programming languages.
The do-until loop is a slight variation of the do while loop. This loop varies in the fact that is exits when the condition being evaluated is false.
The do loops can be catered to carry out a controlled repetition of statements.
The general syntax of this sort of statement is as follows.
do index = start [to limit] [by increment] [for count] 
statement #1 
statement #2 
end 

The difference in this statement is that there is an index which is used to control the number of times the loop is executed. Secondly, there are parameters which state the value which the index should start with, where it should end and what is the increment value.
Let’s check out the flow diagram of this loop −
From the above diagram you can clearly see that the loop is executed based on the index value and how the index value is incremented.
The following program is an example of the controlled repetition statement.
/* Main program */ 
do i = 0 to 5 by 2 
   say "hello" 
end 
In the above program, the value of the count i is set to 0 first. Then it is incremented in counts of 2 till the value is not greater than 5.
The output of the above code will be −
hello 
hello 
hello 

 Print
 Add Notes
 Bookmark this page
C++ Program to Implement Insertion Sort

This sorting technique is similar with the card sorting technique, in other words we sort cards using insertion sort mechanism. For this technique, we pick up one element from the data set and shift the data elements to make a place to insert back the picked up element into the data set.
Time Complexity: O(n) for best case, O(n2) for average and worst case
Time Complexity: O(n) for best case, O(n2) for average and worst case
Space Complexity: O(1)
Space Complexity: O(1)
Input − The unsorted list: 9 45 23 71 80 55
Output − Array after Sorting: 9 23 45 55 71 80
Input: An array of data, and the total number in the array
Output: The sorted Array
Begin
   for i := 1 to size-1 do
      key := array[i]
      j := i
      while j > 0 AND array[j-1] > key do
         array[j] := array[j-1];
         j := j – 1
      done
      array[j] := key
   done
End
#include<iostream>
using namespace std;
void display(int *array, int size) {
   for(int i = 0; i<size; i++)
      cout << array[i] << " ";
   cout << endl;
}
void insertionSort(int *array, int size) {
   int key, j;
   for(int i = 1; i<size; i++) {
      key = array[i];//take value
      j = i;
      while(j > 0 && array[j-1]>key) {
         array[j] = array[j-1];
         j--;
      }
      array[j] = key;   //insert in right place
   }
}
int main() {
   int n;
   cout << "Enter the number of elements: ";
   cin >> n;
   int arr[n];    //create an array with given number of elements
   cout << "Enter elements:" << endl;
   for(int i = 0; i<n; i++) {
      cin >> arr[i];
   }
   cout << "Array before Sorting: ";
   display(arr, n);
   insertionSort(arr, n);
   cout << "Array after Sorting: ";
   display(arr, n);
}
Enter the number of elements: 6
Enter elements:
9 45 23 71 80 55
Array before Sorting: 9 45 23 71 80 55
Array after Sorting: 9 23 45 55 71 80
Can we combine GridLayout and BorderLayout in Java?

Yes, we can do that with Java Swings as shown below. Here, we have a panel set with GridLayout and another panel with BorderLayout −
JPanel panelGrid = new JPanel(new GridLayout(10, 5, 10, 10));
panelGrid.add(new JCheckBox("Demo CheckBox1"));
panelGrid.add(new JCheckBox("Demo CheckBox2"));
panelGrid.add(btnAPanel);
panelGrid.add(btnBPanel);
panelGrid.add(btnCPanel);
panelGrid.add(btnDPanel);
JPanel panelBrdLayout = new JPanel(new BorderLayout());
panelBrdLayout.add(panelGrid, BorderLayout.NORTH);
The following is an example to combine GridLayout and BorderLayout −
package my;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class SwingDemo {
   public static void main(String[] args) {
      JButton btnA = new JButton("Button1");
      JButton btnB = new JButton("Button2");
      JButton btnC = new JButton("Button3");
      JButton btnD = new JButton("Button4");
      btnA.setPreferredSize(new Dimension(150, 20));
      btnB.setPreferredSize(new Dimension(150, 20));
      btnC.setPreferredSize(new Dimension(150, 20));
      btnD.setPreferredSize(new Dimension(150, 20));
      JPanel btnAPanel = new JPanel();
      JPanel btnBPanel = new JPanel();
      JPanel btnCPanel = new JPanel();
      JPanel btnDPanel = new JPanel();
      btnAPanel.add(btnA);
      btnBPanel.add(btnB);
      btnCPanel.add(btnC);
      btnDPanel.add(btnD);
      JPanel panelGrid = new JPanel(new GridLayout(10, 5, 10, 10));
      panelGrid.add(new JCheckBox("Demo CheckBox1"));
      panelGrid.add(new JCheckBox("Demo CheckBox2"));
      panelGrid.add(btnAPanel);
      panelGrid.add(btnBPanel);
      panelGrid.add(btnCPanel);
      panelGrid.add(btnDPanel);
      JPanel panelBrdLayout = new JPanel(new BorderLayout());
      panelBrdLayout.add(panelGrid, BorderLayout.NORTH);
      panelBrdLayout.setPreferredSize(new Dimension(550, 300));
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(panelBrdLayout);
      frame.setSize(550, 300);
      frame.setVisible(true);
   }
}
How to create table footer in HTML?

The HTML <tfoot> tag is used in adding a footer to a table. The tfoot tag is used in conjunction with the tbody tag and the thead tag in determining each part of the table (header, footer, body).
The following are the attributes −
You can try to run the following code to create a table footer in HTML −
<!DOCTYPE html>
<html>
   <head>
      <style>
         table, td {
            border: 1px solid black;
         }
      </style>
   </head>
   
   <body>
      <table style = "width:100%">
         <thead>
            <tr>
               <td colspan = "4">This is the head of the table</td>
            </tr>
         </thead>
         <tfoot>
            <tr>
               <td colspan = "4">This is the footer of the table</td>
            </tr>
         </tfoot>
         <tbody>
            <tr>
            <td>Cell 1</td>
            <td>Cell 2</td>
            <td>Cell 3</td>
            <td>Cell 4</td>
            </tr>

            <tr>
               ...more rows here containing four cells...
            </tr>
         </tbody>
         
         <tbody>
            <tr>
               <td>Cell 1</td>
               <td>Cell 2</td>
               <td>Cell 3</td>
               <td>Cell 4</td>
            </tr>
           
            <tr>
               ...more rows here containing four cells...
            </tr>
         </tbody>
      </table>
   </body>
</html>
How to display star/asterisk sign (*) inside a base R plot?

To display characters inside a base R plot we can simply use text function with expression and if we want to display an asterisk then we need to put the asterisk within double quotes. For example, if we want to display three stars then only expression(paste("***"))) should be used. Check out the below examples to understand how it works.
> plot(1:10,type="n")
> text(8,9,expression(paste(Sig.^"***")))
> plot(1:10,type="n")
> text(5,6,expression(paste(Less_Sig.^"**")))
> plot(1:10,type="n")
> text(2,3,expression(paste(Very_Less_Sig.^"**")))
imagecreate() function in PHP

The imagecreate() function is used to create a new image. It is preferred to use imagecreatetruecolor() to create an image instead of imagecreate(). This is because the image processing occurs on the highest quality image possible which can be created using imagecreatetruecolor().
imagecreate( $width, $height )
width: The width of image
width: The width of image
height: The height of image
height: The height of image
The imagecreate() function returns an image resource identifier on success or FALSE on errors.
The following is an example:
<?php
   $img = imagecreate(500, 300);
   $bgcolor = imagecolorallocate($img, 150, 200, 180);
   $fontcolor = imagecolorallocate($img, 120, 60, 200);
   imagestring($img, 12, 150, 120, "Demo Text1", $fontcolor);
   imagestring($img, 3, 150, 100, "Demo Text2", $fontcolor);
   imagestring($img, 9, 150, 80, "Demo Text3", $fontcolor);
   imagestring($img, 12, 150, 60, "Demo Text4", $fontcolor);
   header("Content-Type: image/png");
   imagepng($img);
   imagedestroy($img);
?>
The following is the output:
C Program to check Strong Number

Given a number ‘n’ we have to check whether the number given is Strong Number or not.
Strong number is a number whose sum of all digits’ factorial is equal to the number ‘n’. Factorial implies when we find the product of all the numbers below that number including that number and is denoted by ! (Exclamation sign), For example: 4! = 4x3x2x1 = 24.
So, to find a number whether its strong number, we have to pick every digit of the number like the number is 145 then we have to pick 1, 4 and 5 now we will find factorial of each number i.e, 1! = 1, 4! = 24, 5! = 120.
Now we will sum up 1 + 24 + 120 so we get 145, that is exactly same as the input given, So we can say that the number is strong number.
Input: n = 124
Output: No it is not a strong number
Explanation: 1! + 2! + 4! = 27 which is not equal to n i.e, 124
Input: n = 145
Output: Yes it is a strong number
Explanation: 1! + 4! + 5! = 145
Approach used below is as follows to solve the problem −
We will −
Take each digit starting from the unit place and find its factorial.
We will add those factorials of each number.
Compare the result with the original number, If they are equal then, the number is strong number; else the number is not a strong number.
START
In Function int factorial(int r)
   Step1 -> Initialize int fact and set as 1
   Step2-> Loop while r>1
      Set fact as fact * r
      Decremnet r by 1
   End Loop
   Step 3-> Return fact
   End Function factorial
In Function int check(int n)
   Step 1-> Initialize int temp, rem and result, set result as 0
   Step 2-> Set temp as n
   Step 3-> Loop while temp
      Set rem as temp % 10
      Set result as result + factorial(rem)
      Set temp as temp/10
   End loop
   Step 4-> If result == n then,
      Return 1
   Step 5-> Else
   Return 0
   End function check
In main(int argc, char const *argv[])
   Step 1-> Initialise and set n as 145
   Step 2->If check(n) is valid then,
      Print "Yes it is a strong number”
   Step 3-> Else
      Print "no it is not a strong number”
STOP
 Live Demo
#include <stdio.h>
int factorial(int r) {
   int fact = 1;
   while(r>1) {
      fact = fact * r;
      r--;
   }
   return fact;
}
int check(int n) {
   int temp, rem, result = 0;
   temp = n;
   while(temp) {
      rem = temp % 10;
      result = result + factorial(rem);
      temp = temp/10;
   }
   if (result == n)
      return 1;
   else
      return 0;
}
int main(int argc, char const *argv[]) {
   int n = 145;
   if (check(n))
      printf("Yes it is a strong number\n");
   else
      printf("no it is not a strong number\n");
   return 0;
}
If run the above code it will generate the following output −
Yes it is a strong number