code-rag-bench/online-tutorials huggingface dataset:
Python | sympy.atan2() method - GeeksforGeeks

24 Dec, 2021
In simpy, atan2() method is an inverse tangent function. Using the atan2(x, y) method in simpy module, we can computes the two-argument arctangent. This function is defined for real x and y only. 
Syntax : sympy.atan(x)

Return : Returns the arc tangent of x 
Code #1: Below is the example using atan() method to find inverse tangent function.  
Python3
# importing sympy libraryfrom sympy import * # calling atan2() method on expressiongeek1 = atan2(1, 1)geek2 = atan2(1, -1) print(geek1)print(geek2)
Output:  
pi/4
3*pi/4
  Code #2:  
Python3
# importing sympy libraryfrom sympy import atan2  # calling atan2() method on expressiongeek = atan2(-1, -1)print(geek)
Output:  
-3*pi/4
 
surindertarika1234
SymPy
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
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Align text and select boxes to the same width with HTML and CSS

When we set the width and height of an element in CSS then often the element appears bigger than the actual size. This is because by default, the padding and border are added to the element’s width and height and then the element is displayed.
The box sizing property includes the padding and border of an element with actual width and height so that the element does not appear bigger than the actual size. The format to use this property is “box-sizing: box-border”
You can try to run the following code to align text and select boxes to the same width −
<html>
   <head>
      <style>
         input, select {
            width: 250px;
            border: 2px solid #000;
            padding: 0;
            margin: 0;
            height: 22px;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
         }
         input {
            text-indent: 3px;
         }
      </style>
   </head>
   <body>
      <input type = "text" value = "Name of Candidate"><br>
      <select>
         <option>Select Choice</option>
         <option>Student</option>
         <option>Teachers</option>
         <option>Head</option>
      </select>
   </body>
</html>
Unix / Linux - Shell Arithmetic Operators Example

The following arithmetic operators are supported by Bourne Shell.
Assume variable a holds 10 and variable b holds 20 then −
It is very important to understand that all the conditional expressions should be inside square braces with spaces around them, for example [ $a == $b ] is correct whereas, [$a==$b] is incorrect.
All the arithmetical calculations are done using long integers.
Here is an example which uses all the arithmetic operators −
#!/bin/sh

a=10
b=20

val=`expr $a + $b`
echo "a + b : $val"

val=`expr $a - $b`
echo "a - b : $val"

val=`expr $a \* $b`
echo "a * b : $val"

val=`expr $b / $a`
echo "b / a : $val"

val=`expr $b % $a`
echo "b % a : $val"

if [ $a == $b ]
then
   echo "a is equal to b"
fi

if [ $a != $b ]
then
   echo "a is not equal to b"
fi
The above script will produce the following result −
a + b : 30
a - b : -10
a * b : 200
b / a : 2
b % a : 0
a is not equal to b

The following points need to be considered when using the Arithmetic Operators −
There must be spaces between the operators and the expressions. For example, 2+2 is not correct; it should be written as 2 + 2.
There must be spaces between the operators and the expressions. For example, 2+2 is not correct; it should be written as 2 + 2.
Complete expression should be enclosed between ‘ ‘, called the inverted commas.
Complete expression should be enclosed between ‘ ‘, called the inverted commas.
You should use \ on the * symbol for multiplication.
You should use \ on the * symbol for multiplication.
if...then...fi statement is a decision-making statement which has been explained in the next chapter.
if...then...fi statement is a decision-making statement which has been explained in the next chapter.

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Stream.distinct() in Java

06 Dec, 2018
distinct() returns a stream consisting of distinct elements in a stream. distinct() is the method of Stream interface. This method uses hashCode() and equals() methods to get distinct elements. In case of ordered streams, the selection of distinct elements is stable. But, in case of unordered streams, the selection of distinct elements is not necessarily stable and can change. distinct() performs stateful intermediate operation i.e, it maintains some state internally to accomplish the operation.
Syntax :
Stream<T> distinct()

Where, Stream is an interface and the function
returns a stream consisting of the distinct 
elements.

Below given are some examples to understand the implementation of the function in a better way.Example 1 :
// Implementation of Stream.distinct()// to get the distinct elements in the Listimport java.util.*;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a list of integers        List<Integer> list = Arrays.asList(1, 1, 2, 3, 3, 4, 5, 5);          System.out.println("The distinct elements are :");          // Displaying the distinct elements in the list        // using Stream.distinct() method        list.stream().distinct().forEach(System.out::println);    }}
Output :
The distinct elements are :
1
2
3
4
5

