code-rag-bench/online-tutorials huggingface dataset:
HTML5 - Attributes

As explained in the previous chapter, elements may contain attributes that are used to set various properties of an element.
Some attributes are defined globally and can be used on any element, while others are defined for specific elements only. All attributes have a name and a value and look like as shown below in the example.
Following is the example of an HTML5 attributes which illustrates how to mark up a div element with an attribute named class using a value of "example" −
<div class = "example">...</div>

Attributes may only be specified within start tags and must never be used in end tags.
HTML5 attributes are case insensitive and may be written in all uppercase or mixed case, although the most common convention is to stick with lowercase.
The attributes listed below are supported by almost all the HTML 5 tags.
For a complete list of HTML5 Tags and related attributes, please check our reference to HTML5 Tags.
A new feature being introduced in HTML 5 is the addition of custom data attributes.
A custom data attribute starts with data- and would be named based on your requirement. Here is a simple example −
<div class = "example" data-subject = "physics" data-level = "complex">
   ...
</div>
The above code will be perfectly valid HTML5 with two custom attributes called datasubject and data-level. You would be able to get the values of these attributes using JavaScript APIs or CSS in similar way as you get for standard attributes.

    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 find the class of clicked element using jQuery ? - GeeksforGeeks

18 Jan, 2021
In this article, we will find the class of the clicked element using jQuery. To find the class of clicked element, we use this.className property. The className property is used to set or return the value of an element’s class attribute. Using this property, the user can change the class of an element to the desired class.
Approach:
Here, we use this.className property to get the class name of the current div element. Here, we have added five div elements with different class name and then use jQuery this.className property to get the clicked div elements class name and display it on the console.
Syntax:
$("div").click(function () {
    var getClass = this.className;
    console.log(getClass);
});
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>        How to find the class of the         clicked element using jquery?    </title>      <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("div").click(function () {                var getClass = this.className;                console.log(getClass);            });        });    </script></head>  <body style="text-align: center;">    <h1 style="color: green;">        GeeksforGeeks    </h1>      <h3>        How to find the class of the         clicked element using jquery?    </h3>      <div class="main">Main Div</div>    <div class="GFG">GFG</div>    <div class="Geeks">Geeks</div>    <div class="G4G">GeeksforGeeks</div>    <div class="welcome">Welcome</div></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
jQuery-Misc
CSS
HTML
JQuery
Web Technologies
HTML
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
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
C Program for Fibonacci numbers - GeeksforGeeks

04 Dec, 2018
The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ........
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation
    Fn = Fn-1 + Fn-2
with seed values
   F0 = 0 and F1 = 1.
C
// Fibonacci Series using Recursion#include <stdio.h>int fib(int n){    if (n <= 1)        return n;    return fib(n - 1) + fib(n - 2);}  int main(){    int n = 9;    printf("%d", fib(n));    getchar();    return 0;}
34

Time Complexity: T(n) = T(n-1) + T(n-2) which is exponential.We can observe that this implementation does a lot of repeated work (see the following recursion tree). So this is a bad implementation for nth Fibonacci number.
                         fib(5)   
                     /                  
               fib(4)                fib(3)   
             /                      /     
         fib(3)      fib(2)         fib(2)    fib(1)
        /             /           /      
  fib(2)   fib(1)  fib(1) fib(0) fib(1) fib(0)
  /    
fib(1) fib(0)

Extra Space: O(n) if we consider the function call stack size, otherwise O(1).
Method 2 ( Use Dynamic Programming )We can avoid the repeated work done is the method 1 by storing the Fibonacci numbers calculated so far.
C
// Fibonacci Series using Dynamic Programming#include <stdio.h>  int fib(int n){    /* Declare an array to store Fibonacci numbers. */    int f[n + 1];    int i;      /* 0th and 1st number of the series are 0 and 1*/    f[0] = 0;    f[1] = 1;      for (i = 2; i <= n; i++) {        /* Add the previous 2 numbers in the series         and store it */        f[i] = f[i - 1] + f[i - 2];    }      return f[n];}  int main(){    int n = 9;    printf("%d", fib(n));    getchar();    return 0;}
34

Time Complexity: O(n)Extra Space: O(n)
Method 3 ( Space Optimized Method 2 )We can optimize the space used in method 2 by storing the previous two numbers only because that is all we need to get the next Fibonacci number in series.
C/C++
// Fibonacci Series using Space Optimized Method#include <stdio.h>int fib(int n){    int a = 0, b = 1, c, i;    if (n == 0)        return a;    for (i = 2; i <= n; i++) {        c = a + b;        a = b;        b = c;    }    return b;}  int main(){    int n = 9;    printf("%d", fib(n));    getchar();    return 0;}
34

