code-rag-bench/online-tutorials huggingface dataset:
Check if two Dictionary objects are equal in C#

01 Feb, 2019
Equals(Object) Method which is inherited from the Object class is used to check if a specified Dictionary object is equal to another Dictionary object or not.
Syntax:
public virtual bool Equals (object obj);
Here, obj is the object which is to be compared with the current object.
Return Value: This method return true if the specified object is equal to the current object otherwise it returns false.
Below programs illustrate the use of above-discussed method:
Example 1:
// C# code to check if two// Dictionary are equal or notusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Dictionary named myDict        Dictionary<string, string> myDict =            new Dictionary<string, string>();          // Adding key/value pairs in myDict        myDict.Add("Australia", "Canberra");        myDict.Add("Belgium", "Brussels");        myDict.Add("Netherlands", "Amsterdam");        myDict.Add("China", "Beijing");        myDict.Add("Russia", "Moscow");        myDict.Add("India", "New Delhi");          // Checking whether myDict is        // equal to itself or not        Console.WriteLine(myDict.Equals(myDict));    }}
True

Example 2:
// C# code to check if two// Dictionary are equal or notusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Creating a Dictionary named myDict        Dictionary<string, string> myDict1 =             new Dictionary<string, string>();          // Adding key/value pairs in myDict        myDict1.Add("I", "first");        myDict1.Add("II", "second");        myDict1.Add("III", "third");        myDict1.Add("IV", "fourth");        myDict1.Add("V", "fifth");          // Creating a Dictionary named myDict2        Dictionary<string, string> myDict2 =             new Dictionary<string, string>();          myDict2.Add("1st", "C");        myDict2.Add("2nd", "C++");        myDict2.Add("3rd", "Java");        myDict2.Add("4th", "C#");        myDict2.Add("5th", "HTML");        myDict2.Add("6th", "PHP");          // Checking whether myDict1 is        // equal to myDict2 or not        Console.WriteLine(myDict1.Equals(myDict2));          // Creating a new Dictionary        Dictionary<string, string> myDict3 =            new Dictionary<string, string>();          // Assigning myDict2 to myDict3        myDict3 = myDict2;          // Checking whether myDict3 is        // equal to myDict2 or not        Console.WriteLine(myDict3.Equals(myDict2));    }}
False
True

Note: If the current instance is a reference type, the Equals(Object) method checks for reference equality.
CSharp Dictionary Class
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create an unordered list with square bullets in HTML?

To create unordered list in HTML, use the <ul> tag. The unordered list starts with the <ul> tag. The list item starts with the <li> tag and will be marked as disc, square, circle, etc. The default is bullets, which is small black circles.
For creating an unordered list with circle bullets, use CSS property list-style-type. We will be using the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <ul> tag, with the CSS property list-style-type to add square bullets to an unordered list. 
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
You can try to run the following code to create an unordered list with square bullets in HTML −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Unordred List</title>
   </head>
   <body>
      <h1>Developed Countries</h1>
      <p>The list of developed countries :</p>
      <ul style="list-style-type:square">
         <li>US</li>
         <li>Australia</li>
         <li>New Zealand</li>
      </ul>
   </body>
</html>
C# ToLower() Method

The ToLower() method in C# is used to return a copy of this string converted to lowercase.
The syntax is as follows -
public string ToLower ();
Let us now see an example -
 Live Demo
using System;
public class Demo {
   public static void Main(String[] args) {
      string str1 = "WELCOME!";
      string str2 = "Thisisit!";
      char[] arr1 = str1.ToCharArray(3,2);
      char[] arr2 = str2.ToCharArray(2,2);
      Console.WriteLine("String1 = "+str1);
      Console.WriteLine("String1 ToLower = "+str1.ToLower());
      Console.WriteLine("String1 Substring from index4 = " + str1.Substring(4, 4));
      Console.Write("Character array...String1 =");
      for (int i = 0; i < arr1.Length; i++)
         Console.Write(" " + arr1[i]);
      Console.WriteLine("\n\nString2 = "+str2);
      Console.WriteLine("String2 ToLower = "+str2.ToLower());
      Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5));
      Console.Write("Character array...String2 =");
      for (int i = 0; i < arr2.Length; i++)
         Console.Write(" " + arr2[i]);
   }
}
String1 = WELCOME!
String1 ToLower = welcome!
String1 Substring from index4 = OME!
Character array...String1 = C O
String2 = Thisisit!
String2 ToLower = thisisit!
String2 Substring from index2 = Thisi
Character array...String2 = i s
Let us now see another example -
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(String[] args) {
      string str1 = "ABCD!";
      string str2 = "@#$PQRSTUV!";
      Console.WriteLine("String1 = "+str1);
      Console.WriteLine("String1 ToLower = "+str1.ToLower(new CultureInfo("en-US", false)));
      Console.WriteLine("String1 Substring from index4 = " + str1.Substring(2, 2));
      Console.WriteLine("\n\nString2 = "+str2);
      Console.WriteLine("String2 ToLower = "+str2.ToLower(new CultureInfo("en-US", false)));
      Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5));
   }
}
String1 = ABCD!
String1 ToLower = abcd!
String1 Substring from index4 = CD
String2 = @#$PQRSTUV!
String2 ToLower = @#$pqrstuv!
String2 Substring from index2 = @#$PQ
TimeSpan.FromDays() Method in C#

