code-rag-bench/online-tutorials huggingface dataset:
aspell command in Linux with examples - GeeksforGeeks

04 Apr, 2019
aspell command is used as a spell checker in Linux. Generally, it will scan the given files or anything from standard input then it check for misspellings. Finally it allows the user to correct the words interactively.
Syntax:
aspell check [options] filename
Options:
-a : To check individual words.
-c : Check a file for specific error.
-mode=mode : The modes we have to use when checking files.
-master=name : It is the main dictionary to use.
-dont-backup : It doesn’t create a backup file.
-encoding=name :Encoding the file is expected to be in.
-lang=name -l name : It describes the language the document is written in. By default it depends on the current locale.
-sug-mode=mode : The Suggestion Mode.
Example 1: Check a file for spelling errors
aspell -c sample.txt
Sample Text
Example 2: Using aspell to check individual words.
aspell -a
Note: As soon as you run this command, it will wait for user input. Type a word in this mode, press enter, and you’ll see aspell offering spelling suggestions on stdout.
Example 3: Using aspell to check words in bulk. When run, will wait for user input. Add as many words as you want, and when done, press Ctrl+D. Then you’ll see that aspell will display incorrectly spelled words below the input you provided.
linux-command
Linux-text-processing-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
Basic Operators in Shell Scripting
nohup Command in Linux with Examples
Array Basics in Shell Scripting | Set 1
chown command in Linux with Examples
mv command in Linux with examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
scp command in Linux with Examples
Docker - COPY Instruction
How to handle the Runtime Exception in Java?

The Runtime Exception is the parent class in all exceptions of the Java programming language that are expected to crash or break down the program or application when they occur. Unlike exceptions that are not considered as Runtime Exceptions, Runtime Exceptions are never checked.
The Runtime Exception usually shows the programmer's error, rather than the condition a program is expected to deal with. Runtime Exceptions are also used when a condition that can't happen. It should be noted that when a program is running out of memory, a program error is thrown instead of showing it as a Runtime Exception.
The most common Runtime Exceptions are NullPointerException, ArrayIndexOutOfBoundsException and the InvalidArgumentException. The Java Virtual Machine throws the first two Runtime Exceptions.
The NullPointerException is the exception thrown by the Java Virtual Machine when a user performs some operations on a certain object considered as null or is calling for some method on the null object. A user should not attempt to handle this kind of an exception because it will only patch the problem and not completely fix it.
The ArrayIndexOutOfBoundsException is the exception that is automatically thrown by the Java Runtime Environment when a certain Java program incorrectly tries to access a certain location in a set that is non-existent. This often happens when the array index requested is negative, or more than or equal to the array's size. The arrays of Java use the zero-based indexing; thus, the first element of that array has a zero index, the last element comes with an index of size 1, and the nth element comes with an index n-1.
The InvalidArgumentException is an exception raised when an invalid parameter is passed to a certain method on the server's referenced connection.
public class MyExceptionTest {
   public void testRuntimeException () {
      throw new MyException();
   }
   public static void main(String[] args) {
      try {
         new MyExceptionTest().testRuntimeException();
      } catch(Exception e) {
         System.out.println(e.getClass().getName());
      }
   }
}
class MyException extends RuntimeException {
   public MyException() {
      super();
   }
}
MyException
Python - Calculate the variance of a column in a Pandas DataFrame

To calculate the variance of column values, use the var() method. At first, import the required Pandas library −
import pandas as pd
Create a DataFrame with two columns −
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'],
      "Units": [100, 150, 110, 80, 110, 90]
   }
)


Finding Variance of "Units" column values using var() function −
print"Variance of Units column from DataFrame1 = ",dataFrame1['Units'].var()
In the same way, we have calculated the Variance from the 2nd DataFrame.
Following is the complete code −
import pandas as pd

# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'],
      "Units": [100, 150, 110, 80, 110, 90]
   }
)

print"DataFrame1 ...\n",dataFrame1

# Finding Variance of "Units" column values
print"Variance of Units column from DataFrame1 = ",dataFrame1['Units'].var()

# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Product": ['TV', 'PenDrive', 'HeadPhone', 'EarPhone', 'HDD', 'SSD'],
      "Price": [8000, 500, 3000, 1500, 3000, 4000]
   }
)

print"\nDataFrame2 ...\n",dataFrame2

# Finding Variance of "Price" column values
print"Variance of Price column from DataFrame2 = ",dataFrame2['Price'].var()
This will produce the following output −
DataFrame1 ...
       Car   Units
0      BMW    100
1    Lexus    150
2     Audi    110
3    Tesla     80
4  Bentley    110
5   Jaguar     90
Variance of Units column from DataFrame1 = 586.666666667

DataFrame2 ...
    Price   Product
0   8000    TV
1   500     PenDrive
2   3000    HeadPhone
3   1500    EarPhone
4   3000    HDD
5   4000    SSD
Variance of Price column from DataFrame2 = 6766666.66667
C++ Pointers ( Incrementing a variable) | Set 1 | Practice | GeeksforGeeks

