code-rag-bench/online-tutorials huggingface dataset:
Python program to capitalize the first and last character of each word in a string

01 Jun, 2022
Given the string, the task is to capitalise the first and last character of each word in a string. Examples:
Input: hello world 
Output: HellO WorlD

Input: welcome to geeksforgeeks
Output: WelcomE TO GeeksforgeekS
Approach:
Access the last element using indexing.
Capitalize the first word using title() method.
Then join the each word using join() method.
Perform all the operations inside lambda for writing the code in one-line.
Below is the implementation. 
Python3
# Python program to capitalize# first and last character of# each word of a String  # Function to do the samedef word_both_cap(str):         #lambda function for capitalizing the    # first and last letter of words in    # the string    return ' '.join(map(lambda s: s[:-1]+s[-1].upper(),                        s.title().split()))          # Driver's codes = "welcome to geeksforgeeks"print("String before:", s)print("String after:", word_both_cap(str))
Output:
String before: welcome to geeksforgeeks
String after: WelcomE TO GeeksforgeekS
sweetyty
Python string-programs
python-string
Technical Scripter 2019
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to draw a circle with gradient border using CSS ?

13 May, 2020
CSS is used to create various shapes and styles with different colors or gradient. In this article, we will learn how to draw a circle with a gradient border.
Approach: We are going to create two div one is outer div with class outer_circle and another is inner div with class inner_circle. Outer div contains the big circle with gradient colour and inner div contains a small white circle which acts as an inner end of the circle creating a border of the circle. The linear-gradient is a CSS function which we are going to use to set a linear gradient as the background image.
Syntax:
 .class_name { background-image: linear-gradient(direction, color1, color2 } 
Parameters: This function accept three parameters as mentioned above and described below:
$direction: It specifies the direction to move the gradient.
$color1: It specifies the first colour stop.
$color2: It specifies the second colour stop.
Program: We can use the linear-gradient function to draw a circle with gradient border as given below:
<!DOCTYPE html><html>  <head>    <!-- CSS -->    <style>        .outer_circle {            position: relative;            margin: 50px;            width: 100px;            height: 100px;            border-radius: 50%;            background: #ffffff;        }                  .inner_circle {            background-image: linear-gradient(                     to bottom, rgb(9, 112, 26) 0%,                     rgb(21, 255, 0) 100%);            content: '';            position: absolute;            top: -20px;            bottom: -20px;            right: -20px;            left: -20px;            z-index: -1;            border-radius: inherit;        }    </style></head>  <body>    <div class="outer_circle">        <div class="inner_circle"></div>    </div></body>  </html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is the use of EXIST and EXIST NOT operator with MySQL subqueries?

The EXIST operator test for the existence of rows in the result set of the subquery. If a subquery row value is found then EXISTS subquery is TRUE and NOT EXISTS subquery if FALSE. To illustrate it we are using the tables ‘Cars’, ‘Customers’ and ‘Reservations’ having the following data −
mysql> Select * from Cars;
+------+--------------+---------+
| ID   | Name         | Price   |
+------+--------------+---------+
|    1 | Nexa         | 750000  |
|    2 | Maruti Swift | 450000  |
|    3 | BMW          | 4450000 |
|    4 | VOLVO        | 2250000 |
|    5 | Alto         | 250000  |
|    6 | Skoda        | 1250000 |
|    7 | Toyota       | 2400000 |
|    8 | Ford         | 1100000 |
+------+--------------+---------+
8 rows in set (0.02 sec)

mysql> Select * from Customers;
+-------------+----------+
| Customer_Id | Name     |
+-------------+----------+
|           1 | Rahul    |
|           2 | Yashpal  |
|           3 | Gaurav   |
|           4 | Virender |
+-------------+----------+
4 rows in set (0.00 sec)

mysql> Select * from Reservations;
+------+-------------+------------+
| ID   | Customer_id | Day        |
+------+-------------+------------+
|    1 |           1 | 2017-12-30 |
|    2 |           2 | 2017-12-28 |
|    3 |           2 | 2017-12-29 |
|    4 |           1 | 2017-12-25 |
|    5 |           3 | 2017-12-26 |
+------+-------------+------------+
5 rows in set (0.00 sec)
Following is MySQL subquery with EXIST using the above-mentioned tables −
mysql> Select Name from customers WHERE EXISTS (SELECT * FROM Reservations WHERE Customers.customer_id = Reservations.customer_id);
+---------+
| Name    |
+---------+
| Rahul   |
| Yashpal |
| Gaurav  |
+---------+
3 rows in set (0.06 sec)
The above query gives the names of the customers who have made a reservation.
Following is MySQL subquery with NOT EXIST using the above-mentioned tables −
mysql> Select Name from customers WHERE NOT EXISTS (SELECT * FROM Reservations WHERE Customers.customer_id = Reservations.customer_id);
+----------+
| Name     |
+----------+
| Virender |
+----------+
1 row in set (0.04 sec)
The above query gives the names of the customers who have not made any reservation.
Convert from String to long in Java

To convert String to long, the following are the two methods.
The following is an example wherein we use parseLong() method.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String myStr = "5";
      Long myLong = Long.parseLong(myStr);
      System.out.println("Long: "+myLong);
   }
}
Long: 5
The following is an example wherein we have used valueOf() and longValue() method to convert String to long.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String myStr = "20";
      long res = Long.valueOf(myStr).longValue();
      System.out.println("Long: "+res);
   }
}
Long: 20
How to use equals () in Android textview?