The TimeSpan.FromDays() method in C# is used to return a TimeSpan that
represents a specified number of days, where the specification is accurate to the nearest millisecond.
The syntax is as follows −
public static TimeSpan FromDays (double val);
Above, the parameter val is the number of days, accurate to the nearest
millisecond.
Let us now see an example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      TimeSpan span1 = new TimeSpan(5, 25, 0);
      TimeSpan span2 = new TimeSpan(1, 10, 0);
      TimeSpan span3 = TimeSpan.FromDays(43.999999);
      Console.WriteLine("TimeSpan1 = "+span1);
      Console.WriteLine("TimeSpan2 = "+span2);
      Console.WriteLine("TimeSpan3 = "+span3);
      Console.WriteLine("Result (Comparison of span1 and span2) = "+TimeSpan.Compare(span1, span2));
   }
}
This will produce the following output −
TimeSpan1 = 05:25:00
TimeSpan2 = 01:10:00
TimeSpan3 = 43.23:59:59.9140000
Result (Comparison of span1 and span2) = 1
Let us now see another example −
 Live Demo
using System;
public class Demo {
   public static void Main(){
      TimeSpan span1 = new TimeSpan(-3, 15, 0);
      TimeSpan span2 = new TimeSpan(-2, 05, 10);
      TimeSpan span3 = TimeSpan.FromDays(0.000323456);
      Console.WriteLine("TimeSpan1 = "+span1);
      Console.WriteLine("TimeSpan2 = "+span2);
      Console.WriteLine("TimeSpan3 = "+span3);
      Console.WriteLine("Result (Comparison of span1 and span2) = "+TimeSpan.Compare(span1, span2));
      Console.WriteLine("Result (Comparison of span2 and span3) = "+TimeSpan.Compare(span2, span3));
   }
}
This will produce the following output −
TimeSpan1 = -02:45:00
TimeSpan2 = -01:54:50
TimeSpan3 = 00:00:27.9470000
Result (Comparison of span1 and span2) = -1
Result (Comparison of span2 and span3) = -1
pulseIn() and pulseInLong() in Arduino

If there is an incoming pulse on a pin, and you need to measure the duration of the pulse then the pulseIn() function comes in handy.
The syntax is −
pulseIn(pin, value)
Where pin is the number of the pin on which you wish to measure the pulse. The value is the level of the pulse. It can be HIGH or LOW.
For example, if you set the value to HIGH, it means that as soon as the voltage on the pin goes from LOW to HIGH, the measurement of the time will start. It will stop when the voltage on the pin goes from HIGH to LOW.
The pin returns the time of the pulse in microseconds.
You can also use an alternate form of the function, which takes in a 3rd argument: timeout
pulseIn(pin, value, timeout)
The timeout indicates the number of microseconds to wait for the pulse to start. If you don’t specify this argument, the default timeout is 1 second. In other words, if, after the call to the pulseIn function, the pulse doesn’t start within 1 second (or timeout), this function will give up and return 0.
If you have a very long pulse that needs to be measured, and have interrupts enabled in your code, you could use pulseInLong() instead of pulseIn. The syntax is similar, and the timeout argument is optional over here as well. This function can be used for measuring pulses from 10 microseconds to 3 minutes in length, and can be used only if interrupts are enabled.It is prone to errors for shorter pulses and gives the highest resolution for larger pulses.
An example implementation is given below −
int pulsePin = 6;
unsigned long pulseDuration;

void setup() {
   Serial.begin(9600);
   pinMode(pulsePin, INPUT);
}
void loop() {
   pulseDuration = pulseIn(pulsePin, HIGH);
   Serial.println(pulseDuration);
}
The syntax for pulseInLong remains the same; only the function name changes from pulseIn() to pulseInLong().
Python program to multiply all numbers in the list?

First we create 3 list for user input .here we use traversing technique. Initializing the value of product to 1, traverse all the element and multiply every number with the product one by one till the end of list.
Input: A=[5,6,3]
Output:90
Explanation:5*6*3