Given a pointer to a variable a, the task is to complete the function updateVar() which will increment the value of the variable by 10. The function does not returns anything.
Example 1:  
Input:
a = 4
Output: 
14

Example 2: 
Input:
a = 61
Output: 
71

Your Task:
Since this is a functional problem you don't have to worry about input, you just have to complete the function updateVar().
Constraints:
1 <= T <= 100
1 <= A <= 103
+1
0niharika22 months ago
*a += 10;
0
gargharshit5033 months ago
#include <iostream>
using namespace std;
int add(int *a)
{
    int b;
    *a= *a+10;
    b= *a;
    return b;
}
int main()
{
int a;
cin>>a;
cout<<add(&a);
return 0;
}
0
satyanandgupta19104 months ago
here , user give input to a value . then a is equal to a + 10 so variable value will increase by 10.
+1
seeagarg02034 months ago
*a += 10;
0
abdulmuqsitzargar015 months ago
void updateVar(int *a){   *a=*a+10;  }
0
bhalgatshreya26 months ago
void updateVar(int *a)
{
     *a+=10;
     
     
      // write your code here
}
-3
aimlabhinavpatil7 months ago
#include <stdio.h>int main(){   int x, *b, inc;   printf("Enter Value of x\n");   scanf("%d",&x);
b = &x;
inc = 10 + *b;      printf("Incremented Value = %d\n",inc);   return 0;} 
0
aimlabhinavpatil
This comment was deleted.
0
Gurucharan Rajput10 months ago
Gurucharan Rajput
*a+=10;
-4
shivam1 year ago
shivam
void updateVar(int *a){ *a=*a+10;}
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 to create Tkinter buttons in a Python for loop?

Tkinter Button widgets are very useful in terms of handling events and performing actions during the execution of an application. We can create Tkinter Buttons using the Button(parent, text, option..) constructor. Using the constructor, we can create multiple buttons within the loop.
In this example, we will create multiple buttons in the range using a Python for loop.
#import required libraries
from tkinter import *
from tkinter import ttk

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

#Set the geometry of the window
win.geometry("750x250")

#Create a LabelFrame
labelframe= LabelFrame(win)

#Define a canvas in the window
canvas= Canvas(labelframe)
canvas.pack(side=RIGHT, fill=BOTH, expand=1)

labelframe.pack(fill= BOTH, expand= 1, padx= 30, pady=30)

#Create Button widget in Canvas
for i in range(5):
   ttk.Button(canvas, text= "Button " +str(i)).pack()

win.mainloop()
Running the above code will display a window containing some buttons inside a LabelFrame object.
C# General Date Short Time ("g") Format Specifier

The Generate Date Short Time format specifier is a combination of the short date ("d") and short time ("t") patterns, separated by a space.
Set a date using DateTime.
DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20);
Now, use the (“g”) format specifier.
dt.ToString("g", DateTimeFormatInfo.InvariantInfo));
 Live Demo
using System;
using System.Globalization;
class Demo {
   static void Main() {
      DateTime dt = new DateTime(2018, 10, 2, 7, 59, 20);
      Console.WriteLine(dt.ToString("g", DateTimeFormatInfo.InvariantInfo));
      Console.WriteLine(dt.ToString("g", CultureInfo.CreateSpecificCulture("en-us")));
   }
}
10/02/2018 07:59
10/2/2018 7:59 AM
Getting error- <type table> is not an internal table “OCCURS n” specification is missing in SAP method

You need to define the et_flights parameter as of type SFLIGHT. As per method defined, you have this type as structure type and also declare transparent table SFLIGHT at the same time.
You should use an already available dictionary table type with row structure of SFLIGHT for et_flight.
You should declare et_flights inside the method in class definition as a private member or as a return value of the method.
class myclass definition.
   public section.
   types ty_mytable type standard table of sflight.
   methods mymethod exporting mydata type ty_mytable.
endclass.

class myclass implementation.
    method mymethod.
       select * from sflight into table mydata.
    endmethod.
endclass.
How to add special characters to text to print in color in the console in JavaScript ? - GeeksforGeeks