Please refer complete article on Program for Fibonacci numbers for more details!
Fibonacci
C Programs
Fibonacci
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
How to Append a Character to a String in C
Producer Consumer Problem in C
time() function in C
Program to find Prime Numbers Between given Interval
C Program to Swap two Numbers
Program to calculate First and Follow sets of given grammar
C program to find the length of a string
Flex (Fast Lexical Analyzer Generator )
Set, Clear and Toggle a given bit of a number in C
Extract Unique dictionary values in Python Program

When it is required to extract unique values from a dictionary, a dictionary is created, and the ‘sorted’ method and dictionary comprehension is used.
Below is a demonstration for the same −
 Live Demo
my_dict = {'hi' : [5,3,8, 0],
   'there' : [22, 51, 63, 77],
   'how' : [7, 0, 22],
   'are' : [12, 11, 45],
   'you' : [56, 31, 89, 90]}

print("The dictionary is : ")
print(my_dict)

my_result = list(sorted({elem for val in my_dict.values() for elem in val}))

print("The unique values are : ")
print(my_result)
The dictionary is :
{'hi': [5, 3, 8, 0], 'there': [22, 51, 63, 77], 'how': [7, 0, 22], 'are': [12, 11, 45], 'you': [56, 31, 89, 90]}
The unique values are :
[0, 3, 5, 7, 8, 11, 12, 22, 31, 45, 51, 56, 63, 77, 89, 90]
A dictionary is defined, and is displayed on the console.
A dictionary is defined, and is displayed on the console.
The values of the dictionary are accessed using the ‘.values’ method.
The values of the dictionary are accessed using the ‘.values’ method.
It is converted into a list, and is assigned to a variable.
It is converted into a list, and is assigned to a variable.
This is displayed as output on the console.
This is displayed as output on the console.
Class getTypeName() method in Java with Examples - GeeksforGeeks

25 Jan, 2022
The getTypeName() method of java.lang.Class class is used to get the type name of this class, which provides the information about this class’ type. The method returns the type name of this class in the form of String. Syntax: 
public String getTypeName()
Parameter: This method does not accept any parameter.Return Value: This method returns the type name of this class in the form of String. Below programs demonstrate the getTypeName() method.Example 1: 
Java
// Java program to demonstrate getTypeName() method import java.util.*; public class Test {    public static void main(String[] args)        throws ClassNotFoundException    {         // returns the Class object for this class        Class myClass = Class.forName("Test");         System.out.println("Class represented by myClass: "                           + myClass.toString());         // Get the type name of myClass        // using getTypeName() method        System.out.println("TypeName of myClass: "                           + myClass.getTypeName());    }}
Class represented by myClass: class Test
TypeName of myClass: Test
 
Example 2:
Java
// Java program to demonstrate getTypeName() method import java.util.*; class Main {     public Object obj;     Main()    {         class Arr {        };         obj = new Arr();    }     public static void main(String[] args)        throws ClassNotFoundException    {        Main t = new Main();         // returns the Class object        Class myClass = t.obj.getClass();         // Get the type name of myClass        // using getTypeName() method        System.out.println("TypeName of myClass: "                           + myClass.getTypeName());    }}
TypeName of myClass: Main$1Arr
 
Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#getTypeName–
saurabh1990aror
Java-Functions
Java-lang package
Java.lang.Class
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Introduction to Java
Difference between Abstract Class and Interface in Java
D3.js | d3.max() function - GeeksforGeeks

26 Jun, 2019
The d3.max() function in D3.js is used to returns the maximum value in the given array using natural order. If an array is empty then it returns undefined as output.
Syntax:
d3.max(Array)
Parameters: This function accepts a parameters Array which is an array of elements whose maximum value is to be calculated. Here elements might be integers or any strings.
Return Value: It returns the maximum value.
Below programs illustrate the d3.max() function in D3.js.Example 1:
<html>  <head>    <title>Getting maximum value</title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [10, 20, 30, 40, 50, 60];        var Array2 = [1, 2];        var Array3 = [0, 1.5, 6.8];        var Array4 = [.8, .08, .008];          // Calling to d3.max() function        A = d3.max(Array1);        B = d3.max(Array2);        C = d3.max(Array3);        D = d3.max(Array4);          // Getting maximum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
60
2
6.8
0.8
Example 2:
<html>  <head>    <title>Getting maximum value</title></head>  <body>    <script src='https://d3js.org/d3.v4.min.js'>  </script>      <script>        // initialising the array of elements        var Array1 = [];        var Array2 = ["a", "b", "c"];        var Array3 = ["A", "B", "C"];        var Array4 = ["Geek", "Geeks", "GeeksforGeeks"];          // Calling to d3.max() function        A = d3.max(Array1);        B = d3.max(Array2);        C = d3.max(Array3);        D = d3.max(Array4);          // Getting maximum value        document.write(A + "<br>");        document.write(B + "<br>");        document.write(C + "<br>");        document.write(D + "<br>");    </script></body>  </html>
Output:
undefined
c
C
GeeksforGeeks
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
How to count the total number of lines in the file in PowerShell?