Example 2 :
// Implementation of Stream.distinct()// to get the distinct elements in the Listimport java.util.*;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a list of strings        List<String> list = Arrays.asList("Geeks", "for", "Geeks",                                          "GeeksQuiz", "for", "GeeksforGeeks");          System.out.println("The distinct elements are :");          // Displaying the distinct elements in the list        // using Stream.distinct() method        list.stream().distinct().forEach(System.out::println);    }}
Output :
The distinct elements are :
Geeks
for
GeeksQuiz
GeeksforGeeks

Example 3 :
// Implementation of Stream.distinct()// to get the count of distinct elements// in the Listimport java.util.*;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a list of strings        List<String> list = Arrays.asList("Geeks", "for", "Geeks",                                          "GeeksQuiz", "for", "GeeksforGeeks");          // Storing the count of distinct elements        // in the list using Stream.distinct() method        long Count = list.stream().distinct().count();          // Displaying the count of distinct elements        System.out.println("The count of distinct elements is : " + Count);    }}
Output :
The count of distinct elements is : 4

Java - util package
Java-Functions
java-stream
Java-Stream interface
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
Stack Class in Java
strftime() function in C/C++

The function strftime() is used to format the time and date as a string. It is declared in “time.h” header file in C language. It returns the total number of characters copied to the string, if string fits in less than size characters otherwise, returns zero.
Here is the syntax of strftime() in C language,
size_t strftime(char *string, size_t size, const char *format, const struct tm *time_pointer)
Here,
string − Pointer to the destination array.
size − Maximum number of characters to be copied.
format − Some special format specifiers to represent the time in tm.
time_pointer − Pointer to tm structure that contains the calendar time structure.
Here is an example of strftime() in C language,
 Live Demo
#include <stdio.h>
#include <time.h>
int main () {
   time_t tim;
   struct tm *detl;
   char buf[80];
   time( &tim );
   detl = localtime( &tim );
   strftime(buf, 20, "%x - %I:%M%p", detl);
   printf("Date & time after formatting : %s", buf );
   return(0);
}
Date & time after formatting : 10/23/18 - 10:33AM
In the above program, three variables of multiple data types are declared. The function localtime() is storing the current date and time. The function strftime() is copying the string and formatting it in some special structure by using some special specifiers.
detl = localtime( &tim );
strftime(buf, 20, "%x - %I:%M%p", detl);
PyQt5 - Introduction

PyQt is a GUI widgets toolkit. It is a Python interface for Qt, one of the most powerful, and popular cross-platform GUI library. PyQt was developed by RiverBank Computing Ltd. The latest version of PyQt can be downloaded from its official website − riverbankcomputing.com
PyQt API is a set of modules containing a large number of classes and functions. While QtCore module contains non-GUI functionality for working with file and directory etc., QtGui module contains all the graphical controls. In addition, there are modules for working with XML (QtXml), SVG (QtSvg), and SQL (QtSql), etc.
A list of frequently used modules is given below −
QtCore − Core non-GUI classes used by other modules
QtCore − Core non-GUI classes used by other modules
QtGui − Graphical user interface components
QtGui − Graphical user interface components
QtMultimedia − Classes for low-level multimedia programming
QtMultimedia − Classes for low-level multimedia programming
QtNetwork − Classes for network programming
QtNetwork − Classes for network programming
QtOpenGL − OpenGL support classes
QtOpenGL − OpenGL support classes
QtScript − Classes for evaluating Qt Scripts
QtScript − Classes for evaluating Qt Scripts
QtSql − Classes for database integration using SQL
QtSql − Classes for database integration using SQL
QtSvg − Classes for displaying the contents of SVG files
QtSvg − Classes for displaying the contents of SVG files
QtWebKit − Classes for rendering and editing HTML
QtWebKit − Classes for rendering and editing HTML
QtXml − Classes for handling XML
QtXml − Classes for handling XML
QtWidgets − Classes for creating classic desktop-style UIs
QtWidgets − Classes for creating classic desktop-style UIs
QtDesigner − Classes for extending Qt Designer
QtDesigner − Classes for extending Qt Designer
PyQt is compatible with all the popular operating systems including Windows, Linux, and Mac OS. It is dual licensed, available under GPL as well as commercial license. The latest stable version is PyQt5-5.13.2.
Wheels for 32-bit or 64-bit architecture are provided that are compatible with Python version 3.5 or later. The recommended way to install is using PIP utility −
pip3 install PyQt5