15 Apr, 2021
The purpose of this article is to add special characters to text to print in color in the console in JavaScript.
Approach: The ANSI escape codes help change/specify the color of the output in the console. The color of the output of the console can be changed by adding these escape codes just before the actual text. 
Syntax: 
/*Codes for different Colors*/
black = "\x1b[30m"
red = "\x1b[31m"
green = "\x1b[32m"
yellow = "\x1b[33m"
blue = "\x1b[34m"
magenta = "\x1b[35m"
cyan = "\x1b[36m"
white = "\x1b[37m"
Example : 
Javascript
<script>  console.log("\x1b[31m"+ "Red");  console.log("\x1b[32m"+ "Green");  console.log("\x1b[35m"+ "Magenta");</script>
Output:
Note: The above task can be simplified by adding a custom helper function in the script which can be invoked with the color and data to be displayed in the console.
Example: The following is the JavaScript code for performing the task using a custom helper function.
Javascript
<script>function colorHelper(color,data){       /* function receives 2 arguments color and data*/   const black = "\x1b[30m";     const red = "\x1b[31m";   const green = "\x1b[32m";   const yellow = "\x1b[33m";   const blue = "\x1b[34m";   const magenta = "\x1b[35m";   const cyan = "\x1b[36m";   const white = "\x1b[37m";   const arr=[];     /* Storing the color codes in Array */   arr[0] = black;     arr[1] = red;   arr[2] = green;   arr[3] = yellow;   arr[4] = blue;   arr[5] = magenta;   arr[6] = cyan;   arr[7] = white;   console.log(arr[color]+data);}  /* colorHelper function called with color and data */colorHelper(1,"I am Red");  colorHelper(2,"I am Green");colorHelper(5,"I am Magenta");</script>
Output: 
javascript-basics
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to detect browser or tab closing in JavaScript ?
How to get character array from string in JavaScript?
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
\backsimeq - Tex Command

\backsimeq - Command to show back sim equal symbol
{ \backsimeq }
\backsimeq command shows back sim symbol.

\backsimeq 

⋍



\backsimeq 

⋍


\backsimeq 

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
How to change a table's fontsize with matplotlib.pyplot?

To change a table's fontsize with matplotlib, we can use set_fontsize() method.
Create a figure and a set of subplots, nrows=1 and ncols=1.
Create random data using numpy.
Create columns value.
Make the axis tight and off.
Initialize a variable fontsize to change the font size.
Set the font size of the table using set_font_size() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, axs = plt.subplots(1, 1)
data = np.random.random((10, 3))
columns = ("Column I", "Column II", "Column III")
axs.axis('tight')
axs.axis('off')
the_table = axs.table(cellText=data, colLabels=columns, loc='center')
the_table.auto_set_font_size(False)
the_table.set_fontsize(10)
plt.show()
RSpec - Helpers

Sometimes your RSpec examples need an easy way to share reusable code. The best way to accomplish this is with Helpers. Helpers are basically regular Ruby methods which you share across examples. To illustrate the benefit of using helpers, let’s consider this code −
class Dog 
   attr_reader :good_dog, :has_been_walked 
   
   def initialize(good_or_not) 
      @good_dog = good_or_not 
      @has_been_walked = false 
   end 
   
   def walk_dog 
      @has_been_walked = true 
   end 
end 

describe Dog do 
   it 'should be able to create and walk a good dog' do 
      dog = Dog.new(true) 
      dog.walk_dog 
      
      expect(dog.good_dog).to be true
      expect(dog.has_been_walked).to be true 
   end 
   
   it 'should be able to create and walk a bad dog' do 
      dog = Dog.new(false) 
      dog.walk_dog 

      expect(dog.good_dog).to be false
      expect(dog.has_been_walked).to be true 
 
   end 
end
This code is clear, but it’s always a good idea to reduce repeated code whenever possible. We can take the above code and reduce some of this repetition with a helper method called create_and_walk_dog().
class Dog
   attr_reader :good_dog, :has_been_walked 
   
   def initialize(good_or_not)
      @good_dog = good_or_not 
      @has_been_walked = false 
   end 
   
   def walk_dog 
      @has_been_walked = true 
   end 
end 

describe Dog do 
   def create_and_walk_dog(good_or_bad)
      dog = Dog.new(good_or_bad)
      dog.walk_dog
      return dog 
   end 
   
   it 'should be able to create and walk a good dog' do
      dog = create_and_walk_dog(true)
      
      expect(dog.good_dog).to be true
      expect(dog.has_been_walked).to be true 
   end 
   
   it 'should be able to create and walk a bad dog' do 
      dog = create_and_walk_dog(false)
      
      expect(dog.good_dog).to be false
      expect(dog.has_been_walked).to be true 
   end 
end
When you run the above code, you will see this output −
.. 
Finished in 0.002 seconds (files took 0.11401 seconds to load) 
2 examples, 0 failures

As you can see, we were able to push the logic for creating and walking a dog object into a Helper which allows our examples to be shorter and cleaner.

    9 Lectures 
     37 mins

 Harshit Srivastava

    27 Lectures 
     7 hours 

 Atul Tiwari
 Print
 Add Notes
 Bookmark this page
Batch Script - NET STATISTICS

Display network statistics of the workstation or server.
Net statistics [SERVER/WORKSTATION]

Net statistics Server
Server Statistics for \\WIN-50GP30FGO75


Statistics since 1/3/2016 9:16:28 PM


Sessions accepted                 0
Sessions timed-out                0
Sessions errored-out              0

Kilobytes sent                    0
Kilobytes received                0

Mean response time (msec)         0

System errors                     0
Permission violations             0
Password violations               0

Files accessed                    0
Communication devices accessed    0
Print jobs spooled                0

Times buffers exhausted

Big buffers                       0
Request buffers                   0

 Print
 Add Notes
 Bookmark this page
