code-rag-bench/online-tutorials huggingface dataset:
Kotlin Type Conversion

03 Jan, 2022
Type conversion (also called as Type casting) refers to changing the entity of one data type variable into another data type. As we know Java supports implicit type conversion from smaller to larger data types. An integer value can be assigned to the long data type. For example: 
Java
public class TypecastingExample {    public static void main(String args[]) {       byte p = 12;       System.out.println("byte value : "+p);                                                   // Implicit Typecasting       long q = p;                                  // integer value can be assigned                                                 // to long data type      } }
But, Kotlin does not support implicit type conversion. An integer value can not be assigned to the long data type.  
var myNumber = 100
var myLongNumber: Long = myNumber       // Compiler error
// Type mismatch: inferred type is Int but Long was expected
In Kotlin, the helper function can be used to explicitly convert one data type to another data type. 
Example: 
var myNumber = 100
var myLongNumber: Long = myNumber.toLong()     // compiles successfully
The following helper function can be used to convert one data type into another:  
toByte() 
toShort() 
toInt() 
toLong() 
toFLoat() 
toDouble() 
toChar() 
Note: There is No helper function available to convert into boolean type.
Conversion from larger to smaller data type
var myLongNumber = 10L
var myNumber2: Int = myLongNumber1.toInt()
Kotlin Program to convert the one data type into another:  
Kotlin
fun main(args: Array<String>){    println("259 to byte: " + (259.toByte()))    println("50000 to short: " + (50000.toShort()))    println("21474847499 to Int: " + (21474847499.toInt()))    println("10L to Int: " + (10L.toInt()))    println("22.54 to Int: " + (22.54.toInt()))    println("22 to float: " + (22.toFloat()))    println("65 to char: " + (65.toChar()))    println("A to Int: " + ('A'.toInt()))}
Output: 
259 to byte: 3
50000 to short: -15536
21474847499 to Int: 11019
10L to Int: 10
22.54 to Int: 22
22 to float: 22.0
65 to char: A
A to Int: 65
iampradeephr
Kotlin
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Add Views Dynamically and Store Data in Arraylist in Android?
How to Communicate Between Fragments in Android?
Retrofit with Kotlin Coroutine in Android
Kotlin constructor
Kotlin Higher-Order Functions
Suspend Function In Kotlin Coroutines
MVP (Model View Presenter) Architecture Pattern in Android with Example
Spinner in Kotlin
Android Menus
How to Get Current Location in Android?
How to add column from another DataFrame in Pandas ?

30 May, 2021
In this article, we will discuss how to add a column from another DataFrame in Pandas.
Method 1: Using join() 
Using this approach, the column to be added to the second dataframe is first extracted from the first using its name. Here the extracted column has been assigned to a variable.
Syntax: dataframe1[“name_of_the_column”]
After extraction, the column needs to be simply added to the second dataframe using join() function. 
Syntax: Dataframe2.join(“variable_name”)
This function needs to be called with reference to the dataframe in which the column has to be added and the variable name which stores the extracted column name has to be passed to it as the argument. As a result, the column will be added to the end of the second dataframe with the same name as it was in the previous dataframe.
Example:
Python3
import pandas as pd    df1 = pd.DataFrame({"Col1": [1, 2, 3],                     "Col2": ["A", "B", "C"],                    "Col3": ["geeks", "for", "geeks"]})  print("First dataframe:")display(df1)  df2 = pd.DataFrame({"C1": [4, 5, 6],                    "C2": ["D", "E", "F"]})  print("Second dataframe:")display(df2)  extracted_col = df1["Col3"]print("column to added from first dataframe to second:")display(extracted_col)  df2 = df2.join(extracted_col)print("Second dataframe after adding column from first dataframe:")display(df2)
Output:
Method 2: Using insert()
The approach is the same as above- the column to be added is first extracted and assigned to a variable and then added to another dataframe. The difference here is that this approach gives freedom to place the column anywhere and with a different column name if need be.
Syntax: insert(location, “new_name”, “extarcted_column” )
Here, the index where the column is desired to inserted is passed in place of location. new_name can be replaced by the name the column is supposed to be renamed with and extracted_column is the column from the first dataframe.
Example:
Python3
import pandas as pd    df1 = pd.DataFrame({"Col1": [1, 2, 3],                    "Col2": ["A", "B", "C"],                    "Col3": ["geeks", "for", "geeks"]})print("First dataframe:")display(df1)  df2 = pd.DataFrame({"C1": [4, 5, 6],                    "C2": ["D", "E", "F"]})print("Second dataframe:")display(df2)  extracted_col = df1["Col3"]print("column to added from first dataframe to second:")display(extracted_col)  df2.insert(1, "C3", extracted_col)print("Second dataframe after adding column from first dataframe:")display(df2)
Output:
Picked
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
GATE CS 1999 - GeeksforGeeks

11 Aug, 2021
The number of binary relations on a set with n elements is:
A. Thread                      1. Interrupt
B. Virtual address space       2. Memory
C. File system                 3. CPU
D. Signal                      4. Disk
Thread is handled by CPU.Virtual address space (it is a set of virtual memory addresses that a process can use) is associated with memory management.File System is used for disk management.Interrupt is a type of signal.
Thread is handled by CPU.
Virtual address space (it is a set of virtual memory addresses that a process can use) is associated with memory management.
File System is used for disk management.
Interrupt is a type of signal.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Software Testing - Web Based Testing
What are the different ways of Data Representation?
Bash Script - Command Substitution
SDE SHEET - A Complete Guide for SDE Preparation
7 Highest Paying Programming Languages For Freelancers in 2022
DSA Sheet by Love Babbar
How to Create a Shell Script in linux
How To Convert Numpy Array To Tensor?
7 Best React Project Ideas For Beginners in 2022
C library function - atol()

The C library function long int atol(const char *str) converts the string argument str to a long integer (type long int).
Following is the declaration for atol() function.
long int atol(const char *str)
str − This is the string containing the representation of an integral number.
str − This is the string containing the representation of an integral number.
This function returns the converted integral number as a long int. If no valid conversion could be performed, it returns zero.
The following example shows the usage of atol() function.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main () {
   long val;
   char str[20];
   
   strcpy(str, "98993489");
   val = atol(str);
   printf("String value = %s, Long value = %ld\n", str, val);

   strcpy(str, "tutorialspoint.com");
   val = atol(str);
   printf("String value = %s, Long value = %ld\n", str, val);
	
   return(0);
}
Let us compile and run the above program, this will produce the following result −
String value = 98993489, Long value = 98993489
String value = tutorialspoint.com, Long value = 0


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
HTML5 Canvas & z-index issue in Google Chrome

When we apply z index to a canvas whose position is fixed, it stop causes chrome to render all other elements which have position:fixed properly. This only happens if canvas is greater than 256X256 px in size.
Wrap both h1 and canvas with the fixed div and solves the issue −
<div id = 'fixcontainer'>
   <h1>Test Title</h1>
   <canvas id = "backgroundCanvas" width = "1000" height = "300"></canvas>
</div>
The following is the CSS −
h1{
   position: fixed;
}
body{
   height: 1500px;
}
canvas{
   position: fixed; z-index: -10;
}
How to select checkboxes using selenium java webdriver?

We can select the checkbox with Selenium. In an html document, each checkbox has an attribute type set to a value as checkbox. In order to select a checkbox, we shall first identify a checkbox with any locator and then apply the click() method to it.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class CheckBoxSelect{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url ="https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      // identify element
      WebElement l=driver.findElement(By.xpath("//*[@value='Manual Tester']"));
      // select checkbox with click()
      l.click();
      driver.quit();
   }
}
HTML5 | date attribute in <input> Tag - GeeksforGeeks

03 Dec, 2018
The date attribute in input tag creates a calendar to choose the date, which includes day, month and year.
Syntax:
<input type = "date">
Example 1: Use date attribute in input tag
<!DOCTYPE html><html>    <head>        <title>Date Attribute</title>    </head>    <body>        <form action="/">            Date of Birth: <input type = "date">        </form>    </body></html>                    
Output:
Example 2: Initializing the default date value in input tag. The date format is value = “yyyy-mm-dd” in input tag
<html>    <head>        <title>Date Attribute</title>    </head>    <body>        <form action="/">            Date of Birth: <input type="date" value="2018-10-19">        </form>    </body></html>
Output:
Example 3: DOM for date attribute
<!DOCTYPE html><html>    <head>        <title>Date Attribute</title>    </head>    <body>        Date of Birth:        <input type="date" id="dob">        <button onclick="dateDisplay()">Submit</button>        <p id="demo"></p>        <script>            function dateDisplay() {                var x = document.getElementById("dob").value;                document.getElementById("demo").innerHTML = x;            }        </script>    </body></html>
Output:
Output in the phone:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
Technical Scripter 2018
CSS
HTML
JavaScript
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Returning a function from a function - Python - GeeksforGeeks

20 May, 2021
Functions in Python are first-class objects. First-class objects in a language are handled uniformly throughout. They may be stored in data structures, passed as arguments, or used in control structures.
Properties of first-class functions:
A function is an instance of the Object type.
You can store the function in a variable.
You can pass the function as a parameter to another function.
You can return the function from a function.
You can store them in data structures such as hash tables, lists, ...
Example 1: Functions without arguments
In this example, the first method is A() and the second method is B(). A() method returns the B() method that is kept as an object with name returned_function and will be used for calling the second method.
Python3
# define two methods # second method that will be returned# by first methoddef B():    print("Inside the method B.")     # first method that return second methoddef A():    print("Inside the method A.")         # return second method    return B # form a object of first method# i.e; second methodreturned_function = A() # call second method by first methodreturned_function()
Output :
Inside the method A.
Inside the method B.
Example 2: Functions with arguments
In this example, the first method is A() and the second method is B(). Here A() method is called which returns the B() method i.e; executes both the functions.
Python3
# define two methods # second method that will be returned# by first methoddef B(st2):    print("Good " + st2 + ".")     # first method that return second methoddef A(st1, st2):    print(st1 + " and ", end = "")         # return second method    return B(st2) # call first method that do two work:# 1. execute the body of first method, and# 2. execute the body of second method as#    first method return the second methodA("Hello", "Morning")
Output :
Hello and Good Morning.
Example 3: Functions with lambda
In this example, the first method is A() and the second method is unnamed i.e; with lambda. A() method returns the lambda statement method that is kept as an object with the name returned_function and will be used for calling the second method.
Python3
# first method that return second methoddef A(u, v):    w = u + v    z = u - v         # return second method without name    return lambda: print(w * z) # form a object of first method# i.e; second methodreturned_function = A(5, 2) # check objectprint(returned_function) # call second method by first methodreturned_function()
Output :
<function A.<locals>.<lambda> at 0x7f65d8e17158>
21
gabaa406
Python function-programs
Python-Functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
GFact 48 | Overloading main() in Java - GeeksforGeeks

03 Sep, 2018
Consider the below Java program.
// A Java program with overloaded main()import java.io.*;  public class Test {          // Normal main()    public static void main(String[] args) {        System.out.println("Hi Geek (from main)");        Test.main("Geek");    }      // Overloaded main methods    public static void main(String arg1) {        System.out.println("Hi, " + arg1);        Test.main("Dear Geek","My Geek");    }    public static void main(String arg1, String arg2) {        System.out.println("Hi, " + arg1 + ", " + arg2);    }}
Output:
Hi Geek (from main)
Hi, Geek
Hi, Dear Geek, My Geek
Important Points:The main method in Java is no extra-terrestrial method. Apart from the fact that main() is just like any other method & can be overloaded in a similar manner, JVM always looks for the method signature to launch the program.
The normal main method acts as an entry point for the JVM to start the execution of program.
We can overload the main method in Java. But the program doesn’t execute the overloaded main method when we run your program, we need to call the overloaded main method from the actual main method only.
Related Articles :Valid variants of main() in JavaOverload main in C++Can we Overload or Override static methods in java ?
This article is contributed by Himanshi Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Java-Overloading
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Reverse a string in Java
Arrays.sort() in Java with examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
PostgreSQL - DROP SCHEMA - GeeksforGeeks

28 Aug, 2020
PostgreSQL also supports the deletion of a schema and its objects using the DROP SCHEMA statement.
Syntax: DROP SCHEMA [IF EXISTS] schema_name [ CASCADE | RESTRICT ];
Let’s analyze the above syntax:
First, specify the name of the schema from which you want to remove after the DROP SCHEMA keywords.
Second, use the IF EXISTS option to conditionally to delete schema only if it exists.
Third, use CASCADE to delete schema and all of its objects, and in turn, all objects that depend on those objects. If you want to delete schema only when it is empty, you can use the RESTRICT option. By default, PostgreSQL uses RESTRICT.
To execute the DROP SCHEMA statement, you must be the owner of the schema that you want to drop or a superuser. PostgreSQL also allows you to drop multiple schemas at the same time by using a single DROP SCHEMA statement.Now let’s look into some examples.
Example 1:This example uses the DROP SCHEMA statement to remove the marketing schema present in our database:
DROP SCHEMA IF EXISTS marketing;
To verify so use the below statement:
SELECT * FROM  pg_catalog.pg_namespace ORDER BY nspname;
Output:
Example 2:The following example uses the DROP SCHEMA statement to drop multiple schemas gfg and Raju using a single statement:
DROP SCHEMA IF EXISTS gfg, raju;
To verify so use the below statement:
SELECT * FROM  pg_catalog.pg_namespace ORDER BY nspname;
Output:
postgreSQL-schema
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - CREATE PROCEDURE
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Identity Column
Python - Extract hashtags from text - GeeksforGeeks

11 Aug, 2021
A hashtag is a keyword or phrase preceded by the hash symbol (#), written within a post or comment to highlight it and facilitate a search for it. Some examples are: #like, #gfg, #selfieWe are provided with a string containing hashtags, we have to extract these hashtags into a list and print them. 
Examples :  
Input : GeeksforGeeks is a wonderful #website for #ComputerScience
Output :  website , ComputerScience

Input : This day is beautiful! #instagood #photooftheday #cute
Output :  instagood, photooftheday, cute
Method 1: 
Split the text into words using the split() method.
For every word check if the first character is a hash symbol(#) or not.
If yes then add the word to the list of hashtags without the hash symbol.
Print the list of hashtags.
Python3
# function to print all the hashtags in a textdef extract_hashtags(text):         # initializing hashtag_list variable    hashtag_list = []         # splitting the text into words    for word in text.split():                 # checking the first character of every word        if word[0] == '#':                         # adding the word to the hashtag_list            hashtag_list.append(word[1:])         # printing the hashtag_list    print("The hashtags in \"" + text + "\" are :")    for hashtag in hashtag_list:        print(hashtag) if __name__=="__main__":    text1 = "GeeksforGeeks is a wonderful # website for # ComputerScience"    text2 = "This day is beautiful ! # instagood # photooftheday # cute"    extract_hashtags(text1)    extract_hashtags(text2)
Output : 
The hashtags in "GeeksforGeeks is a wonderful #website for #ComputerScience" are :
website
ComputerScience
The hashtags in "This day is beautiful! #instagood #photooftheday #cute" are :
instagood
photooftheday
cute
Method 2 : Using regular expressions.
Python3
# import the regex moduleimport re # function to print all the hashtags in a textdef extract_hashtags(text):         # the regular expression    regex = "#(\w+)"         # extracting the hashtags    hashtag_list = re.findall(regex, text)         # printing the hashtag_list    print("The hashtags in \"" + text + "\" are :")    for hashtag in hashtag_list:        print(hashtag) if __name__=="__main__":    text1 = "GeeksforGeeks is a wonderful # website for # ComputerScience"    text2 = "This day is beautiful ! # instagood # photooftheday # cute"    extract_hashtags(text1)    extract_hashtags(text2)
Output : 
The hashtags in "GeeksforGeeks is a wonderful #website for #ComputerScience" are :
website
ComputerScience
The hashtags in "This day is beautiful! #instagood #photooftheday #cute" are :
instagood
photooftheday
cute
sagartomar9927
Python
Python Programs
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()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Convert string dictionary to dictionary
Add and Remove Elements in Perl Hashes

Adding a new key/value pair in a Perl hash can be done with one line of code using a simple assignment operator. But to remove an element from the hash you need to use delete function as shown below in the example −
 Live Demo
#!/usr/bin/perl
%data = ('John Paul' => 45, 'Lisa' => 30, 'Kumar' => 40);
@keys = keys %data;
$size = @keys;
print "1 - Hash size: is $size\n";

# adding an element to the hash;
$data{'Ali'} = 55;
@keys = keys %data;
$size = @keys;
print "2 - Hash size: is $size\n";

# delete the same element from the hash;
delete $data{'Ali'};
@keys = keys %data;
$size = @keys;
print "3 - Hash size: is $size\n";
This will produce the following result −
1 - Hash size: is 3
2 - Hash size: is 4
3 - Hash size: is 3
Cucumber - Comments

Comment is basically a piece of code meant for documentation purpose and not for execution. Be it a step definition file or a feature file, to make it more readable and understandable. So, it is important to use/put comments at appropriate places in the file. This also helps while debugging the code. Cucumber feature files can have comments at any place. To put comments, we just need to start the statement with “#” sign.
Different programming languages have got different norms for defining the comments. Let’s see how Cucumber deals with it.
Step definition file − If you are using Java as a platform then mark your comments with “//”.
Step definition file − If you are using Java as a platform then mark your comments with “//”.
Feature File − In case of feature file, we just need to put # before beginning your comment.
Feature File − In case of feature file, we just need to put # before beginning your comment.
The highlighted text in the program refer to the comments in the code.
Feature: annotation 

#This is how background can be used to eliminate duplicate steps 
Background: 
User navigates to Facebook 
Given I am on Facebook login page 

#Scenario with AND 
Scenario: 
When I enter username as "TOM" 
And I enter password as "JERRY" 
Then Login should fail 

#Scenario with BUT 
Scenario: 
When I enter username as "TOM" 
And I enter password as "JERRY" 
Then Login should fail 
But Relogin option should be available

 Print
 Add Notes
 Bookmark this page
C# All method

The All Method checks for all the values in a collection and returns a Boolean. Even if one of the element do not satisfy the set condition, the All() method returns False.
Let us see an example −
int[] arr = {10, 15, 20};
Now, using All() method, we will check whether each element in the above array is greater than 5 or not.
arr.AsQueryable().All(val => val > 5);
 Live Demo
using System;
using System.Linq;
class Demo {
   static void Main() {
      int[] arr = {10, 15, 20};
      // checking if all the array elements are greater than 5
      bool res = arr.AsQueryable().All(val => val > 5);
      Console.WriteLine(res);
   }
}
True
How to use a textarea (a multi-line text input field) in HTML?

To add a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.
Here are the attributes of <textarea> tag −
 
You can try to run the following code to use a textarea in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML textarea Tag</title>
   </head>

   <body>
      <form action = "/cgi-bin/hello_get.cgi" method = "get">
         What improvements you want in college?
         <br>

         <textarea rows = "4" cols = "40" name = "description">
            Enter details here...
         </textarea>
         <br>

         <input type = "submit" value = "submit" />
      </form>

   </body>
</html>
Add minor gridlines to Matplotlib plot using Seaborn

To add minor gridlines to matplotlib plot using Seaborn, we can take the following steps −
Create a list of numbers to plot a histogram using Seaborn.
Create a list of numbers to plot a histogram using Seaborn.
Plot univariate or bivariate histograms to show distributions of datasets using histplot() method.
Plot univariate or bivariate histograms to show distributions of datasets using histplot() method.
To make minor grid lines, we can first use major grid lines and then minor grid lines.
To make minor grid lines, we can first use major grid lines and then minor grid lines.
To display the figure, use show() method.
To display the figure, use show() method.
import seaborn as sns
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [5, 6, 7, 2, 3, 4, 1, 8, 2]
ax = sns.histplot(x, kde=True, color='red')
ax.grid(b=True, which='major', color='black', linewidth=0.075)
ax.grid(b=True, which='minor', color='black', linewidth=0.075)
plt.show()
Hashtable isEmpty() Method in Java - GeeksforGeeks

28 Jun, 2018
The java.util.Hashtable.isEmpty() method of Hashtable class is used to check for the emptiness of the table. The method returns True if no key-value pair or mapping is present in the table else False.
Syntax:
Hash_Table.isEmpty()
Parameters: The method does not take any parameters.
Return Value: The method returns boolean true if the table is empty or does not contain any mapping pairs else boolean false.
Below programs illustrates the working of java.util.Hashtable.isEmpty() method:Program 1:
// Java code to illustrate the isEmpty() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<String, Integer> hash_table =                        new Hashtable<String, Integer>();          // Inserting elements into the table        hash_table.put("Geeks", 10);        hash_table.put("4", 15);        hash_table.put("Geeks", 20);        hash_table.put("Welcomes", 25);        hash_table.put("You", 30);          // Displaying the Hashtable        System.out.println("The table is: " + hash_table);          // Checking for the emptiness of Table        System.out.println("Is the table empty? " +                                  hash_table.isEmpty());    }}
The table is: {You=30, Welcomes=25, 4=15, Geeks=20}
Is the table empty? false

Program 2:
// Java code to illustrate the isEmpty() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<String, Integer> hash_table = new Hashtable<String, Integer>();          // Displaying the Hashtable        System.out.println("The table is: " + hash_table);          // Checking for the emptiness of Table        System.out.println("Is the table empty? " + hash_table.isEmpty());    }}
The table is: {}
Is the table empty? true

Note: The same operation can be performed with any type of variation and combination of different data types.
Java-HashTable
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Reverse a string in Java
Arrays.sort() in Java with examples
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Interfaces in Java
Initialize an ArrayList in Java
DateTime.Equals() Method in C#

The DateTime.Equals() method in C# is used check whether two DateTime objects or instances are equal or not. TRUE is returned if both are equal, else FALSE would be the return value.
Following is the syntax −
public static bool Equals (DateTime date1, DateTime date2);
Let us now see an example to implement the DateTime.Equals() method −
using System;
public class Demo {
   public static void Main() {
      DateTime d1 = new DateTime(2019, 09, 10, 5, 15, 25);
      DateTime d2 = d1.AddMonths(25);
      Console.WriteLine("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      Console.WriteLine("\nNew DateTime (After adding months) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
      bool res = DateTime.Equals(d1, d2);
      if (res)
         Console.WriteLine("\ndate1 = date2. ");
      else
         Console.WriteLine("\ndate1 is not equal to date2. ");
   }
}
This will produce the following output −
Initial DateTime = 10 September 2019, 05:15:25
New DateTime (After adding months) = 10 October 2021, 05:15:25
date1 is not equal to date2.
Let us now see another example to implement the DateTime.Equals() method −
using System;
public class Demo {
   public static void Main() {
      DateTime d1 = new DateTime(2019, 11, 11, 7, 15, 30);
      DateTime d2 = new DateTime(2019, 11, 11, 7, 15, 30);
      Console.WriteLine("DateTime1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);
      Console.WriteLine("\nDateTime2 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);
      bool res = DateTime.Equals(d1, d2);
      if (res)
         Console.WriteLine("\ndate1 = date2 ");
      else
         Console.WriteLine("\ndate1 is not equal to date2 ");
   }
}
This will produce the following output −
DateTime1 = 10 September 2019, 05:15:25
DateTime2 = 10 September 2019, 05:15:25
date1 = date2
How to change the width of a Frame dynamically in Tkinter?

The frame widget in Tkinter works like a container where we can place widgets and all the other GUI components. To change the frame width dynamically, we can use the configure() method and define the width property in it.
In this example, we have created a button that is packed inside the main window and whenever we click the button, it will update the width of the frame.
# Import the required libraries
from tkinter import *
from tkinter import ttk

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

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

def update_width():
   frame.config(width=100)

# Create a frame
frame=Frame(win, bg="skyblue3", width=700, height=250)
frame.pack()

# Add a button in the main window
ttk.Button(win, text="Update", command=update_width).pack()

win.mainloop()
Run the above code to display a window that contains a frame widget and a button.
Click the "Update" button to update the width of the frame.
Batch Script - NET USE

Connects or disconnects your computer from a shared resource or displays information about your connections.
NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]] 
[/USER:[domainname\]username] 
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name] 
[/SMARTCARD] 
[/SAVECRED] [[/DELETE] | [/PERSISTENT:{YES | NO}]]

where
\\computername\sharename − This is the name of the share which needs to be connected to.
\\computername\sharename − This is the name of the share which needs to be connected to.
/USER − This needs to be specified to ensure that the right credentials are specified when connecting to the network share.
/USER − This needs to be specified to ensure that the right credentials are specified when connecting to the network share.
net use z: \\computer\test
The above command will connect to the share name \\computer\test and assign the Z: drive name to it.
 Print
 Add Notes
 Bookmark this page
How to use checktextview in android?

Before getting into the example, we should know what checktextview in android is. Check textview is expanded by textview and contains checkable interface. Using Checktextview we can find that, whether a user is clicked on textview or not.
This example demonstrate about How to use checktextview in android.
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"?>
<android.support.constraint.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   xmlns:app = "http://schemas.android.com/apk/res-auto"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity">
   <CheckedTextView
      android:id = "@+id/text"
      android:layout_width = "wrap_content"
      android:layout_height = "wrap_content"
      android:text = "Checked Text View"
      android:textSize = "25sp"
      app:layout_constraintBottom_toBottomOf = "parent"
      app:layout_constraintLeft_toLeftOf = "parent"
      app:layout_constraintRight_toRightOf = "parent"
      app:layout_constraintTop_toTopOf = "parent" />
</android.support.constraint.ConstraintLayout>
In the above code, we have taken CheckedTextView, when user clicked on textview, it will show check image.
Step 3 − Add the following code to src/MainActivity.java
package com.example.andy.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckedTextView;
public class MainActivity extends AppCompatActivity {
   CheckedTextView text;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      text = findViewById(R.id.text);
      text.setCheckMarkDrawable(null);
      text.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            text.setCheckMarkDrawable(R.drawable.ic_check_circle_pink_400_24dp);
         }
      });
   }
}
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 android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
In the above result shown initial screen. When user click on textview it will show the result as shown below –
Click here to download the project code
Set dashed line for border with CSS