To install development tools such as Qt Designer to support PyQt5 wheels, following is the command −
pip3 install pyqt5-tools

You can also build PyQt5 on Linux/macOS from the source code www.riverbankcomputing.com/static/Downloads/PyQt5

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
What are the rules need to follow when overriding a method that throws an exception in Java?

We need to follow some rules when we overriding a method that throws an Exception.
When the parent class method doesn’t throw any exceptions, the child class method can’t throw any checked exception, but it may throw any unchecked exceptions.
class Parent {
   void doSomething() {
      // ...
   }
}
class Child extends Parent {
   void doSomething() throws IllegalArgumentException {
      // ...
   }
}
When the parent class method throws one or more checked exceptions, the child class method can throw any unchecked exception.
class Parent {
   void doSomething() throws IOException, ParseException {
      // ...
   }
   void doSomethingElse() throws IOException {
      // ...
   }
}
class Child extends Parent {
   void doSomething() throws IOException {
      // ...
   }
   void doSomethingElse() throws FileNotFoundException, EOFException {
      // ...
   }
}
When the parent class method has a throws clause with an unchecked exception, the child class method can throw none or any number of unchecked exceptions, even though they are not related.
class Parent {
   void doSomething() throws IllegalArgumentException {
      // ...
   }
}
class Child extends Parent {
   void doSomething() throws ArithmeticException, BufferOverflowException {
      // ...
   }
}
Live Demo
import java.io.*;
class SuperClassTest{
   public void test() throws IOException {
      System.out.println("SuperClassTest.test() method");
   }
}
class SubClassTest extends SuperClassTest {
   public void test() {
      System.out.println("SubClassTest.test() method");
   }
}
public class OverridingExceptionTest {
   public static void main(String[] args) {
      SuperClassTest sct = new SubClassTest();
      try {
         sct.test();
      } catch(IOException ioe) {
         ioe.printStackTrace();
      }
   }
}
SubClassTest.test() method
File canWrite() method in Java with examples - GeeksforGeeks

13 Dec, 2021
The canWrite()function is a part of File class in Java . This function determines whether the program can write the file denoted by the abstract path name.The function returns true if the abstract file path exists and the application is allowed to write the file.
Function signature:
public boolean canWrite()
Syntax:
file.canWrite()
Parameters: This method does not accept any parameter.
Return Value: The function returns boolean value representing whether the application is allowed to write the file or not.
Exception: This method throws Security Exception if the write access to the file is denied
Below programs illustrates the use of canWrite() function:
Example 1: The file “F:\\program.txt” is writable
Java
// Java program to demonstrate// canWrite() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program.txt");          // Check if the specified file        // can be written or not        if (f.canWrite())            System.out.println("Can be written");        else            System.out.println("Cannot be written");    }}
Can be written
Example 2: The file “F:\\program1.txt” is writable
Java
// Java program to demonstrate// canWrite() method of File Class  import java.io.*;  public class solution {    public static void main(String args[])    {          // Get the file        File f = new File("F:\\program1.txt");          // Check if the specified file        // can be written or not        if (f.canWrite())            System.out.println("Can be written");        else            System.out.println("Cannot be written");    }}
Cannot be written
Note: The programs might not run in an online IDE. Please use an offline IDE and set the path of the file.
sagar0719kumar
Java-File Class
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Different ways of Reading a text file in Java
Constructors in Java
Stream In Java
Generics in Java
Exceptions in Java
Functional Interfaces in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Strings in Java
StringBuilder Class in Java with Examples
MoviePy – Creating Image Sequence Clip - GeeksforGeeks

18 Aug, 2020
In this article we will see how we can create a image sequence clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Video is formed by the frames, combination of frames creates a video each frame is an individual image. Image sequence clip is the clip which is formed by combining images one by one to form a sequence i.e video.
In order to do this we will use ImageSequenceClip method
Syntax : ImageSequenceClip([‘image_file1.jpeg’, ...], fps=24)
Argument : It takes image file names and fps as argument
Return : It returns ImageSequenceClip object
Below is the implementation
# importing editor from movie pyfrom moviepy.editor import *  # creating a Image sequence clip with fps = 1clip = ImageSequenceClip(['frame1.png', 'frame2.png', 'frame1.png', 'frame2.png'], fps = 1)  # showing  clip clip.ipython_display(width = 360) 
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# importing editor from movie pyfrom moviepy.editor import *  # creating a Image sequence clip with fps = 3clip = ImageSequenceClip(['frame1.png', 'frame1.png', 'frame2.png',                          'frame1.png', 'frame1.png', 'frame2.png',                          'frame1.png', 'frame1.png', 'frame2.png'], fps = 3)  # showing  clip clip.ipython_display(width = 360) 
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
Python program to convert a list to string
Reading and Writing to text files in Python
VBA - WeekDay Name