Bootstrap pre tag styling

If the code needs to be displayed as a standalone block element or if it has multiple lines, then you should use the <pre> tag.
You can try to run the following code to implement the pre tag for code −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <pre>
         <h1>Heading One</h1>
         <h2>Heading Two</h2>
      </pre>
   </body>
</html>
Program to replace all digits with characters using Python

Suppose we have an alphanumeric string s that contains lowercase English letters in its even positions and digits in its odd positions. Consider an operation shift(c, x), where c is any character and x is a number (digit), this will find the xth character after c. So, for example, shift('p', 5) = 'u' and shift('a', 0) = 'a'. Now for every odd index i, we want to replace the digit s[i] with shift(s[i-1], s[i]). We have to find s after replacing all digits.
So, if the input is like s = "a2b1d4f3h2", then the output will be "acbcdhfihj" because
shift('a', 2) = 'c'
shift('a', 2) = 'c'
shift('b', 1) = 'c'
shift('b', 1) = 'c'
shift('d', 4) = 'h'
shift('d', 4) = 'h'
shift('f', 3) = 'i'
shift('f', 3) = 'i'
shift('h', 2) = 'j'
shift('h', 2) = 'j'
To solve this, we will follow these steps −
res:= blank string
res:= blank string
for i in range 0 to size of s, doif s[i] is a digit, thenres := res concatenate character from (ASCII s[i] + ASCII of s[i-1])otherwise,res := res concatenate s[i]
for i in range 0 to size of s, do
if s[i] is a digit, thenres := res concatenate character from (ASCII s[i] + ASCII of s[i-1])
if s[i] is a digit, then
res := res concatenate character from (ASCII s[i] + ASCII of s[i-1])
res := res concatenate character from (ASCII s[i] + ASCII of s[i-1])
otherwise,res := res concatenate s[i]
otherwise,
res := res concatenate s[i]
res := res concatenate s[i]
return res
return res
Let us see the following implementation to get better understanding −
 Live Demo
def solve(s):
   res=""
   for i in range(len(s)):
      if s[i].isdigit():
         res+= chr(int(s[i])+ord(s[i-1]))
      else:
         res+=s[i]
   return res
s = "a2b1d4f3h2"
print(solve(s))
"a2b1d4f3h2"
acbcdhfihj
How to extract the p-value from t test in R?

To extract the p-value from t test in R, we can follow the below steps −
First of all, create a data frame with numerical column or a numerical vector.
Then, use t.test function to perform the test and put $p.value at the end to extract the p-value from the test output.
Create the data frame
Let's create a data frame as shown below −
 Live Demo
x<-rnorm(20,5,1)
df<-data.frame(x)
df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
   x
1 5.854093
2 6.075394
3 5.114147
4 3.672250
5 6.519127
6 5.145577
7 3.005657
8 2.994189
9 6.031218
10 4.981937
11 5.359909
12 4.914696
13 4.767514
14 6.090447
15 5.644259
16 6.210392
17 4.097178
18 5.242026
19 4.999231
20 5.494340
Using t.test function to perform the t-test on column x of df and extract the p-value with $p.value −
 Live Demo
x<-rnorm(20,5,1)
df<-data.frame(x)
t.test(df$x,mu=5.8,alternative="less")$p.value
[1] 0.003168284
Create the vector
Let’s create a vector as shown below −
 Live Demo
y<-sample(1:1000,200)
y
[1] 761 40 629 167 687 200 873 481 218 708 315 649 119 16 603 177 733 852
[19] 925 940 693 620 146 416 13 790 79 464 801 543 91 754 505 235 549 770
[37] 630 991 762 703 805 713 968 316 883 52 717 747 121 756 773 308 283 372
[55] 425 918 391 997 276 912 253 874 281 76 759 658 197 516 917 126 26 615
[73] 240 10 84 676 766 553 286 307 877 778 560 994 736 75 295 697 864 256
[91] 70 50 739 686 66 902 836 125 606 194 819 462 900 891 213 68 808 834
[109] 501 945 325 140 107 531 311 755 169 361 663 577 590 589 211 889 684 257
[127] 580 180 318 872 839 413 936 503 246 190 333 178 46 434 894 365 669 937
[145] 884 752 840 656 698 757 984 772 933 139 317 626 591 502 189 53 410 751
[163] 351 72 645 944 170 465 628 639 243 844 493 855 709 913 710 993 858 504
[181] 596 585 350 618 942 934 980 490 782 699 722 284 740 715 562 156 210 767
[199] 621 19
Using t.test function to perform the t-test on vector x and extract the p-value with $p.value −
 Live Demo
y<-sample(1:1000,200)
t.test(y,mu=500,alternative="greater")$p.value
[1] 0.04181906
How to auto-increment the property of a JSONObject in Java?