To count the total number of lines in the file in PowerShell, you first need to retrieve the content of the item using Get-Content cmdlet and need to use method Length() to retrieve the total number of lines. An example is shown below.
(Get-Content D:\Temp\PowerShellcommands.csv).Length
PS C:\WINDOWS\system32> (Get-Content D:\Temp\PowerShellcommands.csv).Length
5727
C# Program to Convert Decimal to Binary


Let’ s say you have set the decimal to be −
decVal = 34;
Console.WriteLine("Decimal: {0}", decVal);
Use the ToString() method for the values you get as a binary number for the decimal value −
while (decVal >= 1) {
   val = decVal / 2;
   a += (decVal % 2).ToString();
   decVal = val;
}
Now set a new empty variable to display the binary number using a loop −
string binValue = "";
You can try to run the following code to convert decimal to binary in C#.
Live Demo
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         int decVal;
         int val;
         string a = "";
         decVal = 34;
         Console.WriteLine("Decimal: {0}", decVal);
         while (decVal >= 1) {
            val = decVal / 2;
            a += (decVal % 2).ToString();
            decVal = val;
         }
         string binValue = "";
         for (int i = a.Length - 1; i >= 0; i--) {
            binValue = binValue + a[i];
         }
         Console.WriteLine("Binary: {0}", binValue);
         Console.Read();
      }
   }
}
Decimal: 34
Binary: 100010
How to Calculate the Average using Arrays in Golang? - GeeksforGeeks

13 Sep, 2021
Given an array of n elements, your task is to find out the average of the array.Approach: 
Accept the size of the array.
Accept the elements of the array.
Store the sum of the elements using for loop.
Calculate Average = (sum/size of array)
Print the average.
Example: 
Input:

n = 4
array = 1, 2, 3, 4

Output :

sum = 10
average = 2.5
 
C
// Golang program to Calculate the Average using Arrayspackage main import "fmt" func main() {     // declaring an array of values    array := []int{1, 2, 3, 4}         // size of the array    n := 4         // declaring a variable    // to store the sum     sum := 0     // traversing through the    // array using for loop    for i := 0; i < n; i++ {         // adding the values of        // array to the variable sum        sum += (array[i])    }         // declaring a variable    // avg to find the average    avg := (float64(sum)) / (float64(n))         // typecast all values to float    // to get the correct result    fmt.Println("Sum = ", sum, "\nAverage = ", avg)}
Output 
Sum =  10 
Average =  2.5
Here, n is the size of the array and sum is to store the sum of all the values of the array. Using a for loop we find the sum of the elements of the array. After calculating the sum, we must convert the data types of the sum and size of the array to float, so that we don’t lose any decimal values.To know more approaches you can go through the article Program for the average of an array (Iterative and Recursive)
akshaysingh98088
Golang-Arrays
Golang-Program
Picked
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Time Formatting in Golang
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
How to Split a String in Golang?
Golang Maps
Arrays in Go
Slices in Golang
How to compare times in Golang?
How to Trim a String in Golang?
Inheritance in GoLang
MongoDB aggregation / math operation to sum score of a specific student

To sum, use aggregate() along with $sum. Let us create a collection with documents −
> db.demo434.insertOne({"Name":"Chris","Score":45});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e771603bbc41e36cc3cae93")
}
> db.demo434.insertOne({"Name":"David","Score":55});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e77161abbc41e36cc3cae94")
}
> db.demo434.insertOne({"Name":"Chris","Score":55});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e771624bbc41e36cc3cae95")
}
Display all documents from a collection with the help of find() method −
> db.demo434.find();
This will produce the following output −
{ "_id" : ObjectId("5e771603bbc41e36cc3cae93"), "Name" : "Chris", "Score" : 45 }
{ "_id" : ObjectId("5e77161abbc41e36cc3cae94"), "Name" : "David", "Score" : 55 }
{ "_id" : ObjectId("5e771624bbc41e36cc3cae95"), "Name" : "Chris", "Score" : 55 }
Following is the query tom sum score of a specific student −
> db.demo434.aggregate([
...    { "$match": { "Name": "Chris"} },
...    { "$group": { "_id": null, "TotalScore": { "$sum": "$Score" } } }
... ]);
This will produce the following output −
{ "_id" : null, "TotalScore" : 100 }
C++ Array Library - end() Function