This example demonstrate about How to use equals () in Android textview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step  − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/name"
      android:layout_width="match_parent"
      android:hint="Enter name"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:text="Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:textSize="25sp"
      android:layout_height="wrap_content" />
</LinearLayout>
In the above code, we have taken name as Edit text, when user click on button it will take data and check that given string contains “point”.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
   EditText name;
   Button button;
   TextView text;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      name = findViewById(R.id.name);
      button = findViewById(R.id.click);
      text = findViewById(R.id.textview);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            if (!name.getText().toString().isEmpty()) {
               if (name.getText().toString().length() >= 0) {
                  text.setText(String.valueOf(name.getText().toString().equals("point")));
               }
            } else {
               name.setError("Plz enter name");
            }
         }
      });
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, enter the string as point and it returned true because it contained point string in given string. Now enter other string without point it gives the result as false as shown below −
Click here to download the project code
How to use Container Component in ReactJS? - GeeksforGeeks

18 Jan, 2021
The container centers your content horizontally. It’s the most basic layout element. Material UI for React has this component available for us and it is very easy to integrate. We can the Container component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react'import Typography from '@material-ui/core/Typography';import Container from '@material-ui/core/Container';  const App = () => {  return (    <Container maxWidth="sm">      <Typography component="div" style={{         backgroundColor: 'Orange', height: '100vh'       }}>        Greetings from GeeksforGeeks      </Typography>    </Container>  );}  export default App
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
Difference between Public and Private in C++ with Example - GeeksforGeeks

15 Oct, 2019
Public
All the class members declared under public will be available to everyone. The data members and member functions declared public can be accessed by other classes too. The public members of a class can be accessed from anywhere in the program using the direct member access operator (.) with the object of that class.
Example:
// C++ program to demonstrate public// access modifier  #include <iostream>using namespace std;  // class definitionclass Circle {public:    double radius;      double compute_area()    {        return 3.14 * radius * radius;    }};  // main functionint main(){    Circle obj;      // accessing public data member outside class    obj.radius = 5.5;      cout << "Radius is: " << obj.radius << "\n";    cout << "Area is: " << obj.compute_area();    return 0;}
Radius is: 5.5
Area is: 94.985

In the above program, the data member radius is public so we are allowed to access it outside the class.
Private
The class members declared as private can be accessed only by the functions inside the class. They are not allowed to be accessed directly by any object or function outside the class. Only the member functions or the friend functions are allowed to access the private data members of a class.Example:
// C++ program to demonstrate private// access modifier  #include <iostream>using namespace std;  class Circle {    // private data memberprivate:    double radius;      // public member functionpublic:    void compute_area(double r)    {        // member function can access private        // data member radius        radius = r;          double area = 3.14 * radius * radius;          cout << "Radius is: " << radius << endl;        cout << "Area is: " << area;    }};  // main functionint main(){    // creating object of the class    Circle obj;      // trying to access private data member    // directly outside the class    obj.compute_area(1.5);      return 0;}
Radius is: 1.5
Area is: 7.065

Difference between Public and Private
C++ Programs
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Passing a function as a parameter in C++
Program to implement Singly Linked List in C++ using class
Const keyword in C++
cout in C++
Dynamic _Cast in C++
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
Print Function in C, C++, and Python - GeeksforGeeks