Step 1:  input all numbers in the list (lst).
Step 2:  to multiply all values in the list we use traversing technique.	
Step 3:  variable X=1.
Step 4:  for i in LST		/*traverse from first to last in the list
          X=X*i		/* multiply elements one by one
Step 5:  display X

#To multiply all numbers in a list
def mulallnum(lst):
   x=1
   for i in lst:
      x=x*i
      return x
   #driver code
A=list()
B=list()
C=list()
n1=int(input("Enter the size of the First List ::"))
n2=int(input("Enter the size of the Second List ::"))
n3=int(input("Enter the size of the Third List ::"))
print("Enter the Element of First List ::")
for i in range(int(n1)):
   k=int(input(""))
   A.append(k)
print("Enter the Element of Second List ::")
for j in range(int(n2)):
   k1=int(input(""))
   B.append(k1)
print("Enter the Element of Third List ::")
for j in range(int(n3)):
   k1=int(input(""))
   C.append(k1)
print("MULTIPLY OF ALL NUMBERS IN FIRST LIST ::>",mulallnum(A))
print("MULTIPLY OF ALL NUMBERS IN SECOND LIST ::>",mulallnum(B))
print("MULTIPLY OF ALL NUMBERS IN THIRD LIST ::>",mulallnum(C))
Enter the size of the First List ::3
Enter the size of the Second List ::4
Enter the size of the Third List ::5
Enter the Element of First List ::
1
2
5
Enter the Element of Second List ::
3
2
4
5
Enter the Element of Third List ::
12
2
1
3
2
MULTIPLY OF ALL NUMBERS IN FIRST LIST ::> 10
MULTIPLY OF ALL NUMBERS IN SECOND LIST ::> 120
MULTIPLY OF ALL NUMBERS IN THIRD LIST ::> 144
Erlang - put

This method is used to add a key value pair to the map.
put(key1,value1,map1)

key1 − This is key which needs to be added to the map.
key1 − This is key which needs to be added to the map.
Value1 − This is the value associated with key1 which needs to be added to the map.
Value1 − This is the value associated with key1 which needs to be added to the map.
map1 − This is map to which the key value needs to be added.
map1 − This is map to which the key value needs to be added.
The original map with the added key value.
-module(helloworld). 
-export([start/0]). 

start() -> 
   Lst1 = [{"a",1},{"b",2},{"c",3}], 
   Map1 = maps:from_list(Lst1), 
   io:fwrite("~p~n",[maps:put("d",4,Map1)]).
The output of the above program is as follows −
#{"a" => 1,"b" => 2,"c" => 3,"d" => 4}

 Print
 Add Notes
 Bookmark this page
Calculate Hyperbolic cosine of a value in R Programming - cosh() Function - GeeksforGeeks

09 Mar, 2021
cosh() function in R Language is used to calculate the hyperbolic cosine value of the numeric value passed to it as the argument. 
Syntax: cosh(x)Parameter: x: Numeric value
Example 1:  
Python3
# R code to calculate cosine of a value # Assigning values to variablesx1 <- 90x2 <- 30 # Using cosh() Functioncosh(x1)cosh(x2)
Output:  
[1] 6.102016e+38
[1] 5.343237e+12
Example 2:  
Python3
# R code to calculate cosine of a value # Assigning values to variablesx1 <- pix2 <- pi / 3 # Using cosh() Functioncosh(x1)cosh(x2)
Output:  
[1] 11.59195
[1] 1.600287
 
arorakashish0911
R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
How to change the order of bars in bar chart in R ?
Python 3 - Tkinter PanedWindow

A PanedWindow is a container widget that may contain any number of panes, arranged horizontally or vertically.
Each pane contains one widget and each pair of panes is separated by a moveable (via mouse movements) sash. Moving a sash causes the widgets on either side of the sash to be resized.
Here is the simple syntax to create this widget −
w = PanedWindow( master, option, ... )

master − This represents the parent window.
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
bg
The color of the slider and arrowheads when the mouse is not over them.
bd
The width of the 3-d borders around the entire perimeter of the trough, and also the width of the 3-d effects on the arrowheads and slider. Default is no border around the trough, and a 2-pixel border around the arrowheads and slider.
borderwidth
Default is 2.
cursor
The cursor that appears when the mouse is over the window.
handlepad
Default is 8.
handlesize
Default is 8.
height
No default value.
orient
Default is HORIZONTAL.
relief
Default is FLAT.
sashcursor
No default value.
sashrelief
Default is RAISED.
sashwidth
Default is 2.
showhandle
No default value
width
No default value.
PanedWindow objects have these methods −
add(child, options)
Adds a child window to the paned window.
get(startindex [,endindex])
This method returns a specific character or a range of text.
config(options)
Modifies one or more widget options. If no options are given, the method returns a dictionary containing all current option values.
Try the following example yourself. Here's how to create a 3-pane widget −
# !/usr/bin/python3
from tkinter import *

m1 = PanedWindow()
m1.pack(fill = BOTH, expand = 1)

left = Entry(m1, bd = 5)
m1.add(left)

m2 = PanedWindow(m1, orient = VERTICAL)
m1.add(m2)

top = Scale( m2, orient = HORIZONTAL)
m2.add(top)

bottom = Button(m2, text = "OK")
m2.add(bottom)

mainloop()
When the above code is executed, it produces the following result −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to use Font Awesome in Native Android Application?

This example demonstrates how do I use FontAwesome in the native android applications.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/relativeLayout"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
<TextView
   android:id="@+id/textView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerInParent="true"
   android:text="FontAwesome"
   android:textSize="48sp"
   android:textStyle="bold" />
</RelativeLayout>
Step 3 − Create a new download asset folder. Copy-paste the fontAwesome.ttf In the asset folder.
Step 4 − Add the following code to src/MainActivity.java
package app.com.sample;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      TextView textView = findViewById(R.id.textView);
      Typeface font = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf");
      textView.setTypeface(font);
   }
}
Step 5 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
How to get a Popup Dialog in Tkinter/Python?

Tkinter is a standard Python library that is used to create and develop GUI-based applications. We can create an application in Tkinter and add widgets to it that make the application more interactive.
Let's suppose we want to show a popup dialog in an application. In this case, we can use the built-in messagebox module in tkinter. It allows us to show the various dialog boxes such as errors, info box, confirmation boxes, etc.
In this example, we've created a button, which upon clicking will show a popup message on the screen.
# Import the required library
from tkinter import *
from tkinter import ttk
from tkinter import messagebox

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

# Set the geometry
win.geometry("700x250")

# Define a button to show the popup message box
def on_click():
   messagebox.showinfo("Message", "Hey folks!")

# Add a Label widget
Label(win, text="Click the button to open a popup", font=('Georgia 13'))

# Create a button to open the popup dialog
ttk.Button(win, text="Open Popup", command=on_click).pack(pady=30)

win.mainloop()
Running the above code will display a window with a button to open a dialog box.
Click the button to show the popup dialog box on the screen.
How to format a floating number to fixed width in Python?

You can use string formatting to format floating point numbers to a fixed width in Python. For example, if you want the decimal points to be aligned with width of 12 characters and 4 digits on the right of the decimal, you can use the following:
>>> x = 12.35874
>>> print "{:12.4f}".format(x)
     12.3587
You can also achieve this result using string interpolation and formatting. For example:
>>> x = 12.35874
>>> print "% 12.4f" % x
     12.3587
Check if variable is tuple in Python

When it is required to check if a variable is a tuple, the 'type' method can be used.  A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They are important contains since they ensure read-only access.
The 'type' method checks to see the type of the iterable/value that is passed to it as an argument.
Below is a demonstration of the same −
Live Demo
my_tuple_1 = (7, 8, 0, 3, 45, 3, 2, 22, 4)

print ("The tuple is : " )
print(my_tuple_1)

my_result = type(my_tuple_1) is tuple

print("Is the given variable a tuple ? ")
print(my_result)
The tuple is :
(7, 8, 0, 3, 45, 3, 2, 22, 4)
Is the given variable a tuple ?
True
A tuple is defined, and is displayed on the console.
The type of the tuple is examined, and the 'is' and 'tuple' operators are used to check if it is a tuple type.
This result is assigned to a value.
It is displayed as output on the console.
PyQt5 – How to change background color of Main window ? - GeeksforGeeks

26 Mar, 2020
The first step in creating desktop applications with PyQt is getting a window to show up on your desktop, in this article, we will see how we can change the color of this window. In order to change the color of the main window we use setStylesheet() method.
Syntax : setStyleSheet(“background-color: grey;”)
Argument : It takes string as an argument.
Example #1:
# importing the required libraries  from PyQt5.QtWidgets import * from PyQt5 import QtCorefrom PyQt5.QtGui import * import sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          # changing the background color to yellow        self.setStyleSheet("background-color: yellow;")          # set the title        self.setWindowTitle("Color")          # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)          # creating a label widget        self.label = QLabel("Yellow", self)          # moving position        self.label.move(100, 100)          # setting up border        self.label.setStyleSheet("border: 1px solid black;")              # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output : Example #2:
# importing the required libraries  from PyQt5.QtWidgets import * from PyQt5 import QtCorefrom PyQt5.QtGui import * import sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          # changing the background color to cyan        self.setStyleSheet("background-color: cyan;")          # set the title        self.setWindowTitle("Color")          # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)          # creating a label widget        self.label = QLabel("Cyan", self)          # moving position        self.label.move(100, 100)          # setting up border        self.label.setStyleSheet("border: 1px solid black;")              # show all the widgets        self.show()    # 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.
Comments
Old Comments
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
sum() function in Python
How to drop one or multiple columns in Pandas Dataframe
*args and **kwargs in Python
How To Convert Python Dictionary To JSON?
Graph Plotting in Python | Set 1
Print lists in Python (4 Different Ways)
Check if element exists in list in Python
How to check whether a vector contains an NA value or not in R?

An NA value in R represents “Not Available” that means missing value. If a vector has even one NA value then the calculations for that vector becomes a little difficult because we will either have to remove that NA, replace it or neglect it during the calculations. To do any of these things, we will have to make some changes in our codes therefore, it is better to check whether a vector contain an NA or not before doing anything. This can be done with the help of any function in conjunction with is.na.
> x1<-c(1,2,3,2)
> x1
[1] 1 2 3 2
> any(is.na(x1))
[1] FALSE
> x2<-c(1,2,3,2,NA)
> x2
[1] 1 2 3 2 NA
> any(is.na(x2))
[1] TRUE
> x3<-c(4,5,6,"",2,8,7)
> x3
[1] "4" "5" "6" "" "2" "8" "7"
> any(is.na(x3))
[1] FALSE
> x4<-c(4,5,6,"NA",2,8,7)
> x4
[1] "4" "5" "6" "NA" "2" "8" "7"
> any(is.na(x4))
[1] FALSE
> x5<-c(4,5,6,4,2,8,7,NA,4,5,NA,NA)
> x5
[1] 4 5 6 4 2 8 7 NA 4 5 NA NA
> any(is.na(x5))
[1] TRUE
> x6<-rep(c(15,NA,10),times=10)
> x6
 [1] 15 NA 10 15 NA 10 15 NA 10 15 NA 10 15 NA 10 15 NA 10 15 NA 10 15 NA 10 15
[26] NA 10 15 NA 10
> any(is.na(x6))
[1] TRUE
> x7<-rep(c(15,"NA",10),times=10)
> x7
 [1] "15" "NA" "10" "15" "NA" "10" "15" "NA" "10" "15" "NA" "10" "15" "NA" "10"
[16] "15" "NA" "10" "15" "NA" "10" "15" "NA" "10" "15" "NA" "10" "15" "NA" "10"
> any(is.na(x7))
[1] FALSE
> x8<-1:1000000
> any(is.na(x8))
[1] FALSE
> x9<-rep(c(1,2,3,4,5,6,7,8,9,10),times=500000)
> any(is.na(x9))
[1] FALSE
> x10<-rep(c(1,2,3,4,5,6,7,8,9,10),times=5000000)
> any(is.na(x10))
[1] FALSE
The vectors having small size will take less time to get the answer on the other hand the vectors having a very large size will take slightly more time to let us know whether we have an NA in our vector or not.
Measure similarity between images using Python-OpenCV - GeeksforGeeks

18 Aug, 2021
Prerequisites: Python OpenCVSuppose we have two data images and a test image. Let’s find out which data image is more similar to the test image using python and OpenCV library in Python.Let’s first load the image and find out the histogram of images.Importing library  
import cv2
Importing image data  
image = cv2.imread('test.jpg')
Converting to gray image  
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
Finding Histogram  
histogram = cv2.calcHist([gray_image], [0], 
                              None, [256], [0, 256])
Example:Images used:data1.jpg  
data2.jpg  
test.jpg  
 
Python3
import cv2       # test imageimage = cv2.imread('cat.jpg')gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)histogram = cv2.calcHist([gray_image], [0],                         None, [256], [0, 256])  # data1 imageimage = cv2.imread('cat.jpeg')gray_image1 = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)histogram1 = cv2.calcHist([gray_image1], [0],                          None, [256], [0, 256])  # data2 imageimage = cv2.imread('food.jpeg')gray_image2 = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)histogram2 = cv2.calcHist([gray_image2], [0],                          None, [256], [0, 256])    c1, c2 = 0, 0  # Euclidean Distance between data1 and testi = 0while i<len(histogram) and i<len(histogram1):    c1+=(histogram[i]-histogram1[i])**2    i+= 1c1 = c1**(1 / 2)   # Euclidean Distance between data2 and testi = 0while i<len(histogram) and i<len(histogram2):    c2+=(histogram[i]-histogram2[i])**2    i+= 1c2 = c2**(1 / 2)  if(c1<c2):    print("data1.jpg is more similar to test.jpg as compare to data2.jpg")else:    print("data2.jpg is more similar to test.jpg as compare to data1.jpg")
Output :  
data1.jpg is more similar to test.jpg as compare to data2.jpg
 
singghakshay
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Check if element exists in list in Python
Convert integer to string in Python
How To Convert Python Dictionary To JSON?
How to open an image from the URL in PIL? - GeeksforGeeks

26 Mar, 2021
In this article, we will learn How to open an image from the URL using the PIL module in python. For the opening of the image from a URL in Python, we need two Packages urllib and Pillow(PIL).
Install the required libraries and then import them. To install use the following commands:
pip install pillow
Copy the URL of any image.
Write URL with file name in urllib.request.urlretrieve() method.
Use Image.open() method to open image.
At last show the image using obj.show() method.
Sample Code: 
import urllib.request
from PIL import Image
urllib.request.urlretrieve(‘Image url’, “file_name”)
img = Image.open(“file_name”)
img.show()
Example:
Python3
# importing modulesimport urllib.requestfrom PIL import Image  urllib.request.urlretrieve(  'https://media.geeksforgeeks.org/wp-content/uploads/20210318103632/gfg-300x300.png',   "gfg.png")  img = Image.open("gfg.png")img.show()
Picked
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
PyQt5 QListWidget – Setting Vertical Scroll Bar - GeeksforGeeks

06 Aug, 2020
In this article we will see how we can set the vertical scroll bar of the QListWidget. QListWidget is a convenience class that provides a list view with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage each QListWidgetItem in the list. Setting vertical scroll bar replaces the existing vertical scroll bar with scrollBar, and sets all the former scroll bar’s slider properties on the new scroll bar. The former scroll bar is then deleted.
In order to do this we will use setVerticalScrollBar method with the list widget object.
Syntax : list_widget.setVerticalScrollBar(scrollbar)
Argument : It takes QScrollBar object as argument
Return : It returns None
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, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()          # method for components    def UiComponents(self):          # creating a QListWidget        list_widget = QListWidget(self)          # setting geometry to it        list_widget.setGeometry(50, 70, 150, 80)          # list widget items        item1 = QListWidgetItem("PyQt5 Geeks for Geeks")        item2 = QListWidgetItem("B")        item3 = QListWidgetItem("C")        item4 = QListWidgetItem("D")          # adding items to the list widget        list_widget.addItem(item1)        list_widget.addItem(item2)        list_widget.addItem(item3)        list_widget.addItem(item4)          # scroll bar        scroll_bar = QScrollBar(self)          # setting style sheet to the scroll bar        scroll_bar.setStyleSheet("background : lightgreen;")          # setting vertical scroll bar to it        list_widget.setVerticalScrollBar(scroll_bar)          # creating a label        label = QLabel("GeesforGeeks", self)          # setting geometry to the label        label.setGeometry(230, 80, 280, 80)          # making label multi line        label.setWordWrap(True)        # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QListWidget
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
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
*args and **kwargs in Python
Convert integer to string in Python
Lodash _.assignInWith() Method - GeeksforGeeks

18 Sep, 2020
The _.assignInWith() method of Object in lodash is similar to _.assignIn the method and the only difference is that it accepts customizer which is called in order to generate assigned value. Moreover, if the customizer used here returns undefined then the assignment is dealt with by the method instead.
Note: 
The customizer used here can be called with five arguments namely objValue, srcValue, key, object, and source.
The object used here is altered by this method.
Syntax:
_.assignInWith(object, sources, [customizer])

Parameters: This method accepts three parameters as described below:
object: It is the destination object.
sources: It is the source of objects.
customizer: It is the function that customizes assigned values.
Return Value: This method returns the object.
Below examples illustrate the Lodash _.assignInWith() method in JavaScript:
Example 1:
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Defining a function customizerfunction customizer(objectVal, sourceVal) {  return _.isUndefined(objectVal) ? sourceVal : objectVal;}  // Calling assignInWith method with its parameterlet obj = _.assignInWith({ 'gfg': 1 }, { 'geek': 3 }, customizer);  // Displays output console.log(obj);
Output:
{ gfg: 1, geek: 3 }


Example 2:
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Defining a function customizerfunction customizer(objectVal, sourceVal) {  return _.isUndefined(objectVal) ? sourceVal : objectVal;}  // Defining a function GfGfunction GfG() {  this.p = 7;}  // Defining a function Portalfunction Portal() {  this.r = 9;}   // Defining prototype of above functions GfG.prototype.q = 8;Portal.prototype.s = 10;  // Calling assignInWith method with its parameterlet obj = _.assignInWith({ 'p': 6 },           new GfG, new Portal,customizer);  // Displays output console.log(obj);
Output:
{ p: 6, q: 8, r: 9, s: 10 }

Reference: https://lodash.com/docs/4.17.15#assignInWith
JavaScript-Lodash
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
How to append HTML code to a div using JavaScript ?
File uploading in React.js
Hide or show elements in HTML using display property
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Why do we use the novalidate attribute in HTML?

The novalidate attribute in HTML is used to signify that the form won’t get validated on submit. It is a Boolean attribute and useful if you want the user to save the progress of form filing. If the form validation is disabled, the user can easily save the form and continue & submit the form later. While continuing, the user does not have to first validate all the entries.
You can try to run the following code to learn how to use novalidate attribute in HTML. In the following example, if you will add text in the <input type=”number” > field, then it won’t show an error.
<!DOCTYPE html>
<html>
   <head>
      <title>HTML novalidate attribute</title>
   </head>
   <body>
      <form action = "" method = "get" novalidate>
         Student Name<br><input type="name" name="sname"><br>
         Total Marks<br><input type="number" name="mark"><br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
Remove a specific element from a LinkedList in Java

A specific element in the LinkedList can be removed using the java.util.LinkedList.remove()
method. This method removes the specified element the first time it occurs in the LinkedList and
if the element is not in the LinkedList then no change occurs. The parameter required for the
LinkedList.remove() method is the element to be removed.
A program that demonstrates this is given as follows.
 Live Demo
import java.util.LinkedList;
public class Demo {
   public static void main(String[] args) {
      LinkedList<String> l = new LinkedList<String>();
      l.add("Apple");
      l.add("Mango");
      l.add("Pear");
      l.add("Orange");
      l.add("Guava");
      System.out.println("The LinkedList is: " + l);
      System.out.println("The element Mango is removed from the LinkedList? " + l.remove("Mango"));
      System.out.println("The LinkedList is: " + l);
   }
}
The output of the above program is as follows
The LinkedList is: [Apple, Mango, Pear, Orange, Guava]
The element Mango is removed from the LinkedList? true
The LinkedList is: [Apple, Pear, Orange, Guava]
Now let us understand the above program.
The LinkedList l is created. Then LinkedList.add() is used to add the elements to the LinkedList.
After that, LinkedList.remove() method is used to remove the element “Mango” from the
LinkedList. Then the LinkedList is displayed. A code snippet which demonstrates this is as
follows
LinkedList<String> l = new LinkedList<String>();
l.add("Apple");
l.add("Mango");
l.add("Pear");
l.add("Orange");
l.add("Guava");
System.out.println("The LinkedList is: " + l);
System.out.println("The element Mango is removed from the LinkedList? " +
l.remove("Mango"));
System.out.println("The LinkedList is: " + l);
Can a C++ class have an object of self type? - GeeksforGeeks

31 Jul, 2018
A class declaration can contain static object of self type, it can also have pointer to self type, but it cannot have a non-static object of self type.
For example, following program works fine.
// A class can have a static member of self type#include<iostream>  using namespace std;  class Test {  static Test self;  // works fine    /* other stuff in class*/   };  int main(){  Test t;  getchar();  return 0;}
And following program also works fine.
// A class can have a pointer to self type#include<iostream>  using namespace std;  class Test {  Test * self; //works fine    /* other stuff in class*/   };  int main(){  Test t;  getchar();  return 0;}
But following program generates compilation error “field `self’ has incomplete type”
// A class cannot have non-static object(s) of self type.#include<iostream>  using namespace std;  class Test {  Test self; // Error    /* other stuff in class*/   };  int main(){  Test t;  getchar();  return 0;}
If a non-static object is member then declaration of class is incomplete and compiler has no way to find out size of the objects of the class.Static variables do not contribute to the size of objects. So no problem in calculating size with static variables of self type.For a compiler, all pointers have a fixed size irrespective of the data type they are pointing to, so no problem with this also.
Thanks to Manish Jain and Venki for their contribution to this post. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Socket Programming in C/C++
Operator Overloading in C++
Multidimensional Arrays in C / C++
Templates in C++ with Examples
rand() and srand() in C/C++
C++ Data Types
unordered_map in C++ STL
Iterators in C++ STL
getline (string) in C++
Stack in C++ STL
TypeScript | toPrecision() Function - GeeksforGeeks

11 Jun, 2020
The toPrecision() method in TypeScript is used to return the string representation in exponential or fixed-point to the specified precision.
Syntax:
number.toPrecision( [ precision ] )

Parameter: It represents an integer value specifying the number of significant digits.
Return Value: The toPrecision() method in TypeScript returns a string representing a Number in fixed-point or exponential notation round to precision significant digits.
Below examples illustrate the working of toPrecision() function in TypeScript:
Example 1:
<script>  // toPrecision() methodvar num = new Number(6.218956); console.log(num.toPrecision()); console.log(num.toPrecision(4)); console.log(num.toPrecision(3));</script>
Output:
6.218956 
6.2189 
6.21

Example 2:
<script>  // toPrecision() methodlet myNumber: number = 32.5779; console.log("Number Method: toPrecision()");  console.log(myNumber.toPrecision(1));   console.log(myNumber.toPrecision(3));  </script>
Output:
Number Method: toPrecision()
3e+1
32.6

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Difference Between PUT and PATCH Request
Set the value of an input field in JavaScript
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Generate all combinations of supplied words in JavaScript

We are required to write a JavaScript function that takes in an array of strings. The function should then generate and return all possible combinations of the strings of the array.
The code for this will be −
const arr = ['a', 'b', 'c', 'd'];
const permutations = (len, val, existing) => {
   if(len==0){
      res.push(val);
      return;
   }
   for(let i=0; i<arr.length; i++){
      // so that we do not repeat the item, using an array here makes it
      O(1) operation
      if(!existing[i]){
         existing[i] = true;
         permutations(len−1, val+arr[i], existing);
         existing[i] = false;
      }
   }
}
let res = [];
const buildPermuations = (arr = []) => {
   for(let i=0; i < arr.length; i++){
      permutations(arr.length−i, "", []);
   }
};
buildPermuations(arr);
console.log(res);
And the output in the console will be −
[
   'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb',
   'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca',
   'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba',
   'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba',
   'abc', 'abd', 'acb', 'acd', 'adb', 'adc',
   'bac', 'bad', 'bca', 'bcd', 'bda', 'bdc',
   'cab', 'cad', 'cba', 'cbd', 'cda', 'cdb',
   'dab', 'dac', 'dba', 'dbc', 'dca', 'dcb',
   'ab', 'ac', 'ad', 'ba', 'bc', 'bd',
   'ca', 'cb', 'cd', 'da', 'db', 'dc',
   'a', 'b', 'c', 'd'
]
Check if input is a number or letter in JavaScript?

To check if the input is a number or letter, use the isNaN() function from JavaScript. It returns
true if the value is NaN i.e. Not a Number. Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.
css" integrity="sha384- BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
</head>
<body>
<form name="checkingInput" action="" onsubmit="return
checkInputIsNumber()">
Enter the value: <input type="text" name="txtValue">
<br>
<input type="submit" value="check">
<script>
   function checkInputIsNumber(){
      var value=document.forms["checkingInput"]["txtValue"].value;
      if (isNaN(value)){
         alert("Please Provide the input as a number");
         return false;
      }
   }
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
If you provide any value except the number, you will get an alert message. This will produce the
following output −
Here, I am entering the value 100. The screenshot is as follows −
After clicking the check button, you will get the value as query string like −
?txtValue=yourValue.
This will produce the following output −
WSDL - <definition> Element

The <definitions> element must be the root element of all WSDL documents. It defines the name of the web service.
Here is the piece of code from the last chapter that uses the definitions element.
<definitions name="HelloService"
   targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   ................................................
</definitions>
From the above example, we can conclude that definitions −
is a container of all the other elements.
is a container of all the other elements.
specifies that this document is called HelloService.
specifies that this document is called HelloService.
specifies a targetNamespace attribute. The targetNamespace is a convention of XML Schema that enables the WSDL document to refer to itself. In this example, we have specified a targetNamespace of http://www.examples.com/wsdl/HelloService.wsdl
specifies a targetNamespace attribute. The targetNamespace is a convention of XML Schema that enables the WSDL document to refer to itself. In this example, we have specified a targetNamespace of http://www.examples.com/wsdl/HelloService.wsdl
specifies a default namespace: xmlns=http://schemas.xmlsoap.org/wsdl/. All elements without a namespace prefix, such as message or portType, are therefore assumed to be a part of the default WSDL namespace.
specifies a default namespace: xmlns=http://schemas.xmlsoap.org/wsdl/. All elements without a namespace prefix, such as message or portType, are therefore assumed to be a part of the default WSDL namespace.
specifies numerous namespaces that are used throughout the remainder of the document.
specifies numerous namespaces that are used throughout the remainder of the document.
NOTE − The namespace specification does not require the document to be present at the given location. The important point is that you specify a value that is unique, different from all other namespaces that are defined.
 Print
 Add Notes
 Bookmark this page
How to convert byte literals to python strings?

To convert byte literals to Python strings, you need to decode the bytes. It can be done using the decode method on the bytes object. 
>>> b"abcde".decode("utf-8")
u'abcde'
You can also map bytes to chr if the bytes represent ASCII encoding as follows −
bytes = [112, 52, 52]

print("".join(map(chr, bytes)))
p44
log() function in C++

The C/C++ library function double log(double x) returns the natural logarithm (basee
logarithm) of x. Following is the declaration for log() function.
double log(double x)
The parameter is a floating point value. And this function returns natural logarithm
of x.
 Live Demo
#include <iostream>
#include <cmath>
using namespace std;
int main () {
   double x, ret;
   x = 2.7;
   /* finding log(2.7) */
   ret = log(x);
   cout << "log("<< x <<") = " << ret;
   return(0);
}
log(2.7) = 0.993252