A JSONObject is an unordered collection of name/value pairs and parses text from a String to produce a map-like object. However, we can auto-increment the property of a JSONObject using the increment() method of JSONObject class. If there is no such property, create one with a value of 1. If there is such a property and if it is an Integer, Long, Double or Float then add one to it.
public JSONObject increment(java.lang.String key) throws JSONException
import org.json.JSONException;
import org.json.JSONObject;
public class IncrementJSONObjectTest {
   public static void main(String[] args) throws JSONException {
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("year", 2019);
      jsonObj.put("age", 25);
      System.out.println(jsonObj.toString(3));
      jsonObj.increment("year").increment("age");
      System.out.println(jsonObj.toString(3));
      jsonObj.increment("year").increment("age");
      System.out.println(jsonObj.toString(3));
      jsonObj.increment("year").increment("age");
      System.out.println(jsonObj.toString(3));
   }
}
{
 "year": 2019,
 "age": 25
}
{
 "year": 2020,
 "age": 26
}
{
 "year": 2021,
 "age": 27
}
{
 "year": 2022,
 "age": 28
}
Tryit Editor v3.7

Tryit: Sort the flex items
PyQt5 - Gradient Color Progress Bar - GeeksforGeeks

22 Apr, 2020
In this article we will see how we can set gradient color to the progress bar. Below is how normal color progress bar looks like vs the gradient color progress bar looks like. 
In order to do this we have to change the CSS style sheet, below is the code for style sheet.
QProgressBar::chunk 
{
border : 1px solid black;
background: QLinearGradient( x1: 0, y1: 0,
                             x2: 1, y2: 0, 
                          stop: 0 #000fff, 
                          stop: 1 #ff000f );
}

Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):        # creating progress bar        bar = QProgressBar(self)          # setting geometry to progress bar        bar.setGeometry(200, 150, 200, 30)          # set value to progress bar        bar.setValue(30)          # setting alignment to center        bar.setAlignment(Qt.AlignCenter)          # setting gradient color to progress bar        bar.setStyleSheet("QProgressBar"                          "{"                          "border : 1px solid black;"                          "background: QLinearGradient( x1: 0, y1: 0,                                                        x2: 1, y2: 0,                                                    stop: 0 # 00ffff,                                                    stop: 1 # ff000f );"                          "}")    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python 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
Tryit Editor v3.7

Tryit: Link URL's
Java Integer compare() method

05 Dec, 2018
The compare() method of Integer class of java.lang package compares two integer values (x, y) givenas a parameter and returns the value zero if (x==y), if (x < y) then it returns a value less than zero andif (x > y) then it returns a value greater than zero.
Syntax :
public static int compare(int x, int y)
Parameter :
x : the first int to compare
y : the second int to compare
Return :
This method returns the value zero if (x==y), 
if (x < y) then it returns a value less than zero 
and if (x > y) then it returns a value greater than zero.

Example :To show working of java.lang.Integer.compare() method.
// Java program to demonstrate working// of java.lang.Integer.compare() methodimport java.lang.Integer;  class Gfg {    // driver code    public static void main(String args[])    {        int a = 10;        int b = 20;          // as 10 less than 20, Output will be a value less than zero        System.out.println(Integer.compare(a, b));          int x = 30;        int y = 30;          // as 30 equals 30, Output will be zero        System.out.println(Integer.compare(x, y));          int w = 15;        int z = 8;          // as 15 is greater than 8, Output will be a value greater than zero        System.out.println(Integer.compare(w, z));    }}
Output:
-1
0
1

Java-Functions
Java-Integer
Java-lang package
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
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
SQL query to find unique column values from table