The WeekDayName function returns the name of the weekday for the specified day.
WeekdayName(weekday[,abbreviate[,firstdayofweek]]) 

Weekday − A required parameter. The number of the weekday.
Weekday − A required parameter. The number of the weekday.
Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.
Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.
Firstdayofweek − An optional parameter. Specifies the first day of the week.

0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
6 = vbFriday - Friday
7 = vbSaturday - Saturday


Firstdayofweek − An optional parameter. Specifies the first day of the week.
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
1 = vbSunday - Sunday
1 = vbSunday - Sunday
2 = vbMonday - Monday
2 = vbMonday - Monday
3 = vbTuesday - Tuesday
3 = vbTuesday - Tuesday
4 = vbWednesday - Wednesday
4 = vbWednesday - Wednesday
5 = vbThursday - Thursday
5 = vbThursday - Thursday
6 = vbFriday - Friday
6 = vbFriday - Friday
7 = vbSaturday - Saturday
7 = vbSaturday - Saturday
Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1 : " &WeekdayName(3))
   msgbox("Line 2 : " &WeekdayName(2,True))
   msgbox("Line 3 : " &WeekdayName(1,False))
   msgbox("Line 4 : " &WeekdayName(2,True,0))
   msgbox("Line 5 : " &WeekdayName(1,False,1))
End Sub
When you execute the above function, it produces the following output.
Line 1 : Tuesday
Line 2 : Mon
Line 3 : Sunday
Line 4 : Tue
Line 5 : Sunday


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Redis - String Append Command

Redis APPEND command is used to add some value in a key.
Integer reply, the length of the string after the append operation.
Following is the basic syntax of Redis APPEND command.
redis 127.0.0.1:6379> APPEND KEY_NAME NEW_VALUE

redis 127.0.0.1:6379> SET mykey "hello" 
OK 
redis 127.0.0.1:6379> APPEND mykey " tutorialspoint" 
(integer) 20 
redis 127.0.0.1:6379> GET mykey  
"hello tutorialspoint"


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
How can we ENABLE AND DISABLE a particular MySQL event?

With the help of ALTER EVENT statement along with the ENABLE and DISABLE keyword, we can ENABLE and DISABLE the event. To illustrate it we are having the following example −
mysql> ALTER EVENT hello DISABLE;
Query OK, 0 rows affected (0.00 sec)
The above query will DISABLE the event named ‘Hello’ and the query below will enable it.
mysql> ALTER EVENT hello ENABLE;
Query OK, 0 rows affected (0.00 sec)
Run and share deep learning web application on Google Colab | Towards Data Science

In my previous work, I built a deep learning model using Fastai to colorize black and white photos and built a web app prototype using Streamlit. I wish to share it with my colleagues and friends to get some feedback, so I tried to deploy the web app to AWS and Heroku.
towardsdatascience.com
I was able to deploy my app to these cloud service providers and run it, however, the free tier accounts of them do not provide enough memory for my app, it crashed all the time. To have at least something running online, I had to make the size of the photos small, resulting in very poor quality. I do not want to spend a lot of money on upgrading the account at this early stage. I just want a quick prototype running with full functionality so I can test it and get some feedback.
Since then, I have been looking for other solutions to deploy and share the app. One solution I found is to run the app on Google Colab, using its free and powerful computation service. In this short post, I will describe how I run the web app on Colab.
In case you are not familiar with Stremlit, it is a powerful tool to create simple web applications in Python. It is very convenient for people without web development background and skills like me.
They offer a nice tutorial for beginners.
github.com
I also documented my work building the web app using Stremlit in this post:
towardsdatascience.com
Once you have the web app running locally successfully, you can try to run it on Google Colab
First, clone the app to colab and enter the directory.
!git clone http://github.com/xxx/xxxxx.git colorcd color
then install the requirements
!pip install -r requirements_colab.txt
In my case, it contains stremlit, opencv, fastai, and scikit_image.
then we need to install pyngrok.
!pip install pyngrok
To run and share the app by a public URL on Colab, we need to use ngrok, which is a secure tunneling solution. You can find the details here.
After the installation, we can run the app in the background.
!streamlit run run.py &>/dev/null&
then create the public URL using ngrok.
from pyngrok import ngrok# Setup a tunnel to the streamlit port 8501public_url = ngrok.connect(port='8501')public_url
you should get an URL like this “http://ea41c43860d1.ngrok.io”.
That is it! Really simple steps. Now the web app is available online utilizing the powerful Google Colab for free.
The advantage of running a web app on Colab is that the app is not limited by the limited computation of free tier accounts, you can even have a runtime with GPU. However, the major drawback of it is the URL is only temporary, once the Colab is disconnected, the URL will be disabled. So you can only share the link for a short period (<12hrs). But I think it is still a good approach to quickly deploy, test, and share a web app prototype.
Thanks for reading. Suggestions and comments are welcome.
C Program to Sort an array of names or strings - GeeksforGeeks