The C++ function std::array::end() returns an iterator which points to the past-end element of array.
Following is the declaration for std::array::end() function form std::array header.
iterator end() noexcept;
const_iterator end() noexcept;
None
Returns an iterator pointing to the past-the-end element in the array. This element act as a place-holder and never stores the actual data that is why deferencing this location would result undefined behavior.
If array object is const-qualified, method return const iterator otherwise returns iterator.
This member function never throws exception.
Constant i.e. O(1)
The following example shows the usage of std::array::end() function.
#include <iostream>
#include <array>

using namespace std;

int main(void) {

   array<int, 5> arr = {10, 20, 30, 40, 50};
   /* iterator pointing at the start of array */
   auto start = arr.begin();   
   /* iterator pointing past−the−end of array */
   auto end = arr.end();      
   /* iterate complete array */
   while (start < end) {
      cout << *start << " ";
      ++start;
   }

   cout << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
10 20 30 40 50

 Print
 Add Notes
 Bookmark this page
IntStream distinct() method in Java

The distinct() method in the IntStream class in Java returns a stream consisting of the distinct elements of this stream.
The syntax is as follows
IntStream distinct()
Let’s say we have the following elements in the stream. Some of them are repeated
IntStream intStream = IntStream.of(10, 20, 30, 20, 10, 50, 80, 90, 100, 80);
To get the distinct elements, use the IntStream distinct() method.
The following is an example to implement IntStream distinct() method in Java
 Live Demo
import java.util.stream.IntStream;
public class Demo {
   public static void main(String[] args) {
      IntStream intStream = IntStream.of(10, 20, 30, 20, 10, 50, 80, 90, 100, 80);
      System.out.println("Displaying the distinct elements:");
      intStream.distinct().forEach(System.out::println);
   }
}
Displaying the distinct elements:
10
20
30
50
80
90
100
Java Date and Time

Java does not have a built-in Date class, but we can import the java.time 
package to work with the date and time API. The package includes many date and time classes. 
For example:
If you don't know what a package is, read our Java Packages Tutorial.
To display the current date, import the java.time.LocalDate class, and use its now() method:
import java.time.LocalDate; // import the LocalDate class

public class Main {
  public static void main(String[] args) {
    LocalDate myObj = LocalDate.now(); // Create a date object
    System.out.println(myObj); // Display the current date
  }
}

The output will be:
To display the current time (hour, minute, second, and nanoseconds), import the java.time.LocalTime class, and use its now() method:
import java.time.LocalTime; // import the LocalTime class

public class Main {
  public static void main(String[] args) {
    LocalTime myObj = LocalTime.now();
    System.out.println(myObj);
  }
}

The output will be:
To display the current date and time, import the java.time.LocalDateTime class, and use its now() method:
import java.time.LocalDateTime; // import the LocalDateTime class

public class Main {
  public static void main(String[] args) {
    LocalDateTime myObj = LocalDateTime.now();
    System.out.println(myObj);
  }
}

The output will be:
The "T" in the example above is used to separate the date from the time. You can use the DateTimeFormatter class 
with the ofPattern() method in the same package to format or parse date-time objects. 
The following example will remove both the "T" and nanoseconds from the date-time:
import java.time.LocalDateTime; // Import the LocalDateTime class
import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter class

public class Main {
  public static void main(String[] args) {
    LocalDateTime myDateObj = LocalDateTime.now();
    System.out.println("Before formatting: " + myDateObj);
    DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");

    String formattedDate = myDateObj.format(myFormatObj);
    System.out.println("After formatting: " + formattedDate);
  }
}

The output will be:
The ofPattern() method accepts all sorts of values, if you want to display 
the date and time in a different format. For example:
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Handling events in React.js

There are some syntactical differences in writing events but it is handled similar to DOM elements event handling.
The name of event handlers are written in camel case notations.
Event in simple html −
<button onclick=”addUser()”>
   Add User
</button>
Event in React with jsx:
<button onClick={ addUser }>
   Add User
</button>
One of the difference is we do not write return false to prevent default behavior in React. Instead of that we specifically write event.preventDefault()
In simple Html −
<button onclick=”console.log(‘Add user event clicked’); return false;”>
   Add User
</button>
In React it will be written as −
function addUser(event){
   event.preventDefault();
   console.log(‘Add user event clicked’);
}
<button onClick={ addUser }>
   Add User
</button>
Here event passed in React is synthetic and cross browser compatible. A method in ES6 can be an event handler. In JavaScript classes, methods are not bound to class by default. These methods in class should be declared in constructor with binding as shown below −
constructor(props){
   super(props);
   this.addUser=this.addUser.bind(this);
}
Or we can use arrow functions which will bind the methods automatically and then no need to add bind in constructor.
adduser=()=>{
}
If we are not using arrow functions , another alternative is to call the method and binding on React element itself −
addUser(){
}
<button onClick={ (e)=>{this.addUser(e)}}>
   Add User
</button>
The problem with above anonymous callback function is , it will be created every time button renders on the screen and it can affect performance.
<button onClick={ (e)=>this.addUser(id, e) }></button>
Or
<button onClick={ this.addUser.bind(this, id) }></button>
In the above event handler we are passing id as an argument and event object as second argument. The event argument is visible in arrow function but in second approach it is passed implicitly so we have not provided it.
Query for multiple parameters in MongoDB?

To query for multiple parameters in MongoDB, you can use the dot(.) notation. Let us first create a collection with documents −
> db.multipleParametersDemo.insertOne(
...    {
...       "CustomerName" : "Larry",
...       "CustomerDetails" : [
...          {
...             "CustomerCountryName" : "US",
...             "CustomerBankName" : "HDFC",
...             "CustomerBalance" : 17363,
...          }
...       ],
...       "Purchase" : 1456,
...
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd10f9ce3526dbddbbfb60a")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.multipleParametersDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cd10f9ce3526dbddbbfb60a"),
   "CustomerName" : "Larry",
   "CustomerDetails" : [
      {
         "CustomerCountryName" : "US",
         "CustomerBankName" : "HDFC",
         "CustomerBalance" : 17363
      }
   ],
   "Purchase" : 1456
}
Following is how you can query for multiple parameters in MongoDB −
> db.multipleParametersDemo.find({CustomerName: 'Larry', 'CustomerDetails.CustomerCountryName': 'US'}).count();
This will produce the following output −
1
Select rows having more than 2 decimal places in MySQL?

To select rows with more than 2 decimal places, use SUBSTR() function from MySQL. Let us first create a table −
mysql> create table selectRows2DecimalPlacesDemo
   -> (
   -> Amount varchar(100)
   -> );
Query OK, 0 rows affected (0.73 sec)
Following is the query to insert records in the table using insert command −
mysql> insert into selectRows2DecimalPlacesDemo values('234.5678');
Query OK, 1 row affected (0.17 sec)
mysql> insert into selectRows2DecimalPlacesDemo values('19.50');
Query OK, 1 row affected (0.19 sec)
mysql> insert into selectRows2DecimalPlacesDemo values('23.456');
Query OK, 1 row affected (0.17 sec)
mysql> insert into selectRows2DecimalPlacesDemo values('12.123');
Query OK, 1 row affected (0.14 sec)
Following is the query to display all records from the table using select statement −
mysql> select * from selectRows2DecimalPlacesDemo;
This will produce the following output −
+----------+
| Amount   |
+----------+
| 234.5678 |
| 19.50    |
| 23.456   |
| 12.123   |
+----------+
4 rows in set (0.00 sec)
Here is the query to select rows with more than two decimal places −
mysql> select *from selectRows2DecimalPlacesDemo WHERE
LENGTH(SUBSTR(Amount,INSTR(Amount,"."))) >3;
This will produce the following output −
+----------+
| Amount   |
+----------+
| 234.5678 |
| 23.456   |
| 12.123   |
+----------+
3 rows in set (0.00 sec)
8085 program to find maximum and minimum of 10 numbers - GeeksforGeeks

01 Sep, 2021
Problem – Write an assembly language program in 8085 microprocessor to find maximum and minimum of 10 numbers. 
Example –  
Minimum: 01H,  Maximum: FFH
In CMP instruction: If Accumulator > Register then carry and zero flags are reset If Accumulator = Register then zero flag is set If Accumulator < Register then carry flag is set 
Assumption – List of numbers from 2050H to 2059H and output at 2060H and 2061H. 
Algorithm –  
Maximum number is stored in B register and minimum in C registerLoad counter in D registerLoad starting element in Accumulator, B and C registerCompare Accumulator and B registerIf carry flag is not set then transfer contents of Accumulator to B. Else, compare Accumulator with C register, if carry flag is set transfer contents of Accumulator to CDecrement D registerIf D>0 take next element in Accumulator and go to point 4If D=0, store B and C register in memoryEnd of program
Maximum number is stored in B register and minimum in C register
Load counter in D register
Load starting element in Accumulator, B and C register
Compare Accumulator and B register
If carry flag is not set then transfer contents of Accumulator to B. Else, compare Accumulator with C register, if carry flag is set transfer contents of Accumulator to C
Decrement D register
If D>0 take next element in Accumulator and go to point 4
If D=0, store B and C register in memory
End of program
Program- 
Explanation – 
One by one all elements are compared with B and C register.Element is compared with maximum, if it greater than maximum then it is stored in B register. Else, it is compared with minimum and if it is less than minimum then it stored in C register.Loop executes 10 number of times.At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.
One by one all elements are compared with B and C register.
Element is compared with maximum, if it greater than maximum then it is stored in B register. Else, it is compared with minimum and if it is less than minimum then it stored in C register.
Loop executes 10 number of times.
At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.
kalrap615
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Logical and Physical Address in Operating System
Addressing modes in 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Architecture of 8085 microprocessor
Memory Hierarchy Design and its Characteristics
Computer Organization | RISC and CISC
8085 program to add two 8 bit numbers
Architecture of 8086
Computer Organization | Booth's Algorithm
Pin diagram of 8086 microprocessor
How to create a directly-executable cross-platform GUI app using Python(Tkinter)?

Python is a programming language which can be used to create cross-platform applications that are supported in various operating systems such as Microsoft Windows, Mac OS, and Linux.
To create a GUI-based application, we can use the Tkinter library. However, Python provides different modules and extensions which convert a program into an executable application.
For Windows executables - PyInstaller, py2exe
For Windows executables - PyInstaller, py2exe
For Linux executables - Freeze
For Linux executables - Freeze
For Max executables - py2app
For Max executables - py2app
For this example, we will first install the PyInstaller module using pip in our Windows operating system. The module can be installed by using the command,
pip install pyInstaller
Using this module, we will convert our application into an executable file.
app.py
In this application, we will ask the user to select Particular days from the list.
# Import the required libraries
from tkinter import *

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Add a Label
Label(win, text="Select a Day from the Menu",
   font=('Aerial 13')).pack(pady=10)

# Create a Variable to store the selection
var = StringVar()

# Create an OptionMenu Widget and add choices to it
option = OptionMenu(win, var, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
option.config(bg="gray81", fg="white")
option['menu'].config(bg="green3")
option.pack(padx=20, pady=30)

win.mainloop()
Open the command prompt in the directory and write the command for creating an executable file,
Open the command prompt in the directory and write the command for creating an executable file,
pyinstaller app.py
It will create a folder that contains an executable file app.exe. Open the file to run the application.
It will create a folder that contains an executable file app.exe. Open the file to run the application.
C++ Program to Compute Discrete Fourier Transform Using Naive Approach

In discrete Fourier transform (DFT), a finite list is converted of equally spaced samples of a function into the list of coefficients of a finite combination of complex sinusoids. They ordered by their frequencies, that has those same sample values, to convert the sampled function from its original domain (often time or position along a line) to the frequency domain.
Begin
   Take a variable M and initialize it to some integer
   Declare an array function[M]
   For i = 0 to M-1 do
      function[i] = (((a * (double) i) + (b * (double) i)) - c)
   Done
   Declare function sine[M]
   Declare function cosine[M]
   for i =0 to M-1 do
      cosine[i] = cos((2 * i * k * PI) / M)
      sine[i] = sin((2 * i * k * PI) / M)
   Done
   Declare DFT_Coeff dft_value[k]
   for j = 0 to k-1 do
      for i = 0 to M-1 do
         dft_value.real += function[i] * cosine[i]
         dft_value.img += function[i] * sine[i]
      Done
   Done
   Print the value
End
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265
class DFT_Coeff {
   public:
   double real, img;
   DFT_Coeff() {
      real = 0.0;
      img = 0.0;
   }
};
int main(int argc, char **argv) {
   int M= 10;
   cout << "Enter the coefficient of simple linear function:\n";
   cout << "ax + by = c\n";
   double a, b, c;
   cin >> a >> b >> c;
   double function[M];
   for (int i = 0; i < M; i++) {
      function[i] = (((a * (double) i) + (b * (double) i)) - c);
      //System.out.print( " "+function[i] + " ");
   }
   cout << "Enter the max K value: ";
   int k;
   cin >> k;
   double cosine[M];
   double sine[M];
   for (int i = 0; i < M; i++) {
      cosine[i] = cos((2 * i * k * PI) / M);
      sine[i] = sin((2 * i * k * PI) / M);
   }
   DFT_Coeff dft_value[k];
   cout << "The coefficients are: ";
   for (int j = 0; j < k; j++) {
      for (int i = 0; i < M; i++) {
         dft_value[j].real += function[i] * cosine[i];
         dft_value[j].img += function[i] * sine[i];
      }
      cout << "(" << dft_value[j].real << ") - " << "(" << dft_value[j].img <<" i)\n";
   }
}
Enter the coefficient of simple linear function:
ax + by = c
4 5 6
Enter the max K value: 10
The coefficients are:
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
(345) - (-1.64772e-05 i)
Publicly inherit a base class but making some of public method as private - GeeksforGeeks

25 Feb, 2018
There are certain situation when we want to make some of the public base class functions as private in the derived class. Suppose both base and child class has getter and setter methods
// CPP program to demonstrate that all base// class public functions become available// in derived class if we use public inheritance.#include <iostream>using namespace std;  class Base {    int i;  public:    Base() {}    void setBaseProperties(int i)    {        this->i = i;    }    void showBaseProperties()    {        std::cout << endl                  << "i = " << i;    }    virtual ~Base() {}};  class Child : public Base {    int j;    int k;  public:    void setChildProperties(int i, int j, int k)    {        setBaseProperties(i);        this->j = j;        this->k = k;    }    void showChildProperties()    {        showBaseProperties();        cout << " j = " << j << " k = " << k;    }};  int main(){    Child c;    c.setChildProperties(1, 2, 3);      // this exposed function is undesirable    c.setBaseProperties(4);       c.showChildProperties();    return 0;}
i = 4 j = 2 k = 3

Here if we need to restrict the call of function “setBaseProperties” and “showBaseProperties” with Child class object “c”. This can be achieved without overriding the function as below:
We re-declare base class functions in derived class scope using “using” syntax. We do it in private section of derived class.
// CPP program to demonstrate that some of// base class public functions cane be restricted// in derived class if we re-declare them with // "using" in private section of derived class#include <iostream>using namespace std;  class Base {    int i;  public:    Base() {}    void setBaseProperties(int i)    {        this->i = i;    }    void showBaseProperties()    {        std::cout << endl                  << "i = " << i;    }    virtual ~Base() {}};  class Child : public Base {    int j;    int k;      // Redeclaring scope of base class    // functions in private section of    // derived class.    using Base::showBaseProperties;    using Base::setBaseProperties;  public:    void setChildProperties(int i, int j, int k)    {        setBaseProperties(i);        this->j = j;        this->k = k;    }    void showChildProperties()    {        showBaseProperties();        cout << " j = " << j << " k = " << k;    }};  int main(){    Child c;    c.setChildProperties(1, 2, 3);      // if we uncomment this part of code, it causes     // compilation error as the function is private     // now    // c.setBaseProperties(4);       c.showChildProperties();    return 0;}
i = 1 j = 2 k = 3

cpp-inheritance
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Inline Functions in C++
Pair in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
List in C++ Standard Template Library (STL)
How to remove an item from the List in Python? - GeeksforGeeks

29 Aug, 2020
Python Lists have various in-built methods to remove items from the list. Apart from these, we can also use del statement to remove an element from the list by specifying a position. Let’s look at these methods –
Method 1: Using del statementThe del statement is not a function of List. Items of the list can be deleted using del statement by specifying the index of item (element) to be deleted.
# Python 3 code to# remove an item from list# using del statement  lst = ['Iris', 'Orchids', 'Rose', 'Lavender',       'Lily', 'Carnations']print("Original List is :", lst)  # using del statement# to delete item (Orchids at index 1) # from the listdel lst[1]print("After deleting the item :", lst)
Output:
Original List is : [‘Iris’, ‘Orchids’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]After deleting the item : [‘Iris’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]
Method 2: Using remove()We can remove an item from the list by passing the value of the item to be deleted as the parameter to remove() function.
# Python 3 code to# remove an item from list# using function remove()  lst = ['Iris', 'Orchids', 'Rose', 'Lavender',       'Lily', 'Carnations']print("Original List is :", lst)  # using remove()# to delete item ('Orchids') # from the listlst.remove('Orchids')print("After deleting the item :", lst)
Output:
Original List is : [‘Iris’, ‘Orchids’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]After deleting the item : [‘Iris’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]
Method 3: Using pop()pop() is also a method of list. We can remove the element at the specified index and get the value of that element using pop().
# Python 3 code to# remove an item from list# using function pop()  lst = ['Iris', 'Orchids', 'Rose', 'Lavender',        'Lily', 'Carnations']print("Original List is :", lst)  # using pop()# to delete item ('Orchids' at index 1) # from the lista = lst.pop(1)print("Item popped :", a)print("After deleting the item :", lst)
Output –
Original List is : [‘Iris’, ‘Orchids’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]Item popped : OrchidsAfter deleting the item : [‘Iris’, ‘Rose’, ‘Lavender’, ‘Lily’, ‘Carnations’]
python-list
python-list-functions
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
Check if element exists in list in Python
Convert integer to string in Python
Python PIL | MinFilter() and MaxFilter() method

25 Jun, 2019
PIL.ImageFilter.MinFilter() method creates a min filter. Picks the lowest pixel value in a window with the given size.
Syntax: PIL.ImageFilter.MinFilter(size=3)

Parameters: 
size: The kernel size, in pixels.

Image used:
# Importing Image and ImageFilter module from PIL package from PIL import Image, ImageFilter   # creating a image objectim1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG")   # applying the min filterim2 = im1.filter(ImageFilter.MinFilter(size = 3))   im2.show()
Output:
PIL.ImageFilter.MinFilter() method creates a max filter. Picks the largest pixel value in a window with the given size.
Syntax: PIL.ImageFilter.MaxFilter(size=3)

Parameters: 
size: The kernel size, in pixels.

# Importing Image and ImageFilter module from PIL package from PIL import Image, ImageFilter   # creating a image objectim1 = Image.open(r"C:\Users\sadow984\Desktop\download2.JPG")   # applying the max filterim2 = im1.filter(ImageFilter.MaxFilter(size = 3))   im2.show()
Output:
python-utility
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
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
PyQt5 – How to stop radio button from getting checked

22 Apr, 2020
In this article we will see how to stop the radio button for getting checked, some times there is a need of blocking a radio button so that user can’t check it.
In order to stop the radio button from getting checked we have to change the check-able property of radio button and set it to False.
Syntax : radio_button.setCheckable(False)
Argument : It takes bool as argument
Action : It will not allow button to get checked.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a radio button        self.radio_button = QRadioButton(self)          # setting geometry of radio button        self.radio_button.setGeometry(200, 150, 120, 40)          # setting text to radio button        self.radio_button.setText("Radio Button")          # changing check-able property of radio button        self.radio_button.setCheckable(False)    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Extract numbers from list of strings

25 Apr, 2019
Sometimes, we can data in many forms and we desire to perform both conversions and extractions of certain specific parts of a whole. One such issue can be extracting a number from a string and extending this, sometimes it can be more than just an element string but a list of it. Let’s discuss certain ways in which this can be solved.
Method #1 : Using list comprehension + split()
This particular problem can be solved using the list comprehension function to extend the logic to all the items and split function performs the task of splitting and to fetch the target desired element.
# Python3 code to demonstrate# Extracting numbers from list of strings# using list comprehension + split()  # initializing listtest_list = ['Rs. 24', 'Rs. 18', 'Rs. 8', 'Rs. 21']  # printing original listprint("The original list : " + str(test_list))  # using list comprehension + split()# Extracting numbers from list of stringsres = [int(sub.split('.')[1]) for sub in test_list]  # print resultprint("The list after Extracting numbers : " + str(res))
The original list : ['Rs. 24', 'Rs. 18', 'Rs. 8', 'Rs. 21']
The list after Extracting numbers : [24, 18, 8, 21]

 
Method #2 : Using join() + isnumeric() + list comprehension + map()
This method is preferred in the instances in which it is not predefined that the numbers will be ordered in a particular way i.e, this method gives the flexibility of getting the number from whichever position possible.
# Python3 code to demonstrate# Extracting numbers from list of strings# using join() + isnumeric() + list comprehension + map()  # initializing listtest_list = ['Rs. 24', 'Rs. 18', 'Rs. 8', 'Rs. 21']  # printing original listprint("The original list : " + str(test_list))  # using join() + isnumeric() + list comprehension + map()# Extracting numbers from list of stringsres = list(map(lambda sub:int(''.join(      [ele for ele in sub if ele.isnumeric()])), test_list))  # print resultprint("The list after Extracting numbers : " + str(res))
The original list : ['Rs. 24', 'Rs. 18', 'Rs. 8', 'Rs. 21']
The list after Extracting numbers : [24, 18, 8, 21]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.