13 Aug, 2020
We take a sample table named Geeks and return unique column values by applying various SQL queries on it.
SQL query to find unique values of column department from Geeks table.
Select distinct DEPARTMENT 
from Geeks;
Output –
SQL query to find details of column department where name as “DBA”.
Select * 
from Geeks 
where DEPARTMENT like 'DBA%';
Output –
SQL query to find the count of rows in the department ‘Admin’.
SELECT COUNT(*) 
FROM Geeks 
WHERE DEPARTMENT = 'Admin';
Output –
DBMS-SQL
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
MySQL | Regular expressions (Regexp)
Difference between OLAP and OLTP in DBMS
OLAP Guidelines (Codd's Rule)
What is Temporary Table in SQL?
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
Programming 8051 using Keil Software

In this section we will see how to write and execute programs for 8051 microcontroller using the Keil Software.
Here is the download link of Keil. You can download it and install it very easily. We are using C51 version for 8051 devices.
https://www.keil.com/download/product/
Start the Keil software. Go to the Project > New Project then choose a location to store your program, and give a name and Save.
Start the Keil software. Go to the Project > New Project then choose a location to store your program, and give a name and Save.
Now in the next window select the device from different manufacturers. We are selecting Microchip, and then by expanding we are selecting AT89C51 device and click ok.
Now in the next window select the device from different manufacturers. We are selecting Microchip, and then by expanding we are selecting AT89C51 device and click ok.
Now go to the New in the menu and select New. It will open a new editor to write code.
Now go to the New in the menu and select New. It will open a new editor to write code.
Go to the save option and save the program file with .c extension.
Go to the save option and save the program file with .c extension.
Write the code for 8051 Microcontroller. (Here we are using a code for blinking LED in 500 ms)
Write the code for 8051 Microcontroller. (Here we are using a code for blinking LED in 500 ms)
Now from the left panel, select Source Group 1, and Add Existing Files to Group ‘Source Group 1’. Then select the program (c file) then add and close.
Now from the left panel, select Source Group 1, and Add Existing Files to Group ‘Source Group 1’. Then select the program (c file) then add and close.
Now go to the Project > Build Target to build the project. If there is some error the building will be failed, after correcting the errors it can be build.
Now go to the Project > Build Target to build the project. If there is some error the building will be failed, after correcting the errors it can be build.
Now click on the Target1 from the left panel and select Options for Target ‘Target1’. Then set the xtal (MHz) value to 11.0592. Check mark on the Use On Chip ROM. Then go to the output tab. In this tab check Create Hex File, and click OK. Then build it again.
Now click on the Target1 from the left panel and select Options for Target ‘Target1’. Then set the xtal (MHz) value to 11.0592. Check mark on the Use On Chip ROM. Then go to the output tab. In this tab check Create Hex File, and click OK. Then build it again.
By uploading this hex file into the 8051 microcontroller the program can be loaded into it. And it will work.
Here we have used the following code −
#include<reg51.h>
sbit LED_pin = P2^0; //set the LED pin as P2.0
void delay(int ms){
   unsigned int i, j;
   for(i = 0; i< ms; i++){
      // Outer for loop for given milliseconds value
      for(j = 0; j < 1275; j++){
         //execute in each milliseconds;
      }
   }
}
void main(){
   while(1){
      //infinite loop for LED blinking
      LED_pin = 0;
      delay(500); //wait for 500 milliseconds
      LED_pin = 1;
      delay(500); //wait for 500 milliseconds
   }
}
The connection is like below
Tryit Editor v3.7

Tryit: Different border color for each side
Program to rotate square matrix by 90 degrees counterclockwise in Python

Suppose we have a square matrix, we have to rotate it 90 degrees counter-clockwise.
then the output will be
To solve this, we will follow these steps −
if matrix is empty, thenreturn a blank list
if matrix is empty, then
return a blank list
return a blank list
n := row count of matrix
n := row count of matrix
for each row in matrix, doreverse the row
for each row in matrix, do
reverse the row
reverse the row
for i in range 0 to n−1, dofor j in range 0 to i−1, doswap matrix[i, j] and matrix[j, i]
for i in range 0 to n−1, do
for j in range 0 to i−1, doswap matrix[i, j] and matrix[j, i]
for j in range 0 to i−1, do
swap matrix[i, j] and matrix[j, i]
swap matrix[i, j] and matrix[j, i]
return matrix
return matrix
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, matrix):
      if not matrix or not matrix[0]:
         return []
      n = len(matrix)
      for row in matrix:
         row.reverse()
      for i in range(n):
         for j in range(i):
            matrix[i][j], matrix[j][i] = matrix[j][i],
            matrix[i][j]
      return matrix
ob = Solution()
matrix = [
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]
print(ob.solve(matrix))
[
[1, 4, 7],
[2, 5, 8],
[3, 6, 9] ]
[
[7, 8, 9],
[4, 5, 6],
[1, 2, 3]]
What is the scope of local variables in Java?

Scope of a variable denotes span of a variable.
The scope of a local variable is within that method i.e. when we create a variable with in a method, it cannot be accessed outside that method.
If you observe the following example here, we have created a variable named num in the main method and, trying to access it in another method (demo).
public class SampleTest {
   String str = "sampleString";
   
   public static void main(String args[]){
      int num = 334;
   }
   public void demo(){
      System.out.println(num);
   }
}
Since we cannot access a local variable (variable of a method) outside it, the compiler generates an error as −
C:\Sample>javac SampleTest.java
SampleTest.java:7: error: cannot find symbol
System.out.println(num);
                   ^
symbol: variable num
location: class SampleTest
1 error
Difference between String and StringBuilder in C#

String is immutable in C# that would mean you couldn’t modify it after it is created. It creates a new object of string type in memory if you will perform any operation.
string str1 = "Welcome!";
// creates a new string instance
str1 += "Hello";
str1 += "World”;

StringBuilder is mutable in C#. This means that if an operation is performed on the string, it will not create a new instance every time. With that, it will not create new space in memory, unlike Strings.
StringBuilder str1 = new StringBuilder("");
str1.Append("Welcome!");
str1.Append("Hello World!");
string str2 = str1.ToString();
Find product of prime numbers between 1 to n in C++

Suppose we have a number n. We have to find the product of prime numbers between 1 to n. So if n = 7, then output will be 210, as 2 * 3 * 5 * 7 = 210.
We will use the Sieve of Eratosthenes method to find all primes. Then calculate the product of them.
 Live Demo