08 Mar, 2021
In this article, the task is to observe the behavior of the print function in C, C++, and Python. Print function is used to display content on the screen.
Approach: 
Some characters are stored in integer value inside printf function.
Printing the value as well as the count of the characters.
Illustrating the different use of printf().
Below is the C program printing the inside printf:
C
// C program printing inside printf()  #include <stdio.h>  // Driver Codeint main(){    // Stores no of characters printed by printf    int val = printf("GeeksForGeeks\n");        // Print the count of characters    printf("Int printf(\"GeeksForGeeks\\n \") = %d\n", val);            return 0;}
GeeksForGeeks
Int printf("GeeksForGeeks\n ") = 14
Below is the C++ program printing inside cout:
C++
// C++ program printing inside cout  #include <iostream>using namespace std;  // Driver Codeint main(){      // Store no of characters printed by printf    int value = printf("GeeksForGeeks\n");        // Prints the count of the characters      cout << "Integer printf(\"GeeksForGeeks\\n\") = "         << value << endl;}
GeeksForGeeks
Integer printf("GeeksForGeeks\n") = 14
Explanation:
In both the above code, printf returns the number of character it has printed successfully.
“GeeksForGeeks\n” have 14 characters hence it will print 14.
Below is the python program illustrating print():
Python3
# Python program illustrating print()  # Storing valuevalue=print("GeeksForGeeks\n")  # Printing valueprint(value)
GeeksForGeeks

None
Explanation: In python3, Print function never returns anything that’s why it is returning None.
C Language
C++
Python
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
basic_istream::seekg() in C++ with Examples - GeeksforGeeks

28 May, 2020
The basic_stream::seekg() method is used to set position of the next character to be extracted from the input stream. This function is present in the iostream header file. Below is the syntax for the same:
Header File:
#include<iostream>

Syntax:
basic_istream& seekg (pos_type pos);

Parameter:
pos: It represents the new position in the buffer .
Return Value: This function returns the basic_istream object.
Below is the program to illustrate std::basic_istream::seekg()
Program 1:
// C++ code for basic_istream::seekg()  #include <bits/stdc++.h>using namespace std;  // Driver codeint main(){    string str = "Geeks for Geeks";    istringstream gfg(str);    string a, b;      gfg >> a;    gfg.seekg(0); // rewind    gfg >> b;      cout << "a = " << a << endl;    cout << "b = " << b << endl;}
a = Geeks
b = Geeks

Program 2:
// C++ code for basic_istream::seekg()  #include <bits/stdc++.h>using namespace std;  // Driver codeint main(){    string str = "Geeks for Geeks";    istringstream gfg(str);    string a, b;      gfg >> a;    gfg.seekg(6); // rewind    gfg >> b;      cout << "a = " << a << endl;    cout << "b = " << b << endl;}
a = Geeks
b = for

Reference: http://www.cplusplus.com/reference/istream/basic_istream/seekg/
CPP-Functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Queue in C++ Standard Template Library (STL)
Inline Functions in C++
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
Python IMDbPY – Getting top 250 movies - GeeksforGeeks

22 Apr, 2020
In this article we will see how we can retrieve the information of top 250 movies in IMDb database, IMDb sets ratings to all the movies.
In order to get the top 250 movies by IMDb we will use get_top250_movies method.
Syntax : imdb_object.get_top250_movies()
Argument : It takes no argument
Return : It returns list of 250 element and each element is idbm movie object
Below is the implementation
# importing the moduleimport imdb   # creating instance of IMDbia = imdb.IMDb()   # getting top 250 moviessearch = ia.get_top250_movies()  # printing only first 10 movies titlefor i in range(10):    print(search[i]['title'])
Output :
The Shawshank Redemption
The Godfather
The Godfather: Part II
The Dark Knight
12 Angry Men
Schindler's List
The Lord of the Rings: The Return of the King
Pulp Fiction
The Good, the Bad and the Ugly
The Lord of the Rings: The Fellowship of the Ring

Python IMDbPY-module
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
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
C# | Default Constructor - GeeksforGeeks

23 Jan, 2019
If you don’t provide a constructor for your class, C# creates one by default that instantiates the object and sets member variables to the default values as listed in the Default Values Table. Constructor without any parameters is called a default constructor. In other words, this type of constructor does not take parameters. The drawback of a default constructor is that every instance of the class will be initialized to the same values and it is not possible to initialize each instance of the class to different values.
The default constructor initializes:
All numeric fields in the class to zero.
All string and object fields to null.
Example 1:
// C# Program to illustrate the use// of Default Constructorusing System;  namespace GFG {      class multiplication{    int a, b;          // default Constructor    public multiplication()       {        a = 10;        b = 5;    }  // Main Methodpublic static void Main() {          // an object is created,     // constructor is called    multiplication obj = new multiplication();           Console.WriteLine(obj.a);    Console.WriteLine(obj.b);          Console.WriteLine("The result of multiplication is: "                                        +(obj.a * obj.b));}  }}
Output:
10
5
The result of multiplication is: 50