18 Jan, 2019
Given an array of strings in which all characters are of the same case, write a C function to sort them alphabetically.
The idea is to use qsort() in C and write a comparison function that uses strcmp() to compare two strings.
#include <stdio.h>#include <stdlib.h>#include <string.h>  // Defining comparator function as per the requirementstatic int myCompare(const void* a, const void* b){      // setting up rules for comparison    return strcmp(*(const char**)a, *(const char**)b);}  // Function to sort the arrayvoid sort(const char* arr[], int n){    // calling qsort function to sort the array    // with the help of Comparator    qsort(arr, n, sizeof(const char*), myCompare);}  int main(){      // Get the array of names to be sorted    const char* arr[]        = { "geeksforgeeks", "geeksquiz", "clanguage" };      int n = sizeof(arr) / sizeof(arr[0]);    int i;      // Print the given names    printf("Given array is\n");    for (i = 0; i < n; i++)        printf("%d: %s \n", i, arr[i]);      // Sort the given names    sort(arr, n);      // Print the sorted names    printf("\nSorted array is\n");    for (i = 0; i < n; i++)        printf("%d: %s \n", i, arr[i]);      return 0;}
Given array is
0: geeksforgeeks 
1: geeksquiz 
2: clanguage 

Sorted array is
0: clanguage 
1: geeksforgeeks 
2: geeksquiz

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Sorting
Strings
Strings
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HeapSort
Time Complexities of all Sorting Algorithms
Radix Sort
std::sort() in C++ STL
sort() in Python
Longest Common Subsequence | DP-4
Write a program to print all permutations of a given string
Reverse a string in Java
KMP Algorithm for Pattern Searching
C++ Data Types
Scala Set toMap() method with example - GeeksforGeeks

18 Oct, 2019
The toMap() method is utilized to return a map consisting of all the elements of the set.
Method Definition: def toMap[T, U]: Map[T, U]
Return Type: It returns a map consisting of all the elements of the set.
Example #1:
// Scala program of toMap() // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {         // Creating a set         val s1 = Set((1, 2), (3, 4), (5, 6))                   // Applying toMap method         val result = s1.toMap                  // Display output        println(result)                  } } 
Map(1 -> 2, 3 -> 4, 5 -> 6)

Example #2:
// Scala program of toMap() // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {         // Creating a set         val s1 = Set((12, 2), (13, 4), (15, 6))                   // Applying toMap method         val result = s1.toMap                  // Display output        println(result)                  } } 
Map(12 -> 2, 13 -> 4, 15 -> 6)

Scala
scala-collection
Scala-Method
Scala-Set
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Scala Lists
Scala Tutorial – Learn Scala with Step By Step Guide
Class and Object in Scala
Type Casting in Scala
Operators in Scala
Inheritance in Scala
Throw Keyword in Scala
Hello World in Scala
Scala String substring() method with example
Conditionally change object property with JavaScript?

To conditionally change object property, use the logical AND operator ( &&).
If both the operands are non-zero, then the condition becomes true in JavaScript’s logical AND
operator.
let marksDetails = { Mark1: 33, Mark2: 89 },isBacklog = false;
console.log("Result when backlog is set to false===");
console.log({ ...marksDetails, ...isBacklog === true && { Mark1: 33 }});
isBacklog = true;
console.log("Result when backlog is set to true===");
console.log({ ...marksDetails, ...isBacklog === true && { Mark1: 93 }});
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo77.js.
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo77.js
Result when backlog is set to false===
{ Mark1: 33, Mark2: 89 }
Result when backlog is set to true===
{ Mark1: 93, Mark2: 89 }
How can we disable the cell editing inside a JTable in Java?