#include<iostream>
using namespace std;
long PrimeProds(int n) {
   bool prime[n + 1];
   for(int i = 0; i<=n; i++){
      prime[i] = true;
   }
   for (int i = 2; i * i <= n; i++) {
      if (prime[i] == true) {
         for (int j = i * 2; j <= n; j += i)
         prime[j] = false;
      }
   }
   long product = 1;
   for (int i = 2; i <= n; i++)
   if (prime[i])
      product *= i;
   return product;
}
int main() {
   int n = 8;
   cout << "Product of primes up to " << n << " is: " << PrimeProds(n);
}
Product of primes up to 8 is: 210
C Program To Check Whether Two Strings Are Anagram Of Each Other - GeeksforGeeks

20 Dec, 2021
Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is another string that contains the same characters, only the order of characters can be different. For example, “abcd” and “dabc” are an anagram of each other.
Method (Count characters): This method assumes that the set of possible characters in both strings is small. In the following implementation, it is assumed that the characters are stored using 8 bit and there can be 256 possible characters. 
Create count arrays of size 256 for both strings. Initialize all values in count arrays as 0.Iterate through every character of both strings and increment the count of character in the corresponding count arrays.Compare count arrays. If both count arrays are same, then return true.
Create count arrays of size 256 for both strings. Initialize all values in count arrays as 0.
Iterate through every character of both strings and increment the count of character in the corresponding count arrays.
Compare count arrays. If both count arrays are same, then return true.
Below is the implementation of the above idea:
C
// C program to check if two strings// are anagrams of each other#include <stdio.h>#define NO_OF_CHARS 256  /* Function to check whether two    strings are anagram of each other */bool areAnagram(char* str1, char* str2){    // Create 2 count arrays and initialize     // all values as 0    int count1[NO_OF_CHARS] = {0};    int count2[NO_OF_CHARS] = {0};    int i;      // For each character in input strings,     // increment count in the corresponding     // count array    for (i = 0; str1[i] && str2[i]; i++)     {        count1[str1[i]]++;        count2[str2[i]]++;    }      // If both strings are of different length.     // Removing this condition will make the     // program fail for strings like "aaca"     // and "aca"    if (str1[i] || str2[i])        return false;      // Compare count arrays    for (i = 0; i < NO_OF_CHARS; i++)        if (count1[i] != count2[i])            return false;      return true;}  // Driver codeint main(){    char str1[] = "geeksforgeeks";    char str2[] = "forgeeksgeeks";        // Function Call    if (areAnagram(str1, str2))        printf(        "The two strings are anagram of each other");    else        printf("The two strings are not anagram of each "               "other");    return 0;}
Output: 
The two strings are anagram of each other
Please refer complete article on Check whether two strings are anagram of each other for more details!
Amazon
anagram
Goldman Sachs
Nagarro
C Programs
Strings
Amazon
Goldman Sachs
Nagarro
Strings
anagram
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Producer Consumer Problem in C
C program to find the length of a string
Exit codes in C/C++ with Examples
Regular expressions in C
Reverse a string in Java
Write a program to reverse an array or string
Longest Common Subsequence | DP-4
Write a program to print all permutations of a given string
C++ Data Types
How to convert Integer array list to integer array in Java?

To convert integer array list to integer array is not a tedious task. First, create an integer array list and add some elements to it −
ArrayList < Integer > arrList = new ArrayList < Integer > ();
arrList.add(100);
arrList.add(200);
arrList.add(300);
arrList.add(400);
arrList.add(500);
Now, assign each value of the integer array list to integer array. We used size() to get the size of the integer array list and placed the same size to the newly created integer array −
final int[] arr = new int[arrList.size()];
int index = 0;
for (final Integer value: arrList) {
   arr[index++] = value;
}
 Live Demo
import java.util.ArrayList;
public class Demo {
   public static void main(String[] args) {
      ArrayList<Integer>arrList = new ArrayList<Integer>();
      arrList.add(100);
      arrList.add(200);
      arrList.add(300);
      arrList.add(400);
      arrList.add(500);
      arrList.add(600);
      arrList.add(700);
      arrList.add(800);
      arrList.add(900);
      arrList.add(1000);
      final int[] arr = new int[arrList.size()];
      int index = 0;
      for (final Integer value : arrList) {
         arr[index++] = value;
      }
      System.out.println("Elements of int array...");
      for (Integer i : arr) {
         System.out.println(i);
      }
   }
}
Elements of int array...
100
200
300
400
500
600
700
800
900
1000
Pandas - Cleaning Data

Data cleaning means fixing bad data in your data set.
Bad data could be: 
Empty cells
Data in wrong format
Wrong data
Duplicates
In this tutorial you will learn how to deal with all of them.
In the next chapters we will use this data set:

      Duration          Date  Pulse  Maxpulse  Calories
  0         60  '2020/12/01'    110       130     409.1
  1         60  '2020/12/02'    117       145     479.0
  2         60  '2020/12/03'    103       135     340.0
  3         45  '2020/12/04'    109       175     282.4
  4         45  '2020/12/05'    117       148     406.0
  5         60  '2020/12/06'    102       127     300.0
  6         60  '2020/12/07'    110       136     374.0
  7        450  '2020/12/08'    104       134     253.3
  8         30  '2020/12/09'    109       133     195.1
  9         60  '2020/12/10'     98       124     269.0
  10        60  '2020/12/11'    103       147     329.3
  11        60  '2020/12/12'    100       120     250.7
  12        60  '2020/12/12'    100       120     250.7
  13        60  '2020/12/13'    106       128     345.3
  14        60  '2020/12/14'    104       132     379.3
  15        60  '2020/12/15'     98       123     275.0
  16        60  '2020/12/16'     98       120     215.2
  17        60  '2020/12/17'    100       120     300.0
  18        45  '2020/12/18'     90       112       NaN
  19        60  '2020/12/19'    103       123     323.0
  20        45  '2020/12/20'     97       125     243.0
  21        60  '2020/12/21'    108       131     364.2
  22        45           NaN    100       119     282.0
  23        60  '2020/12/23'    130       101     300.0
  24        45  '2020/12/24'    105       132     246.0
  25        60  '2020/12/25'    102       126     334.5
  26        60    2020/12/26    100       120     250.0
  27        60  '2020/12/27'     92       118     241.0
  28        60  '2020/12/28'    103       132       NaN
  29        60  '2020/12/29'    100       132     280.0
  30        60  '2020/12/30'    102       129     380.3
  31        60  '2020/12/31'     92       115     243.0


The data set contains some empty cells ("Date" in row 22, and "Calories" in row 18 and 28).
The data set contains wrong format ("Date" in row 26).
The data set contains wrong data ("Duration" in row 7).
The data set contains duplicates (row 11 and 12).
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.
Jackson Annotations - @JsonSerialize

@JsonSerialize is used to specify custom serializer to marshall the json object.
import java.io.IOException; 
import java.text.ParseException; 
import java.text.SimpleDateFormat; 
import java.util.Date; 

import com.fasterxml.jackson.core.JsonGenerator; 
import com.fasterxml.jackson.databind.ObjectMapper; 
import com.fasterxml.jackson.databind.SerializerProvider; 
import com.fasterxml.jackson.databind.annotation.JsonSerialize; 
import com.fasterxml.jackson.databind.ser.std.StdSerializer; 

public class JacksonTester {
   public static void main(String args[]) throws ParseException {
      ObjectMapper mapper = new ObjectMapper(); 
      SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); 
      try {
         Student student = new Student("Mark", 1, dateFormat.parse("20-11-1984")); 
         String jsonString = mapper 
            .writerWithDefaultPrettyPrinter() 
            .writeValueAsString(student); 
         System.out.println(jsonString); 
      } 
      catch (IOException e) { 
         e.printStackTrace(); 
      }   
   }
}
class Student {
   private String name; 
   private int rollNo; 
   @JsonSerialize(using = CustomDateSerializer.class) 
   private Date dateOfBirth; 
   public Student(String name, int rollNo, Date dob){ 
      this.name = name; 
      this.rollNo = rollNo; 
      this.dateOfBirth = dob; 
   }
   public String getName(){
      return name;
   }
   public int getRollNo(){
      return rollNo; 
   }
   public Date getDateOfBirth(){ 
      return dateOfBirth; 
   }
}
class CustomDateSerializer extends StdSerializer<Date> {
   private static final long serialVersionUID = 1L; 
   private static SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
   public CustomDateSerializer() { 
      this(null); 
   } 
   public CustomDateSerializer(Class<Date> t) { 
      super(t); 
   } 
   @Override 
   public void serialize(Date value, 
      JsonGenerator generator, SerializerProvider arg2) throws IOException { 
      generator.writeString(formatter.format(value)); 
   } 
}
{
   "name" : "Mark",
   "rollNo" : 1,
   "dateOfBirth" : "20-11-1984"
}

 Print
 Add Notes
 Bookmark this page
How to add a YouTube Video to your Website?

To add a YouTube Video to your website, you need to embed it. To embed a video in an HTML page, use the <iframe> element. The source attribute included the video URL. For the dimensions of the video player, set the width and height of the video appropriately.
The Video URL is the video embed link. The video we will be embedding our example will be YouTube.To get the embed link, go to a YouTube Video and click embed as shown below. You will get a link fro embed here −
You can try to run the following code to learn how to embed a video using HTML code. Copy the embed link as shown above and add it to the HTML document
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Video embed</title>
   </head>
   <body>
      <p>Learn Eclipse</p>
      <br />
      <iframe width="560" height="315" src="https://www.youtube.com/embed/y881t8ilMyc" frameborder="0" allowfullscreen></iframe>
      </iframe>
   </body>
</html>
Groovy - sort()

Returns a sorted copy of the original List.
List sort()

None
The sorted list.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      def lst = [13, 12, 15, 14]; 
      def newlst = lst.sort(); 
      println(newlst);
   }
}
When we run the above program, we will get the following result −
[12, 13, 14, 15]


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page