Example 2: In this example, the class Person does not have any constructors, in which case, a default constructor is automatically provided and the fields are initialized to their default values.
// C# Program to illustrate the use// of Default Constructorusing System;  public class Person{    public int age;    public string name;}    // Driver Classclass TestPerson {  // Main Methodstatic void Main() {      // object creation    Person pers = new Person();          Console.WriteLine("Name: {0}, Age: {1}", pers.name, pers.age);  }} 
Output:
Name: , Age: 0

Note: The output is so because a string is assigned to null by default and integers to 0.
CSharp-Basics
CSharp-OOP
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
Switch Statement in C#
Convert String to Character Array in C#
C# | How to insert an element in an Array?
Lambda Expressions in C#
Parallel Coordinates Plot using Plotly in Python - GeeksforGeeks

01 Oct, 2020
A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization library.
Parallel coordinates plot is a common way of visualizing and analyzing high-dimensional datasets. A point in n-dimensional space is represented as a polyline with vertices on the parallel axes and the position of the vertex corresponds to the coordinate of the point.
 Syntax: parallel_coordinates(data_frame=None, dimensions=None, labels={}, range_color=None)
Parameters:
data_frame: This argument needs to be passed for column names (and not keyword names) to be used. 
dimensions: Either names of columns in data_frame, or pandas Series, or array_like objects Values from these columns are used for multidimensional visualization.
labels: By default, column names are used in the figure for axis titles, legend entries and hovers. This parameter allows this to be overridden. The keys of this dict should correspond to column names, and the values should correspond to the desired label to be displayed.
range_color: If provided, overrides auto-scaling on the continuous color scale.
Example 1:
Python3
import plotly.express as px    df = px.data.tips()fig = px.parallel_coordinates(    df, dimensions=['tip', 'total_bill', 'day','time'],)  fig.show()
Output:
Example 2: Showing Parallel Coordinates Chart with go.Parcoords()
Python3
import plotly.graph_objects as go  fig = go.Figure(data=go.Parcoords(    line_color='green',    dimensions=list([        dict(range=[4, 9],             label='A', values=[5, 8]),        dict(range=[2, 7],             label='B', values=[3, 6]),    ])))  fig.show()
Output:
Example 3:
Python3
import plotly.graph_objects as goimport plotly.express as px  df = px.data.tips()  fig = go.Figure(data=go.Parcoords(    dimensions=list([        dict(range=[0, 8],             constraintrange=[4, 8],             label='Sepal Length', values=df['tip']),        dict(range=[0, 8],             label='Sepal Width', values=df['total_bill']),    ])))    fig.show()
Output:
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
HTTP headers | Content-Encoding - GeeksforGeeks

23 Oct, 2019
The HTTP headers Content-encoding is used to compress the media type. It informers the server which encoding the user will supported. It sends the information to the Accept-encoding. The server selects any one of the proposals, uses it and informs the client of its choice with the Content-Encoding response header.Syntax:
Content-Encoding: gzip | compress | deflate | br| identity

Note: Multiple algorithms can also be applied.
Directives:
gzip: It uses Lempel-Ziv coding (LZ77), with a 32-bit CRC format. It is the original format of UNIX gzip program.
compress: It uses Lempel-Ziv-Welch (LZW) algorithm. Due to patent issue, many modern browsers don’t support this type of content-encoding.
deflate: This format uses zlib structure with deflate compression algorithm.
br: It is a compression format using the Brotli algorithm.
identity: It is used to indicate that there is no compression.
You can check how good your Accept-Encoding and Content-Encoding is working on this site.
Example:
Single Compression:Content-Encoding: gzip
Content-Encoding: compress

Content-Encoding: gzip
Content-Encoding: compress

Multiple Compression:Content-Encoding: gzip, compress
To check the Content-Encoding in action go to Inspect Element -> Network check the request header for Content-Encoding like below, Content-Encoding is highlighted you can see.Supported Browsers: The browsers compatible with HTTP headers Content-Encoding are listed below:Google ChromeInternet ExplorerFirefoxSafariOperaMy Personal Notes
arrow_drop_upSave
Content-Encoding: gzip, compress

To check the Content-Encoding in action go to Inspect Element -> Network check the request header for Content-Encoding like below, Content-Encoding is highlighted you can see.Supported Browsers: The browsers compatible with HTTP headers Content-Encoding are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to create footer to stay at the bottom of a Web page?
Differences between Functional Components and Class Components in React
Node.js fs.readFileSync() Method
How to apply style to parent if it has child with CSS?
How to Open URL in New Tab using JavaScript ?
How to execute PHP code using command line ?
SQUARE() Function in SQL Server - GeeksforGeeks

28 Dec, 2020
SQUARE() function :This function in SQL Server is used to return the square of a specified number. For example, if the specified number is 9, this function will return 81 as output.
Features :
This function is used to square a given number.
This function accepts both that is positive and negative numbers.
This function also accepts fraction numbers.
This function always returns positive number.
This function use the formula “(a)2 = Returned value”, where a is the specified number.
Syntax :
SQUARE(number)
Parameter :This method accepts a parameter as given below as follows.
number –Specified number whose square is going to be returned.
Returns :It returns the square of a specified number.
Example-1 :Getting the result 16.0 which is the square of the specified number 4.
SELECT SQUARE(4);
Output :
16.0
Example-2 :Getting the result 4.0 which is the square of the specified negative number -2.
SELECT SQUARE(-2);
Output :
4.0
Example-3 :Getting the result 0.0 which is the square of the specified number zero (0).
SELECT SQUARE(0);
Output :
0.0
Example-4 :Getting the result 1.0 which is the square of the specified number 1.
SELECT SQUARE(1);
Output :
1.0
Example-5 :Getting the result 1.4399999999999999 which is the square of the specified number 1.2.
SELECT SQUARE(1.2);
Output :
1.4399999999999999
Application :This function is used to return the square of a specified number.
DBMS-SQL
SQL-Server
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?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Insert multiple rows in a single MySQL query

Let us first create a table −
mysql> create table DemoTable1384
   -> (
   -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentName varchar(20),
   -> StudentAge int
   -> );
Query OK, 0 rows affected (0.63 sec)
Insert some records in the table using insert command. Here, we are inserting multiple rows in a single query −
mysql> insert into DemoTable1384(StudentName,StudentAge) values('Chris Brown',21),('David Miller',22),
-> ('Carol Taylor',19),('Adam Smith',23);
Query OK, 4 rows affected (0.11 sec)
Records: 4  Duplicates: 0  Warnings: 0
Display all records from the table using select statement −
mysql> select * from DemoTable1384;
This will produce the following output −
+-----------+--------------+------------+
| StudentId | StudentName  | StudentAge |
+-----------+--------------+------------+
|         1 | Chris Brown  |         21 |
|         2 | David Miller |         22 |
|         3 | Carol Taylor |         19 |
|         4 | Adam Smith   |         23 |
+-----------+--------------+------------+
4 rows in set (0.00 sec)
Batch Script - Appending to Files

Content writing to files is also done with the help of the double redirection filter >>. This filter can be used to append any output to a file. Following is a simple example of how to create a file using the redirection command to append data to files.
@echo off
echo "This is the directory listing of C:\ Drive">C:\new.txt
dir C:\>>C:\new.txt
In the above example, you can see that the first echo command is used to create the file using the single redirection command whereas the DIR command is outputted to the file using the double redirection filter.
If you open the file new.txt on your C drive, you will get the contents of your C drive in this file plus the string “This is the directory listing of C:\ Drive” . Following is a sample output.
"This is the directory listing of C:\ Drive"
Volume in drive C is Windows8_OS
Volume Serial Number is E41C-6F43

Directory of C:\

12/22/2015 09:02 PM   <DIR>       01 - Music
06/14/2015 10:31 AM   <DIR>       02 - Videos
09/12/2015 06:23 AM   <DIR>       03 - Pictures
12/17/2015 12:19 AM   <DIR>       04 - Software
12/15/2015 11:06 PM   <DIR>       05 - Studies
12/20/2014 09:09 AM   <DIR>       06 - Future
12/20/2014 09:07 AM   <DIR>       07 - Fitness
09/19/2015 09:56 AM   <DIR>       08 - Tracking
10/19/2015 10:28 PM   <DIR>       09 – Misc

 Print
 Add Notes
 Bookmark this page
PHP switch Statement

If a program needs a series of if statements that perform different process for vaarying value of an expression, it may get very clumsy with each if statement having its own set of curly brackets. This is where using swtich-case construct can make the program compact and readable. With switch construct, it is possible to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to.
switch (expr) {
   case val1:
      code to be executed if expr=val1;
   break;
   case val2:
      code to be executed if expr=val2;
   break;
   ...
   ...
   default:
   code to be executed if expr is not equal to any of above values;
}
It is important to give break statement after each case block in order to void program flow falling through the rest of the cases.
In following example, user is asked to input two numbers and a number for type of arithmetic operation 1/2/3/4 for add/subtract/multiply/divide
 Live Demo
<?php
$first=(int)readline("enter a number");
$second=(int)readline("enter another number");
$x=readline("enter 1/2/3/4 for add/subtract/multiply/divide");
$result=0;
switch($x){
   case 1: echo $first+$second; break;
   case 2: echo $first-$second; break;
   case 3: echo $first*$second; break;
   case 4: echo $first/$second; break;
   default: echo "Incorrect input";
}
?>
This will produce following result −
Incorrect input
The default keyword is used to specify block of statements to be executed if switch expression doesn't match specific cases
If a particular case block is empty, it simply passes the flow to next case.
 Live Demo
<?php
$x=(int)readline("enter a number");
switch($x){
   case 1:
   case 2: echo "x is less than 3"; break;
   case 3: echo "x is equal to 3"; break;
   case 4: echo "x is greater than 3";break;
   default: echo "x is beyound 1 to 4";
}
?>
This will produce following result −
x is beyound 1 to 4
It is possible to use string values to be compared with switch expression
 Live Demo
<?php
$x=readline("enter a something..");
switch($x){
   case "India": echo "you entered India"; break;
   case "USA": echo "You typed USA"; break;
   case "Mumbai": echo "you entered Mumbai";break;
   default: echo "you entered something else";
}
?>
This will produce following result −
you entered something else
Python Pandas - Sparse Data

Sparse objects are “compressed” when any data matching a specific value (NaN / missing value, though any value can be chosen) is omitted. A special SparseIndex object tracks where data has been “sparsified”. This will make much more sense in an example. All of the standard Pandas data structures apply the to_sparse method −
import pandas as pd
import numpy as np

ts = pd.Series(np.random.randn(10))
ts[2:-2] = np.nan
sts = ts.to_sparse()
print sts
Its output is as follows −
0   -0.810497
1   -1.419954
2         NaN
3         NaN
4         NaN
5         NaN
6         NaN
7         NaN
8    0.439240
9   -1.095910
dtype: float64
BlockIndex
Block locations: array([0, 8], dtype=int32)
Block lengths: array([2, 2], dtype=int32)

The sparse objects exist for memory efficiency reasons.
Let us now assume you had a large NA DataFrame and execute the following code −
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(10000, 4))
df.ix[:9998] = np.nan
sdf = df.to_sparse()

print sdf.density
Its output is as follows −
0.0001

Any sparse object can be converted back to the standard dense form by calling to_dense −
import pandas as pd
import numpy as np
ts = pd.Series(np.random.randn(10))
ts[2:-2] = np.nan
sts = ts.to_sparse()
print sts.to_dense()
Its output is as follows −
0   -0.810497
1   -1.419954
2         NaN
3         NaN
4         NaN
5         NaN
6         NaN
7         NaN
8    0.439240
9   -1.095910
dtype: float64

Sparse data should have the same dtype as its dense representation. Currently, float64, int64 and booldtypes are supported. Depending on the original dtype, fill_value default changes −
float64 − np.nan
float64 − np.nan
int64 − 0
int64 − 0
bool − False
bool − False
Let us execute the following code to understand the same −
import pandas as pd
import numpy as np

s = pd.Series([1, np.nan, np.nan])
print s

s.to_sparse()
print s
Its output is as follows −
0   1.0
1   NaN
2   NaN
dtype: float64

0   1.0
1   NaN
2   NaN
dtype: float64


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to Adjust Number of Ticks in Seaborn Plots? - GeeksforGeeks

19 Dec, 2021
In this article, we will discuss how to adjust the number of ticks in Seaborn Plots. Ticks are the values that are used to show some specific points on the X-Y coordinate, It can be a string or a number. We will see how we can choose an optimal or expand the number of ticks to display on both the x-axis and y-axis.
The Axes.set_xticks() and Axes.set_yticks() functions in axes module of matplotlib library are used to Set the ticks with a list of ticks on X-axis and Y-axis respectively.
Syntax:
For  xticks:
 Axes.set_xticks(self, ticks, minor=False)
For  yticks:
Axes.set_yticks(self, ticks, minor=False)
Parameters:
ticks: This parameter is the list of x-axis/y-axis tick locations.
minor: This parameter is used whether set major ticks or to set minor ticks
Return value: 
This method does not returns any value.
In this example, we are setting a number of xticks to the length of data present in dataframe.
Python3
import pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as plt  sns.set(style="darkgrid")  # create DataFramedf = pd.DataFrame({'a': np.random.rand(8), 'b': np.random.rand(8)})  # create lineplotg = sns.lineplot(data=df)  # set the ticks firstg.set_xticks(range(8))  # set the labelsg.set_xticklabels(['2011', '2012', '2013', '2014',                   '2015', '2016', '2017', '2018'])
Output:
In this example, we are setting a number of yticks to the length of data present in dataframe.
Python3
import pandas as pdimport numpy as npimport seaborn as snsimport matplotlib.pyplot as plt  sns.set(style="darkgrid")  # create DataFramedf = pd.DataFrame({'a': np.random.rand(8), 'b': np.random.rand(8)})  # create lineplotg = sns.lineplot(data=df)  #  set the ticks firstg.set_yticks(range(len(df)-5))  # set the labelsg.set_xticklabels(['2011', '2012', '2013', '2014',                   '2015', '2016', '2017', '2018'])
Output:
In this example, we are setting the number of specific positions of ticks on x-axis and y-axis
Python3
import pandas as pdimport matplotlib.pyplot as pltimport seaborn as sns  # create DataFramedf = pd.DataFrame({'var1': [25, 12, 15, 14, 19, 23, 25, 29],                   'var2': [5, 7, 7, 9, 12, 9, 9, 4]})  # create scatterplotsns.scatterplot(data=df, x='var1', y='var2')  # specify positions of ticks on x-axis and y-axisplt.xticks([15, 20, 25], ['A', 'B', 'C'])plt.yticks([4, 8, 12], ['Low', 'Medium', 'High'])
Output:
Picked
Python-Seaborn
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
PHP – Get the string length using mb_strlen()

In PHP, multibyte string length (mb_strlen) function is used to get the total string length of a specified string. This function is supported in PHP 4.6.0 or higher versions.
int mb_strlen(str $string, str $encoding)
mb_strlen() accepts two parameters: $string and $encoding.
$string− It is used to check the string length
$string− It is used to check the string length
$encoding− This parameter is used for character encoding. If it is omitted or null, then the internal character encoding value will be used.
$encoding− This parameter is used for character encoding. If it is omitted or null, then the internal character encoding value will be used.
mb_strlen() returns the number of characters present in the given string. One is counted as a multi-byte character.
If the encoding is not known, then it will generate the level E_warning.
 Live Demo
<?php
   // It will return total number of character
   $result = mb_strlen("Hello World","UTF-8");
   echo "Total number of characters: ", $result;
?>
Total number of characters: 11
Note: that it counts the space too in the given string.
Getting the list of keys of a SortedList object in C#

To get the list of keys of a SortedList object, the code is as follows −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main(String[] args) {
      SortedList list1 = new SortedList();
      list1.Add("One", 1);
      list1.Add("Two ", 2);
      list1.Add("Three ", 3);
      list1.Add("Four", 4);
      list1.Add("Five", 5);
      list1.Add("Six", 6);
      list1.Add("Seven ", 7);
      list1.Add("Eight ", 8);
      list1.Add("Nine", 9);
      list1.Add("Ten", 10);
      Console.WriteLine("SortedList1 elements...");
      foreach(DictionaryEntry d in list1) {
         Console.WriteLine(d.Key + " " + d.Value);
      }
      Console.WriteLine("\nList of keys...SortedList1");
      IList list = list1.GetKeyList();
      foreach(string res in list)
      Console.WriteLine(res);
      SortedList list2 = new SortedList();
      list2.Add("A", "Accessories");
      list2.Add("B", "Books");
      list2.Add("C", "Smart Wearable Tech");
      list2.Add("D", "Home Appliances");
      Console.WriteLine("\nSortedList2 elements...");
      foreach(DictionaryEntry d in list2) {
         Console.WriteLine(d.Key + " " + d.Value);
      }
      Console.WriteLine("\nList of keys...SortedList2");
      list = list2.GetKeyList();
      foreach(string res in list)
         Console.WriteLine(res);
   }
}
This will produce the following output −
SortedList1 elements...
Eight  8
Five 5
Four 4
Nine 9
One 1
Seven  7
Six 6
Ten 10
Three  3
Two  2
List of keys...SortedList1
Eight
Five
Four
Nine
One
Seven
Six
Ten
Three
Two
SortedList2 elements...
A Accessories
B Books
C Smart Wearable Tech
D Home Appliances
List of keys...SortedList2
A
B
C
D
Let us see another example −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main(String[] args) {
      SortedList list = new SortedList();  
      list.Add("One", 1);
      list.Add("Two ", 2);
      list.Add("Three ", 3);
      list.Add("Four", 4);
      list.Add("Five", 5);
      Console.WriteLine("SortedList elements...");
      foreach(DictionaryEntry d in list) {
         Console.WriteLine(d.Key + " " + d.Value);
      }
      Console.WriteLine("\nList of keys...SortedList");
      IList col = list.GetKeyList();
      foreach(string res in col)
         Console.WriteLine(res);
   }
}
This will produce the following output −
SortedList elements...
Five 5
Four 4
One 1
Three  3
Two  2
List of keys...SortedList
Five
Four
One
Three
Two
C++ program to find union and intersection of two unsorted arrays

In this article, we will be discussing a program to find the union and intersection of two given unsorted arrays.
Let us denote the two arrays with ‘A’ and ‘B’. Then union of those arrays is denoted by A ∪ B which is basically an array of all the elements in both the given arrays; provided that each element repeats only once.
To find this, we will create a separate array and copy down all the elements from the first array. Then we will traverse through the elements of the second array and check if it is already present in the union array. If it isn’t, then we will add it to the union array.
Similarly, intersection of two arrays will be denoted by A ∩ B. It is an array of the elements that are present in both the given arrays.
For this, we will traverse through the elements of the first array one by one. Simultaneously we will be checking if that element is present in the second array or not. If the element is present in both the arrays, then we will add it to an intersection array.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int len1 = 4, len2 = 3, flag1 = 0, flag2 = 0;
   int array1[len1] = {1,2,3,4}, array2[len2] = {5,3,4};
   int uni[len1+len2] = {1,2,3,4}, inter[len1];
   for(int k = 0; k < len2 ; k++) {
      flag1 = len1;
      for(int m = 0; m < len1; m++) {
         //eliminating common elements among the given arrays
         if(array2[k] == uni[m])
            break;
         else if(m == len1-1) {
            uni[flag1] = array2[k];
            flag1 = flag1+1;
         }
      }
   }
   for(int q = 0; q < len1; q++) {
      for(int w = 0; w < len2; w++) {
         //checking if both arrays contain a particular element
         if(array1[q] == array2[w]) {
            inter[flag2] = array1[q];
            flag2 = flag2+1;
            break;
         }
      }
   }
   cout << "Union :" <<endl;
   for(int u = 0; u < flag1; u++) {
      cout << uni[u] << " ";
   }
   cout << "\nIntersection :" <<endl;
   for(int i = 0; i < flag2; i++) {
      cout << inter[i] << " ";
   }
   return 0;
}
Union :
1 2 3 4
Intersection :
3 4
How to Crack PDF Files in Python?

Python has a rich collection of libraries that are used for multiple purposes like
creating and developing applications, web development, scientific computation, software testing, machine learning, and many more. Python is also used for testing and developing system applications in terms of information security. There are several other libraries and tools available that contain specific scripts used for creating hashes, information gathering, information retrieval, encryption and decryption, web crawling, spoofing, and many more.
In this article, we will create a program that will decrypt a password protected PDF
document. For decryption, we will use a word list that contains some common
passwords and it will help to decrypt the pdf document.
In order to create a pdf cracker, we will import the pikepdf library. Once downloaded, we can include it in our notebook. For reference, we will use this wordlist as an example that contains 5000 common passwords in it.
import pikepdf
from tqdm import tqdm

#Loading password list
password = [line.strip() for line in open("wordlist.txt")]

#iterate over all the passwords
for paswrd in tqdm(password, "Cracking PDF"):
   try:
      #open PDF file
      with pikepdf.open("protected.pdf", password=paswrd) as pdf:
#If password matches then break the loop and print the output
         print("Password found:", paswrd)
         break
   except pikepdf._qpdf.PasswordError as e:
      #If password not found then continue
      continue
Running the above code will first find the password and then print it as the output.