To set the dashed line for the border, use the border-style property. You can try to run the following code to implement border-style property value dashed to set dashed border:
<html>
   <head>
   </head>
   <body>
      <p style = "border-width:3px; border-style:dashed;">
         This is a dotted border.
      </p>
   </body>
</html>
NumPy - Environment

Standard Python distribution doesn't come bundled with NumPy module. A lightweight alternative is to install NumPy using popular Python package installer, pip.
pip install numpy

The best way to enable NumPy is to use an installable binary package specific to your operating system. These binaries contain full SciPy stack (inclusive of NumPy, SciPy, matplotlib, IPython, SymPy and nose packages along with core Python).
Anaconda (from https://www.continuum.io) is a free Python distribution for SciPy stack. It is also available for Linux and Mac.
Canopy (https://www.enthought.com/products/canopy/) is available as free as well as commercial distribution with full SciPy stack for Windows, Linux and Mac.
Python (x,y): It is a free Python distribution with SciPy stack and Spyder IDE for Windows OS. (Downloadable from https://www.python-xy.github.io/)
Package managers of respective Linux distributions are used to install one or more packages in SciPy stack.
sudo apt-get install python-numpy 
python-scipy python-matplotlibipythonipythonnotebook python-pandas 
python-sympy python-nose

sudo yum install numpyscipy python-matplotlibipython 
python-pandas sympy python-nose atlas-devel

Core Python (2.6.x, 2.7.x and 3.2.x onwards) must be installed with distutils and zlib module should be enabled.
GNU gcc (4.2 and above) C compiler must be available.
To install NumPy, run the following command.
Python setup.py install

To test whether NumPy module is properly installed, try to import it from Python prompt.
import numpy

If it is not installed, the following error message will be displayed.
Traceback (most recent call last): 
   File "<pyshell#0>", line 1, in <module> 
      import numpy 
ImportError: No module named 'numpy'

Alternatively, NumPy package is imported using the following syntax −
import numpy as np


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Sending an HTML e-mail using Python

When you send a text message using Python, then all the content are treated as simple text. Even if you include HTML tags in a text message, it is displayed as simple text and HTML tags will not be formatted according to HTML syntax. But Python provides option to send an HTML message as actual HTML message.
While sending an e-mail message, you can specify a Mime version, content type and character set to send an HTML e-mail.
Following is the example to send HTML content as an e-mail. Try it once −
#!/usr/bin/python
import smtplib
message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
MIME-Version: 1.0
Content-type: text/html
Subject: SMTP HTML e-mail test
This is an e-mail message to be sent in HTML format
<b>This is HTML message.</b>
<h1>This is headline.</h1>
"""
try:
   smtpObj = smtplib.SMTP('localhost')
   smtpObj.sendmail(sender, receivers, message)
   print "Successfully sent email"
except SMTPException:
   print "Error: unable to send email"
PHP File Open/Read/Close

In this chapter we will teach you how to open, read, and close a file 
on the server.
A better method to open files is with the fopen() function. This function gives you more 
options than the readfile() function.
We will use the text file, "webdictionary.txt", during the lessons:
The first parameter of fopen() contains the name of the file to be opened and the 
second parameter specifies in which mode the file should be opened. The following example 
also generates a message if the fopen() function is unable to open the specified file:
Tip: The fread() and the fclose() functions will be 
explained below.
The file may be opened in one of the following modes:
The fread() function reads from an open file.
The first parameter of fread() contains the name of the file to read from and 
the second parameter specifies the maximum number of bytes to read.
The following PHP code reads the "webdictionary.txt" file to the end:
The fclose() function is used to close an open file.
It's a good programming practice to close all files after you have finished with them. 
You don't want an open file running around on your 
server taking up resources!
The fclose() requires the name of the file (or a variable that holds the 
filename) we want to close:
The fgets() function is used to read a single line from a file.
The example below outputs the first line of the "webdictionary.txt" file:
Note: After a call to the fgets() function, the file pointer has moved to the next line.
The feof() function checks if the "end-of-file" (EOF) has been reached.
The feof() function is useful for looping through data of unknown length.
The example below reads the "webdictionary.txt" file line by line, until end-of-file is reached:
The fgetc() function is used to read a single character from a file.
The example below reads the "webdictionary.txt" file character by 
character, until end-of-file is reached:
Note: After a call to the fgetc() function, the file pointer moves to the next character.
For a complete reference of filesystem functions, go to our complete
PHP Filesystem Reference.
Open a file, and write the correct syntax to output one character at the time, until end-of-file.
$myfile = fopen("webdict.txt", "r");
while(!($myfile)) {
  echo ($myfile);
}

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.
Python program to accept the strings which contains all vowels

Sometimes you want to accept input based on certain conditions. Here, we are going to see the same type of program. We will write a program that allows only words with vowels. We will show them whether the input is valid or not.
Let's see the approach step by step.
Define a list of vowels [A, E, I, O, U, a, e, i, o, u]
Define a list of vowels [A, E, I, O, U, a, e, i, o, u]
Initialize a word or sentence.
Initialize a word or sentence.
Iterate over the word or sentence.Check if it is present in the list or not.      
Iterate over the word or sentence.
Check if it is present in the list or not.      
Check if it is present in the list or not.      
3.1.1. If not, break the loop and print Not accepted.
Else print accepted
Let's convert the text into Python code.
def check_vowels(string):
   # vowels
   vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u']
   # iterating over the string
   for char in string:
      if char not in vowels:
      print(f"{string}: Not accepted")
      break
   else:
      print(f"{string}: Accepted")
if __name__ == '__main__':
   # initializing strings
   string_1 = "tutorialspoint"
   string_2 = "AEiouaieeu"
   # checking the strings
   check_vowels(string_1)
   check_vowels(string_2)
If you run the above code, you will get the following results.
tutorialspoint: Not accepted
AEiouaieeu: Accepted
You check different properties based on your requirements. If you have any doubts in the tutorial, mention them in the comment section.
Replace one string with another string with Java Regular Expressions

To replace one string with another string using Java Regular Expressions, we need to use the replaceAll() method. The replaceAll() method returns a String replacing all the character sequence matching the regular expression and String after replacement.
Declaration − The java.lang.String.replaceAll() method is declared as follows −
public String replaceAll(String regex, String replaced)  
Let us see a program to replace one string with another string using Java Regular Expressions −
 Live Demo
public class Example {
   public static void main( String args[] ) {
      String str = new String("Good Harry Good");
      System.out.println( "Initial String : "+ str);
      // replacing "Good" with "Bad"
      str = str.replaceAll( "Good" , "Bad" );
      System.out.println( "The String after substitution : "+str );
   }
}
Initial String : Good Harry Good
The String after substitution : Bad Harry Bad
How to check whether a form or a control is valid or not in Angular 10 ? - GeeksforGeeks

03 Jun, 2021
In this article, we are going to check whether a form is touched or not in Angular 10. The valid property is used to report that the control or the form is valid or not.
Syntax:
form.valid
Return Value:
boolean: the boolean value to check whether a form is valid or not.
NgModule: Module used by the valid property is:
FormsModule
 
Approach: 
Create the Angular app to be used.
In app.component.html make a form using ngForm directive.
In app.component.ts get the information using the valid property.
Serve the angular app using ng serve to see the output.
Example:
Javascript
import { Component } from '@angular/core';import { FormGroup, FormControl,     FormArray, Validators } from '@angular/forms'  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})  export class AppComponent {    form = new FormGroup({        name: new FormControl(          ),        rollno: new FormControl()    });      get name(): any {        return this.form.get('name');    }      onSubmit(): void {        console.log("Form is valid : ", this.form.valid);    }}
app.component.html
<form [formGroup]="form" (ngSubmit)="onSubmit()">    <input formControlName="name" placeholder="Name">    <br>          <button type='submit'>Submit</button>    <br><br></form>
Output:
Reference: >https://angular.io/api/forms/AbstractControlDirective#valid
Angular10
AngularJS-Questions
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Angular Libraries For Web Developers
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular PrimeNG Dropdown Component
How to create module with Routing in Angular 9 ?
Angular 10 (blur) Event
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
C# Linq FirstorDefault Method

Use the FirstorDefault() method to return the first element of a sequence or a default value if element isn’t there.
The following is our empty list −
List<double> val = new List<double> { };
Now, we cannot display the first element, since it is an empty collection. For that, use the FirstorDefault() method to display the default value.
val.AsQueryable().FirstOrDefault();
The following is the complete example.
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
   static void Main() {
      List<double> val = new List<double> { };
      double d = val.AsQueryable().FirstOrDefault();
      Console.WriteLine("Default Value = "+d);
      if (d == 0.0D) {
         d = 0.1D;
      }
      Console.WriteLine("Default Value changed = "+d);
   }
}
Default Value = 0
Default Value changed = 0.1