A JTable is a subclass of JComponent for displaying complex data structures. A JTable can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns. A JTable can fire TableModelListener, TableColumnModelListener, ListSelectionListener, CellEditorListener and RowSorterListener interfaces. By default, we can edit the text and modify it inside a JTable cell. We can also disable the cell editing inside a table by calling the editCellAt() method of JTable class and it must return false.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public final class DisableJTableMouseClickTest extends JFrame {
   private JTable table;
   private JScrollPane scrollPane;
   public DisableJTableMouseClickTest() {
      setTitle("DisableJTableMouseClick Test");
      String[] columnNames = {"Country", "Rank"};
      Object[][] data = {{"England", "1"}, {"India", "2"}, {"New Zealand", "3"}, {"Australia", "4"},       {"South Africa","5"}, {"Pakistan","6"}};
      table = new JTable(data, columnNames) {
         public boolean editCellAt(int row, int column, java.util.EventObject e) {
            return false;
         }
      };
      table.setRowSelectionAllowed(false);
      scrollPane= new JScrollPane(table);
      add(scrollPane);
      setSize(400, 275);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   public static void main(String[] args) {
      new DisableJTableMouseClickTest();
   }
}
time.Sleep() Function in Golang With Examples

01 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time.The Sleep() function in Go language is used to stop the latest go-routine for at least the stated duration d. And a negative or zero duration of sleep will cause this method to return instantly. Moreover, this function is defined under the time package. Here, you need to import the “time” package to use these functions.
Syntax:
func Sleep(d Duration)

Here, d is the duration of time in seconds to sleep.
Return Value: It pauses the latest go-routine for the stated duration then returns the output of any operation after the sleep is over.
Example 1:
// Golang program to illustrate the usage of// Sleep() function  // Including main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Main functionfunc main() {      // Calling Sleep method    time.Sleep(8 * time.Second)      // Printed after sleep is over    fmt.Println("Sleep Over.....")}
Output:
Sleep Over.....

Here, after running the above code when the main function is called then due to Sleep method the stated operation is stopped for the given duration then the result is printed.
Example 2:
// Golang program to illustrate the usage of// Sleep() function  // Including main packagepackage main  // Importing time and fmtimport (    "fmt"    "time")  // Main functionfunc main() {      // Creating channel using    // make keyword    mychan1 := make(chan string, 2)      // Calling Sleep function of go    go func() {        time.Sleep(2 * time.Second)          // Displayed after sleep overs        mychan1 <- "output1"    }()      // Select statement    select {      // Case statement    case out := <-mychan1:        fmt.Println(out)      // Calling After method    case <-time.After(3 * time.Second):        fmt.Println("timeout....1")    }      // Again Creating channel using    // make keyword    mychan2 := make(chan string, 2)      // Calling Sleep method of go    go func() {        time.Sleep(6 * time.Second)          // Printed after sleep overs        mychan2 <- "output2"    }()      // Select statement    select {      // Case statement    case out := <-mychan2:        fmt.Println(out)      // Calling After method    case <-time.After(3 * time.Second):        fmt.Println("timeout....2")    }}
Output:
output1
timeout....2

Here, in the above code “output1” is printed as the duration of timeout(in After() method) is greater than the sleep time(in Sleep() method) so, the output is printed before the timeout is displayed but after that, the below case has timeout duration less than the sleep time so, before printing the output the timeout is displayed hence, “timeout....2” is printed.
GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tailwind CSS Line Height

23 Mar, 2022
This class accepts lots of value in tailwind CSS  in which all the properties are covered as in class form. It is the alternative to the CSS Line Height property. This class is used to set the amount of space used for lines, such as in the text. Negative values are not allowed.
Line Height classes:
leading-3: This class set the line-height at .75rem.
leading-4: This class set the line-height at 1rem.
leading-5: This class set the line-height at 1.25rem. 
leading-6: This class set the line-height at 1.5rem.
leading-7: This class set the line-height at 1.75rem.
leading-8: This class set the line-height at 2rem.
leading-9: This class set the line-height at 2.25rem.
leading-10: This class set the line-height at 2.5rem.
leading-none: This class set the line-height at 1.
leading-tight: This class set the line-height at 1.25.
leading-snug: This class set the line-height at 1.375.
leading-normal: This class set the line-height at 1.5.
leading-relaxed: This class set the line-height at 1.625.
leading-loose: This class set the line-height at 2.
Syntax:
<element class="leading-{height}">...</element>
Example: In this example, we will use three classes leading-none, leading-normal and leading-loose. You can change the class name according to your need.
HTML
<!DOCTYPE html>  <head>    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"        rel="stylesheet"></head>  <body class="text-center mx-4 space-y-2">    <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>      <b>Tailwind CSS Line Height Class</b>          <div class="mx-24 bg-green-200 text-justify">        <p class="p-2">leading-none:<br>            <span class="leading-none">                How many times were you frustrated                 while looking out for a good                 collection of programming/algorithm                /interview questions? What did you                 expect and what did you get?                GeeksforGeeks.            </span>        </p>          <p class="p-2">leading-normal:<br>            <span class="leading-normal">                How many times were you frustrated                 while looking out for a good                 collection of programming/algorithm                /interview questions? What did you                 expect and what did you get?                GeeksforGeeks.            </span>        </p>          <p class="p-2">leading-loose:<br>            <span class="leading-loose">                How many times were you frustrated                 while looking out for a good                 collection of programming/algorithm                /interview questions? What did you                 expect and what did you get?                GeeksforGeeks.            </span>        </p>    </div></body>  </html>
Output:
Line height classes
Tailwind CSS
Tailwind-Typography
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript - RegExp ignoreCase Property

ignoreCase is a read-only boolean property of RegExp objects. It specifies whether a particular regular expression performs case-insensitive matching, i.e., whether it was created with the "i" attribute.
Its syntax is as follows −
RegExpObject.ignoreCase

Returns "TRUE" if the "i" modifier is set, "FALSE" otherwise.
Try the following example program.
<html>   
   <head>
      <title>JavaScript RegExp ignoreCase Property</title>
   </head>
   
   <body>
      <script type = "text/javascript">
         var re = new RegExp( "string" );
        
         if ( re.ignoreCase ) {
            document.write("Test1-ignoreCase property is set"); 
         } else {
            document.write("Test1-ignoreCase property is not set"); 
         }
         re = new RegExp( "string", "i" );
        
         if ( re.ignoreCase ) {
            document.write("<br/>Test2-ignoreCase property is set"); 
         } else {
            document.write("<br/>Test2-ignoreCase property is not set"); 
         }
      </script>      
   </body>
</html>
Test1 - ignoreCase property is not set
Test2 - ignoreCase property is set 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
DIV() Function in MySQL - GeeksforGeeks

10 Dec, 2020
DIV() function :This function in MySQL is used to return a quotient (integer) value when integer division is done. For example, when 7 is divided by 3, then 2 will be returned.
Syntax :
SELECT x DIV y;
Parameter :This method accepts two parameters as given below as follows.
x – Specified dividend which will be divided by y.
y – Specified divisor which will divide x.
Returns :It returns a quotient (integer) value when integer division is done.
Example-1 :Getting quotient 2 when 7 is divided by 3.
SELECT 7 DIV 3;
Output :
2
Example-2 :Getting quotient 1 when 4 is divided by 4.
SELECT 4 DIV 4;
Output :
1
Example-3 :Getting quotient 0 when 2 is divided by 4. Here dividend is less than divisor that is why 0 is returned.
SELECT 2 DIV 4;
Output :
0
Application :This function is used to return a quotient (integer) value when integer division is done.
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Convert VARCHAR to INT
SQL | Subquery
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
How to Select Data Between Two Dates and Times in SQL Server?
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Compare Two Dates
GATE | GATE CS 2018 | Question 30 - GeeksforGeeks

25 Feb, 2018
Consider a system with 3 processes that share 4 instances of the same resource type. Each process can request a maximum of K instances. Resource instances can be requested and released only one at a time. The largest value of K that will always avoid deadlock is _______ .
Note – This was Numerical Type question.
(A) 1(B) 2(C) 3(D) 4Answer: (B)Explanation:
Given,Number of processes (P) = 3Number of resources (R) = 4
Since deadlock-free condition is:
R ≥ P(N − 1) + 1

Where R is total number of resources,P is the number of processes, andN is the max need for each resource.
4 ≥ 3(N − 1) + 1
3 ≥ 3(N − 1)
1 ≥ (N − 1)
N ≤ 2

Therefore, the largest value of K that will always avoid deadlock is 2.Option (B) is correct.Quiz of this Question
GATE CS 2018
GATE-GATE CS 2018
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Faulty Keyboard | Practice | GeeksforGeeks

Geek has a unique keyboard containing only the numpad keys. ie - 1,2,3,4,5,6,7,8,9,0. But the keyboard is damaged and can only process M keys. Geek is supposed to use the keyboard to type as many natural numbers as possible starting from 1. What will be the greatest natural number he will type?  

Example 1:
Input: 
M = 5
Output: 5
Explaination: 
Geek can only press 5 keys. He will type
1,2,3,4,5. The greatest number is 5.

Example 2:
Input: 
M = 15
Output: 12
Explaination: 
1 key each from 1 to 9. 
2 keys each from 10 to 12.
Total keys pressed = 15.

Your Task:
You do not need to read input or print anything. Your task is to complete the function maxNatural() which takes M as input parameter and returns the maximum natural number possible to get after pressing M keys.

Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ M ≤ 38890
+1
amanpandey30072 months ago
int maxNatural(int M)   {     if(M<=9)      return M;          M-=9;               if(M<=180)     {         M=M/2;         return 9+M;     }          M-=180;          if(M<=2700)     {                 M=M/3;         return 99+M;     }          M-=2700;          if(M<=36000)     {         M=M/4;         return 999+M;     }          M-=36000;          if(M<=38890)     {         M=M/5;         return 9999+M;     }          return 0;   }
-2
Vineet Kumar5 years ago
Vineet Kumar
java implementation http://code.geeksforgeeks.o...works fine. let me know if it can be optimised further
0
LALIT6 years ago
LALIT
easy
0
Arpit Varshneya6 years ago
Arpit Varshneya
Java Implementationhttp://ideone.com/OEOhg1
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
How do I check if raw input is integer in Python 3?

There is a method called isdigit() in String class that returns true if all characters in the string are digits and there is at least one character, false otherwise. Even if you input a float, it'll return false. You can call it as follows:
>>> x = raw_input()
12345
>>> x.isdigit()
True
You can also use regexes for the same result. For matching only digits, we can call the re.match(regex, string) using the regex: "^[0-9]+$". For example,
>>> x = raw_input()
123abc
>>> bool(re.match('^[0-9]+$', x))
False
re.match returns an object, to check if it exists or not, we need to convert it to a boolean using bool().
Python | sympy.euler() method - GeeksforGeeks

14 Jul, 2019
With the help of sympy.euler() method, we can find the Euler number and Euler polynomial in SymPy.
Syntax: euler(n)
Parameter:n – It denotes the nth Euler number.
Returns: Returns the nth Euler number.
Example #1:
# import sympy from sympy import * n = 4print("Value of n = {}".format(n))   # Use sympy.euler() method nth_euler = euler(n)        print("Value of nth euler number : {}".format(nth_euler))  
Output:
Value of n = 4
Value of nth euler number : 5

Syntax: euler(n, k)
Parameter:n – It denotes the order of the Euler polynomial.k – It denotes the variable in the Euler polynomial.
Returns: Returns the expression of the Euler polynomial or its value.
Example #2:
# import sympy from sympy import * n = 5k = symbols('x')print("Value of n = {} and k = {}".format(n, k))   # Use sympy.euler() method nth_euler_poly = euler(n, k)        print("The nth euler polynomial : {}".format(nth_euler_poly))  
Output:
Value of n = 5 and k = x
The nth euler polynomial : x**5 - 5*x**4/2 + 5*x**2/2 - 1/2

Example #3:
# import sympy from sympy import * n = 4k = 3print("Value of n = {} and k = {}".format(n, k))   # Use sympy.euler() method nth_euler_poly = euler(n, k)        print("The nth euler polynomial value : {}".format(nth_euler_poly))  
Output:
Value of n = 4 and k = 3
The nth euler polynomial value : 30

SymPy
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()
batch command in Linux with Examples - GeeksforGeeks

15 May, 2019
batch command is used to read commands from standard input or a specified file and execute them when system load levels permit i.e. when the load average drops below 1.5.
Syntax:
batch
It is important to note that batch does not accepts any parameters.
Other Similar Commands:
atq: Used to display the queue of pending jobs(this is because at and batch both uses the same job queue).
atrm: Used to remove the specified job from job queue.
Example:
Working with the batch command.top
top
Executing some commands using batch.See the average load is lower than 1.5 that’s why the job queue is empty and command executed instantly.Use ctrl +d when done giving commands to batch.
See the average load is lower than 1.5 that’s why the job queue is empty and command executed instantly.
Use ctrl +d when done giving commands to batch.
Linux-batch-commands
linux-command
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux