code-rag-bench/online-tutorials huggingface dataset:
Python - Extract String after Nth occurrence of K character - GeeksforGeeks

14 Oct, 2020
Given a String, extract the string after Nth occurrence of a character. 
Input : test_str = ‘geekforgeeks’, K = “e”, N = 2Output : kforgeeksExplanation : After 2nd occur. of “e” string is extracted.
Input : test_str = ‘geekforgeeks’, K = “e”, N = 4Output : ksExplanation : After 4th occur. of “e” string is extracted.
Method #1 : Using split()
This is one of the ways in which this task can be performed. In this we customize split() to split on Nth occurrence and then print the rear extracted string using “-1”.
Python3
# Python3 code to demonstrate working of # Extract String after Nth occurrence of K character # Using split()  # initializing stringtest_str = 'geekforgeeks'  # printing original stringprint("The original string is : " + str(test_str))  # initializing K K = "e"  # initializing N N = 3  # using split() to perform required string split# "-1" to extract required partres = test_str.split(K, N)[-1]  # printing result print("The extracted string : " + str(res)) 
The original string is : geekforgeeks
The extracted string : eks

Method #2 : Using re.split()
This is yet another way to solve this problem. Similar to above function, we perform split() to perform task of splitting but from regex library which also provides flexibility to split on Nth occurrence.
Python3
# Python3 code to demonstrate working of # Extract String after Nth occurrence of K character # Using re.split()import re  # initializing stringtest_str = 'geekforgeeks'  # printing original stringprint("The original string is : " + str(test_str))  # initializing K K = "e"  # initializing N N = 3  # using split() to perform required string split# "-1" to extract required partres = re.split(K, test_str, N)[-1]  # printing result print("The extracted string : " + str(res)) 
The original string is : geekforgeeks
The extracted string : eks

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
basic_istream::get() in C++ with Examples - GeeksforGeeks

28 May, 2020
The basic_istream::get() is used to get the character. This function returns a one character if available, otherwise it will return end of the file.
Header File:
<iostream>

Syntax:
int_type get();

Parameters: The method basic_istream::get() doesn’t accept any parameter.
Return Value: The method basic_istream::get() returns a character if available, otherwise returns end of the file.
Below are the programs to illustrate basic_istream::get()
Program 1:
// C++ code for basic_istream::get()#include <bits/stdc++.h>using namespace std;  // Driver Codeint main(){    // Declare string stream    istringstream gfg("GeeksforGeeks");      // Here we get H    char a = gfg.get();    cout << "First character is: "         << a << endl;      char b;    // Here we got e    gfg.get(b);    cout << "After reading:" << a         << " We got " << b << endl;      return 0;}
First character is: G
After reading:G We got e

Program 2:
// C++ code for basic_istream::get()#include <bits/stdc++.h>using namespace std;  // Driver Codeint main(){    // Declare string stream    istringstream gfg("Computer");      // Here we get C    char a = gfg.get();    cout << "First character is: "         << a << endl;      char b;    // Here we got o    gfg.get(b);    cout << "After reading:" << a         << " We got " << b << endl;      char c;    // Here we got m    gfg.get(c);    cout << "Now we got : "         << c << endl;      return 0;}
First character is: C
After reading:C We got o
Now we got : m

Reference: std::basic_istream::get
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++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Array of Strings in C++ (5 Different Ways to Create)
Inline Functions in C++
Pair in C++ Standard Template Library (STL)
List in C++ Standard Template Library (STL)
Convert string to char array in C++
Radio Button Vs Checkbox in HTML - GeeksforGeeks

27 Mar, 2020
Radio button: It is generally used in HTML forms. HTML forms are required when you need to collect some data from the site visitors. A radio button is used when you want to select only one option out of several available options.
Example:
<html>  <head>    <title>        Radio Button    <title></head>  <body>    <form>        Do you agree this statement?        <br>        <input type="radio"               name="agree"                value="yes">Yes        <br>        <input type="radio"               name="agree"                value="no">No        <br>        <input type="Submit">    </form></body>  </html>
Output:
Checkbox: Checkboxes are also mostly used in HTML forms. A checkbox allows you to choose one or many options to be selected from a list of options.
Example:
<html>  <head>    <title>        HTML Checkbox    <title></head>  <body>    <form>        Choose languages you know:        <br>        <input type="checkbox"                name="C"                value="yes">C        <br>        <input type="checkbox"                name="C++"                value="yes">C++        <br>        <input type="checkbox"                name="Java"                value="yes">Java        <br>        <input type="checkbox"                name="Python"                value="yes">Python        <br>        <input type="Submit">    </form></body>  </html>
Output:
Difference between radio button and checkbox
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
HTML
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
DB2 - Alias

This chapter describes the creation of alias and retrieving data using alias of database objects.
Alias is an alternative name for database objects. It can be used to reference the database object. You can say, it is a nick name for database objects. Alias are defined for the objects to make their name short, thereby reducing the query size and increasing readability of the query.
You can create database object alias as shown below:
Syntax:
db2 create alias <alias_name> for <table_name>    
Example: Creating alias name for table “professional.customer” table
db2 create alias pro_cust for professional.customer    
If you pass “SELECT * FROM PRO_CUST” or “SELECT * FROM PROFESSIONAL.CUSTOMER” the database server will show the same result.
Syntax: [To retrieve values from a table directly with schema name]
db2 select * from <schema_name>.<table_name>    
Example: [To retrieve values from table customer]
db2 select * from professional.customer    
Output:
CUSTID  FULLNAME    PHONE
------- ---------   ------------ 
100     ravi        9898989 
101     krathi      87996659 
102     gopal       768678687 
  
  3 record(s) selected.    
You can retrieve values from database using alias name as shown below:
Syntax: [To retrieve values from table by calling alias name of the table]
db2 select * from <alias_name>    
Example: [To retrieve values from table customer using alias name]
db2 select * from pro_cust
Output:
CUSTID  FULLNAME    PHONE
------- ---------   ------------ 
100     ravi        9898989 
101     krathi      87996659 
102     gopal       768678687 
  
  3 record(s) selected.    

    10 Lectures 
     1.5 hours 

 Nishant Malik

    41 Lectures 
     8.5 hours 

 Parth Panjabi

    53 Lectures 
     11.5 hours 

 Parth Panjabi

    33 Lectures 
     7 hours 

 Parth Panjabi

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    178 Lectures 
     14.5 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to print a variable name in C?

The following is an example to print variable name.
 Live Demo
#include <stdio.h>
#define VariableName(name) #name
int main() {
   int name;
   char ch;
   printf("The variable name : %s", VariableName(name));
   printf("\nThe variable name : %s", VariableName(ch));
   return 0;
}
The variable name : name
The variable name : ch
In the above program, the variable names are printed by defining the method before main()
#define VariableName(name) #name
Two variables of different datatypes are declared. By using the defined function, variable names are printed.
int name;
char ch;
printf("The variable name : %s", VariableName(name));
printf("\nThe variable name : %s", VariableName(ch));
Compute Cumulative Log Normal Probability Density in R Programming - plnorm() Function - GeeksforGeeks

25 Jun, 2020
plnorm() function in R Language is used to compute the log normal value of the cumulative probability density function. It also creates a plot of the cumulative distribution of log normal density.
Syntax: plnorm(vec)
Parameters:vec: x-values for normal density
Example 1:
# R program to compute cumulative# log normal probability density  # Creating x-values for densityx <- seq(1, 10, by = 1)  # Calling plnorm() functiony <- plnorm(x)y
Output:
 [1] 0.5000000 0.7558914 0.8640314 0.9171715 0.9462397 0.9634142 0.9741672
 [8] 0.9812116 0.9859978 0.9893489

Example 2:
# R program to compute cumulative# log normal probability density  # Creating x-values for densityx <- seq(1, 10, by = 0.1)  # Calling plnorm() functiony <- plnorm(x)  # Plot a graphplot(y)
Output:
R-Statistics
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Loops in R (for, while, repeat)
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Printing Output of an R Program
Data Visualization in R
How to Change Axis Scales in R Plots?
Remove rows with NA in one column of R DataFrame
Group by function in R using Dplyr
Metasploit - Payload

Payload, in simple terms, are simple scripts that the hackers utilize to interact with a hacked system. Using payloads, they can transfer data to a victim system.
Metasploit payloads can be of three types −
Singles − Singles are very small and designed to create some kind of communication, then move to the next stage. For example, just creating a user.
Singles − Singles are very small and designed to create some kind of communication, then move to the next stage. For example, just creating a user.
Staged − It is a payload that an attacker can use to upload a bigger file onto a victim system.
Staged − It is a payload that an attacker can use to upload a bigger file onto a victim system.
Stages − Stages are payload components that are downloaded by Stagers modules. The various payload stages provide advanced features with no size limits such as Meterpreter and VNC Injection.
Stages − Stages are payload components that are downloaded by Stagers modules. The various payload stages provide advanced features with no size limits such as Meterpreter and VNC Injection.
Let’s take an example to understand the use of Metasploit payloads. Assume we have a Windows Server 2003 machine which is vulnerable to DCOM MS03-026.
At first, we will search for an exploit that can work with this vulnerability. We will use the exploit with the best RANK.
Next, we will use the following command to see what payload we can use with this exploit.
msf > show payloads

and see I can use payloads that will help me to upload /execute files, to make the victim as a VNC server to have a view.
The above command will show the payloads that will help us upload/execute files onto a victim system.
To set the payload that we want, we will use the following command −
set PAYLOAD payload/path

Set the listen host and listen port (LHOST, LPORT) which are the attacker IP and port. Then set remote host and port (RPORT, LHOST) which are the victim IP and port.
Type “exploit”. It will create a session as shown below −
Now we can play with the machine according to the settings that this payload offers.
 Print
 Add Notes
 Bookmark this page
Matplotlib.axes.Axes.get_xticks() in Python - GeeksforGeeks

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.get_xticks() function in axes module of matplotlib library is used to return the x ticks as a list of locations.
Syntax: Axes.get_xticks(self, minor=False)
Parameters: This method accepts the following parameters.
minor : This parameter is used whether set major ticks or to set minor ticks
Return value: This method returns a list of Text values.
Below examples illustrate the matplotlib.axes.Axes.get_xticks() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as pltfrom matplotlib.patches import Polygon        def func(x):    return (x - 4) * (x - 6) * (x - 5) + 100        a, b = 2, 9  # integral limitsx = np.linspace(0, 10)y = func(x)    fig, ax = plt.subplots()ax.plot(x, y, "k", linewidth = 2)ax.set_ylim(bottom = 0)    # Make the shaded regionix = np.linspace(a, b)iy = func(ix)verts = [(a, 0), *zip(ix, iy), (b, 0)]poly = Polygon(verts, facecolor ='green',                edgecolor ='0.5', alpha = 0.4)ax.add_patch(poly)    ax.text(0.5 * (a + b), 30,         r"$\int_a ^ b f(x)\mathrm{d}x$",        horizontalalignment ='center',         fontsize = 20)    fig.text(0.9, 0.05, '$x$')fig.text(0.1, 0.9, '$y$')    ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False) ax.set_xticks((a, b-2 * a, b))  w = ax.get_xticks()print(w)ax.text(3, 180, "xtick values : "+str(w),         fontweight ="bold")    fig.suptitle('matplotlib.axes.Axes.get_xticks() function\ Example\n\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt    # Fixing random state for reproducibilitynp.random.seed(19680801)    x = np.linspace(0, 2 * np.pi, 100)y = np.sin(x)y2 = y + 0.2 * np.random.normal(size = x.shape)    fig, ax = plt.subplots()ax.plot(x, y)ax.plot(x, y2)   ax.set_xticks([0, np.pi, 2 * np.pi])    ax.spines['left'].set_bounds(-1, 1)ax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)  w = ax.get_xticks()ww = list(w)strr ="[ "for i in ww:    strr+='%.3f'% i+", "strr+="]"ax.text(1, 0, "xtick values : "+strr, fontweight ="bold")    fig.suptitle('matplotlib.axes.Axes.get_xticks() function\ Example\n\n', fontweight ="bold")fig.canvas.draw()plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
How to Reverse a String using Unix Shell Programming?

Bash is a shell or command line interpreter. It is a layer programming language that understands and executes the command that a user enters or can read commands from a script. Essentially Bash or Shell allows users of Unix-like systems and Windows via a Windows subsystem for Linux to control the innermost components of the Operating system using text-based commands.
In this article, we will discuss a problem to be solved by Shell scripting. We are given a String, and we need to print the reverse of that string using Shell Programming. For example,
Input : str = “ Hello ”
Output : “ olleH ”
Explanation : Reverse order of string “ Hello ” is “ olleH ”.

Input : str = “ yam ”
Output : “ may ”
Declare two strings, one to store the given string and the other to store reversed string.
Find the length of the given string.
Traverse the string from [length - 1]th index to 1 using a for a loop.
Append every character to the reversed_string variable.
Finally, print the reversed_string using echo.
#!/bin/bash
# declaring variable to store string
# and catching the string passed from shell
str="$1"
reversed_string=""
# finding the length of string
len=${#str}
# traverse the string in reverse order.
for (( i=$len-1; i>=0; i-- ))
do
   reversed_string="$reversed_string${str:$i:1}"
done
# printing the reversed string.
echo "$reversed_string"
Hello
olleH
MongoDB $toLower Operator - GeeksforGeeks

01 Aug, 2020
MongoDB provides different types of string expression operators that are used in the aggregation pipeline stages $toLower operator is one of them. This operator is used to convert the given string into lowercase.
Syntax: 
{ $toLower: <expression> }



Here, the argument passed in this operator can be any valid expression until they resolve to a string. If the entered argument resolves to null, then this operator will return an empty string “”.
Examples:
In the following examples, we are working with:
Database: GeeksforGeeks
Collection: employee
Document: three documents that contain the details of the employees in the form of field-value pairs.
Using $toLower Operator:
In this example, we are going to convert the value of the department field in lowercase.
db.employee.aggregate([
... {$match: {"name.first": "Aman"}},
... {$project: {dept: {$toLower: "$department"}}}])
Using $toLower Operator in embedded documents:
In this example, we are going to convert the value of the name.first field in lowercase.
db.employee.aggregate([
... {$match: {department: "Development"}},
... {$project: {name: {$toLower: "$name.first"}}}])
MongoDB-operators
MongoDB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Spring Boot JpaRepository with Example
Aggregation in MongoDB
How to build a basic CRUD app with Node.js and ReactJS ?
Mongoose Populate() Method
MongoDB - Check the existence of the fields in the specified collection
MongoDB - db.collection.Find() Method
MongoDB - Distinct() Method
Upsert in MongoDB
How to connect MongoDB with ReactJS ?
MongoDB - limit() Method
How to count number of occurrences of repeated names in an array - JavaScript?

Let’s say the following is our array −
var details = [
   {
      studentName: "John",
      studentAge: 23
   },
   {
      studentName: "David",
      studentAge: 24
   },
   {
      studentName: "John",
      studentAge: 21
   },
   {
      studentName: "John",
      studentAge: 25
   },
   {
      studentName: "Bob",
      studentAge: 22
   },
   {
      studentName: "David",
      studentAge: 20
   }
]
We need to count of occurrence of repeated names i.e. the output should be
John: 3
David: 2
Bob: 1
For this, you can use the concept of reduce().
Following is the code −
var details = [
   {
      studentName: "John",
      studentAge: 23
   },
   {
      studentName: "David",
      studentAge: 24
   },
   {
      studentName: "John",
      studentAge: 21
   },
   {
      studentName: "John",
      studentAge: 25
   },
   {
      studentName: "Bob",
      studentAge: 22
   },
   {
      studentName: "David",
      studentAge: 20
   }
]
var output = Object.values(details.reduce((obj, { studentName }) => {
   if (obj[studentName] === undefined)
      obj[studentName] = { studentName: studentName, occurrences: 1 };
   else
      obj[studentName].occurrences++;
   return obj;
}, {}));
console.log(output);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo282.js. This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo282.js
[
   { studentName: 'John', occurrences: 3 },
   { studentName: 'David', occurrences: 2 },
   { studentName: 'Bob', occurrences: 1 }
]
SQL – count() with Group By clause

25 Oct, 2021
The count() function is an aggregate function use to find the count of the rows that satisfy the fixed conditions. The count() function with the GROUP BY clause is used to count the data which were grouped on a particular attribute of the table. 
Syntax:
SELECT attribute1 , COUNT(attribute2)
FROM table_name
GROUP BY attribute1
In this article let us see the SQL count() with Group by clause using MSSQL as a server.
Step 1: We are creating a Database. For this use the below command to create a database named GeeksforGeeks.
Query:
CREATE DATABASE GeeksforGeeks;
Step 2: To use the GeeksforGeeks database use the below command.
Query:
USE GeeksforGeeks
Step 3: Now we are creating a table. Create a table student_marks with 4 columns using the following SQL query.
Query:
CREATE TABLE student_marks(
stu_id VARCHAR(20),
stu_name VARCHAR(20),
stu_branch VARCHAR(20),
total_marks INT
)
Step 4: Viewing the description of the table.
Query:
EXEC sp_columns student_marks
Step 5: The query for Inserting rows into the Table. Inserting rows into student_marks  table using the following SQL query.
Query:
INSERT INTO student_marks
VALUES( '1001','PRADEEP','E.C.E', 550),
( '1002','KIRAN','E.C.E', 540),
( '1003','PRANAV','E.C.E', 450),
( '2001','PADMA','C.S.E', 570),
( '2002','SRUTHI','C.S.E', 480),
( '2003','HARSITHA','C.S.E', 534),
( '3001','SAI','I.T', 560),
( '3002','HARSH','I.T', 510),
( '3003','HARSHINI','I.T', 500)
Step 6: Viewing the inserted data
Query:
SELECT * FROM student_marks
Query to find the number of students in each branch
SELECT stu_branch, COUNT(stu_id) AS number_of_students
FROM student_marks
GROUP BY stu_branch
Query to find the number of students whose marks are greater than the average marks of the table.
SELECT AVG(total_marks) AS average,COUNT(stu_id) AS number_of_students
FROM student_marks
WHERE total_marks>(SELECT AVG(total_marks) FROM student_marks)
Picked
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?
Window functions in SQL
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
SQL Query to Compare Two Dates
SQL Query to Convert Rows to Columns in SQL Server
Python – Get Hardware and System information using platform module

26 Mar, 2020
In this article, we will see how we can show information about our system i.e processor name, name of system etc.
The Platform module is used to retrieve as much possible information about the platform on which the program is being currently executed. Now by platform info, it means information about the device, it’s OS, node, OS version, Python version, etc. This module plays a crucial role when you want to check whether your program is compatible with the python version installed on a particular system or whether the hardware specifications meet the requirements of your program.
In order to do this we need to import platform module.
import platform
 Below is the Python implementation –
# importing moduleimport platform  # dictionaryinfo = {}  # platform detailsplatform_details = platform.platform()  # adding it to dictionaryinfo["platform details"] = platform_details  # system namesystem_name = platform.system()  # adding it to dictionaryinfo["system name"] = system_name  # processor nameprocessor_name = platform.processor()  # adding it to dictionaryinfo["processor name"] = processor_name  # architectural detailarchitecture_details = platform.architecture()  # adding it to dictionaryinfo["architectural detail"] = architecture_details  # printing the detailsfor i, j in info.items():    print(i, " - ", j)
Output :
platform details  -  Windows-10-10.0.17134-SP0
system name  -  Windows
processor name  -  Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
architectural detail  -  ('64bit', 'WindowsPE')

Note : Output may vary based on you system architecture.
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS – componentWillUnmount() Method

In this article, we are going to see how to execute a function when the component is deleted from the DOM tree.
This method is called during the unmounting phase of the React Lifecycle, i.e., before the component is destroyed or unmounted from the DOM tree. This method is majorly used to cancel all the subscriptions that were previously created in the componentWillMount method.
Never call this.setState() inside the componentWillUnmount method as this component is never going to be re-rendered again.
componentWillUnmount()
In this example, we will build a React application which displays the list of all users. On clicking the 'Delete User' button, the User component will get unmounted from the DOM tree and before destroying the User component, the componentWillUnmount method will be called.
Our first component in the following example is App. This component is the parent of the Change component. We are creating Change separately and just adding it inside the JSX tree in our App component. Hence, only the App component needs to be exported.
App.jsx
import React from 'react';

class App extends React.Component {
   constructor() {
      super();
      this.state = {
         delete: false,
      };
   }
   render() {
      return (
         <div>
            <h1>User List</h1>
            <button onClick={() => this.setState({ delete: true })}>
               Delete Users
            </button>
            {this.state.delete ? null : <User />}
         </div>
      );
   }
}
class User extends React.Component {
   componentWillUnmount() {
      alert('Deleted User successfully');
   }
   render() {
      return (
         <div>
            <h3>Username: Rahul</h3>
            <h3>Email: rbbansal558@gmail.com</h3>
         </div>
      );
   }
}
export default App;
This will produce the following result.
What are the best practices to organize Python modules?

Here is a sample project that shows a very good way to structure your projects: https://github.com/kennethreitz/samplemod. The project is about creating the "sample" module. The directory structure looks as follows:
README.rst
LICENSE
setup.py
requirements.txt
sample/__init__.py
sample/core.py
sample/helpers.py
docs/conf.py
docs/index.rst
tests/test_basic.py
tests/test_advanced.py
The README.rst file: This file is for giving a brief description of the module, how to set it up, how to use it, etc.
LICENSE: Contains license text and any copyright claims.
setup.py: It is Python's answer to a multi-platform installer and make file. If you’re familiar with command line installations, then make && make install translates to python setup.py build && python setup.py install. So it is used to build your project on user machine.
requirements.txt: A Pip requirements file should specify the dependencies required to contribute to the project: testing, building, and generating documentation. If your project has no development dependencies, or you prefer development environment setup via setup.py, this file is unnecessary.
docs/: This directory contains the documentation for your project.
tests/: All your tests should reside in this directory. Initially you'll have a single test file. As they start to grow, you can structure your tests like your module directory.
sample/: This directory contains your actual module code. If your module consists of only a single file, you can place it directly in the root of your repository as sample.py. Your library does not belong in an ambiguous src or python subdirectory. This will contain a __init__.py file if you want this module to reside within a package.
How to add an attribute to the XML file using Powershell?

To add the attribute to the XML, we first need to add the Element and then we will add an attribute for it.
Below is a sample of the XML file.
<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications with XML.</description>
   </book>
</catalog>
The below command will add the new element but the file won’t be saved. We will save the file after the attribute is added.
$file = "C:\Temp\SampleXML.xml"
$xmlfile = [xml](Get-Content $file)
$newbookelement = $xmlfile.CreateElement("book")
$newbookelementadd = $xmlfile.catalog.AppendChild($newbookelement)
To insert the attribute and save the file,
$newbookattribute = $newbookelementadd.SetAttribute("id","bk001")
$xmlfile.Save($file)
To add the nested elements or if we need to add the attributes under the newly created node use the below code,
$file = "C:\Temp\SampleXML.xml"
$xmlfile = [XML](Get-Content $file)
$newbooknode = $xmlfile.catalog.AppendChild($xmlfile.CreateElement("book"))
$newbooknode.SetAttribute("id","bk102")
$newauthorelement = $newbooknode.AppendChild($xmlfile.CreateElement("author"))
$newauthorelement.AppendChild($xmlfile.CreateTextNode("Jimmy Welson")) | Out-Null
$newtitleelement = $newbooknode.AppendChild($xmlfile.CreateElement("title"))
$newtitleelement.AppendChild($xmlfile.CreateTextNode("PowerShell One")) | OutNull
$xmlfile.save($file)
HTML | charset Attribute - GeeksforGeeks

14 Dec, 2021
The charset attribute in HTML is used to define the character encoding. The charset attribute is used with the <meta> and <script> element.Charset attribute in <meta> Tag: The charset attribute is present in the meta element. It specifies the character encoding for the HTML document. 
Supported Tags: 
<meta> 
<script>
Syntax:  
<meta charset="character_set"> 
Attribute Values: It contains the value i.e character_set which specifies the character encoding for the HTML document.
Values:
UTF-8: It specify the character encoding for Unicode.
ISO-8859-1: It specify the character encoding for the Latin alphabet.
Example: This example illustrates the use of charset attribute in meta element.  
html
<!DOCTYPE html><html>    <head>        <title>            HTML charset Attribute        </title>                 <meta name="keywords" charset="UTF-8"                content="Meta Tags, Metadata" />    </head>             <body style="text-align:center">        <h1>Hello GeeksforGeeks!</h1>                 <h2>            HTML charset Attribute in Meta Element        </h2>    </body></html>                   
Output: 
Charset attribute in <script> Tag: When charset attribute present in the script element, it specifies the character encoding used in an external script. 
Syntax:  
<script charset="charset">
Example: This Example illustrates the use of charset attribute in script element.  
html
<!DOCTYPE html><html>    <head>        <title>            Charset Attribute script tag        </title>                 <style>            body {                text-align:center;            }            h1 {                color:green;            }        </style>    </head>         <body>        <h1>GeeksforGeeks</h1>                 <h2>            HTML charset Attribute in            <script> Element        </h2>                 <p id="Geeks"></p>                              <script charset="UTF-8">            document.getElementById("Geeks").innerHTML                    = "Hello GeeksforGeeks!";        </script>    </body></html>                   
Output:  
Supported Browsers: The browser supported by HTML charset Attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
How to Install pywin32 on Windows? - GeeksforGeeks

22 Sep, 2021
Pywin32 is a Python extension for windows that is used to access Windows API.  In this article, we will look into the process of installing Pywin32 on a windows machine.
The only thing that you need for installing Numpy on Windows are:
Python 
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install -c anaconda pywin32
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
To verify if Pywin32 has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
conda list pywin32
You’ll get the below message if the installation is complete:
If you want the installation to be done through PIP,  open up the Command Prompt and use the below command:
pip install pywin32 
You will get a similar message once the installation is complete:
To verify if the Pywin32 has been successfully installed in your system run the below command in Command Prompt:
python -m pip show pywin32 
You’ll get the below message if the installation is complete:
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Import JSON Data into SQL Server?
How to Install Tkinter in Windows?
SQL - Multiple Column Ordering
How to pass data into table from a form using React Components
How to Create a Table With Multiple Foreign Keys in SQL?
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
How to Install OpenCV for Python on Windows?
How to set default Field Value in MySQL?

To set default field value, use the “default”. Let us first create a table −
mysql> create table DemoTable
-> (
-> Age int
-> );
Query OK, 0 rows affected (0.58 sec)
Here is the query to set default field value in MySQL −
mysql> alter table DemoTable MODIFY Age int default 18;
Query OK, 0 rows affected (0.25 sec)
Records: 0 Duplicates: 0 Warnings: 0
Now you can check the table description −
mysql> desc DemoTable;
This will produce the following output −
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| Age   | int(11) | YES  |     | 18      |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
Insert some records in the table using insert command. We have left two of the fields without any value. Therefore, it would be set as the default field value −
mysql> insert into DemoTable values(19);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values();
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values(20);
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable values();
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql>select *from DemoTable;
This will produce the following output. As you can see two of the values are set 18, since we have set the same as default above −
+------+
| Age  |
+------+
| 19   |
| 18   |
| 20   |
| 18   |
+------+
4 rows in set (0.00 sec)
How to place cursor position at end of text in text input field using JavaScript ? - GeeksforGeeks

05 Jan, 2021
In this article, we are going to learn about how to place the cursor at end of the text in a text input element using JavaScript. 
At first, we are going to create a text input box where some value will be given and a button to place the cursor at the end. We can place the cursor at the end of the text in a text input element by using different JavaScript functions.
Approach:
The JavaScript functions that used are:
HTMLInputElement.setSelectionRange(): The HTMLInputElement.setSelectionRange() is a method that sets the start and end positions of the current text selection in an <input> or <textarea> element.
Element.createTextRange(): It provides us with a selected text range in an input form. A caret is also known as a text cursor which is an indicator on the screen to indicate where the text is to be inserted.
 TextRange.collapse(): It helps to move the caret to the beginning or end of the current range.
TextRange.moveEnd(): It helps to move the end of the range by a specified number of units.
TextRange.moveStart(): It moves the start of the range by a specified number of units.
Example:
HTML
<!DOCTYPE html><html>  <body>    <center>        <h1>Put Cursor at End of Input</h1>          <!-- Creating an Input Text Box and             the button to move cursor at the             end of the text-->        <input id="idText" type="text" size="70"             value="Cursor at the End">          <button onclick="PosEnd(idText);">            Put Cursor at end of Text        </button>    </center>      <script>          /* Creating a function called PosEnd         in JavaScript to place the cursor          at the end */        function PosEnd(end) {            var len = end.value.length;                          // Mostly for Web Browsers            if (end.setSelectionRange) {                end.focus();                end.setSelectionRange(len, len);            } else if (end.createTextRange) {                var t = end.createTextRange();                t.collapse(true);                t.moveEnd('character', len);                t.moveStart('character', len);                t.select();            }        }    </script></body>  </html>
Output:
Before clicking the button:
After clicking the button:
HTML-Misc
JavaScript-Misc
Picked
Technical Scripter 2020
HTML
JavaScript
Technical Scripter
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
HTML - Figcaption Tag

The HTML <figcaption> tag specifies a caption for an element.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML Figcaption Tag</title>
   </head>

   <body>
      <figure><img src = "http://www.tutorialspoint.com/scripts/img/logo.png"/>
         <figcaption>Tutorials Point Logo</figcaption>
      </figure>
   </body>

</html>
This will produce the following result −
This tag supports all the global attributes described in HTML Attribute Reference
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Python - Extract ith element of K key's value - GeeksforGeeks

11 Sep, 2021
Given a dictionary, extract ith element of K key’s value list.
Input : test_dict = {‘Gfg’ : [6, 7, 3, 1], ‘is’ : [9, 1, 4], ‘best’ : [10, 7, 4]}, K = ‘Gfg’, i = 1 Output : 7 Explanation : 1st index of ‘Gfg”s value is 7.
Input : test_dict = {‘Gfg’ : [6, 7, 3, 1], ‘is’ : [9, 1, 4], ‘best’ : [10, 7, 4]}, K = ‘best’, i = 0 Output : 10 Explanation : 0th index of ‘best”s value is 10.  
Method : Using + get()
This is one of the ways in which this task can be performed. In this, we extract the key’s value using get() and then value is extracted after checking for K being less than list length.
Python3
# Python3 code to demonstrate working of# Extract ith element of K key's value# Using get() # initializing dictionarytest_dict = {'Gfg' : [6, 7, 3, 1],             'is' : [9, 1, 4],             'best' : [10, 7, 4]} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # initializing KK = 'Gfg' # initializing ii = 2 # using get() to get the required valuetemp = test_dict.get(K)res = None# checking for non empty dict and length constraintsif temp and len(temp) >= i:          res = temp[i]         # printing resultprint("The extracted value : " + str(res))
The original dictionary is : {'Gfg': [6, 7, 3, 1], 'is': [9, 1, 4], 'best': [10, 7, 4]}
The extracted value : 3
anikakapoor
Python dictionary-programs
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Minimum Coin Change Problem

There is a list of coin C(c1, c2, ......Cn) is given and a value V is also given. Now the problem is to use the minimum number of coins to make the chance V.
Note − Assume there are an infinite number of coins C
In this problem, we will consider a set of different coins C{1, 2, 5, 10} are given, There is an infinite number of coins of each type. To make change the requested value we will try to take the minimum number of coins of any type.
As an example, for value 22 − we will choose {10, 10, 2}, 3 coins as the minimum.
The time complexity of this algorithm id O(V), where V is the value.
Input:
A value, say 47
Output:
Enter value: 47
Coins are: 10, 10, 10, 10, 5, 2
findMinCoin(value)
Input − The value to make the change
Output − Set of coins.
Begin
   coins set with value {1, 2, 5, 10}
   for all coins i as higher value to lower value do
      while value >= coins[i] do
         value := value – coins[i]
         add coins[i], in thecoin list
      done
   done
   print all entries in the coin list.
End
#include<iostream>
#include<list>
#define COINS 4
using namespace std;

float coins[COINS] = {1, 2, 5, 10};

void findMinCoin(int cost) {
   list<int> coinList;

   for(int i = COINS-1; i>=0; i--) {
      while(cost >= coins[i]) {
         cost -= coins[i];
         coinList.push_back(coins[i]); //add coin in the list

      }
   }

   list<int>::iterator it;

   for(it = coinList.begin(); it != coinList.end(); it++) {
      cout << *it << ", ";
   }
}

main() {
   int val;
   cout << "Enter value: ";
   cin >> val;
   cout << "Coins are: ";
   findMinCoin(val);
   cout << endl;
}
Enter value: 47
Coins are: 10, 10, 10, 10, 5, 2
Largest Gap in Python

Suppose we have a list of numbers called nums, we have to find the largest difference of two
consecutive numbers in the sorted version of nums.
So, if the input is like [5, 2, 3, 9, 10, 11], then the output will be 4, as the largest gap between 5
and 9 is 4.
To solve this, we will follow these steps −
n := sorted list nums
ans := a new list
for i in range 0 to size of n -2, doinsert n[i+1]-n[i] at the end of ans
insert n[i+1]-n[i] at the end of ans
return maximum of ans
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, nums):
      n = sorted(nums)
      ans = []
      for i in range(len(n)-1):
         ans.append(n[i+1]-n[i])
      return max(ans)
ob = Solution()
nums = [5, 2, 3, 9, 10, 11]
print(ob.solve(nums))
[5, 2, 3, 9, 10, 11]
4
Difference Between exit(0) and exit(1)

In this post, we will understand the difference between exit(0) and exit(1).
It is portable.
It is portable.
It tells about the successful termination or completion of the program.
It tells about the successful termination or completion of the program.
It tells about the termination when the program is executed without any errors.
It tells about the termination when the program is executed without any errors.
The ‘EXIT_SUCCESS’ macro is used to return code 0.
The ‘EXIT_SUCCESS’ macro is used to return code 0.
The ‘EXIT_SUCCESS’ can be defined as standard as zero.
The ‘EXIT_SUCCESS’ can be defined as standard as zero.
exit(0);
It is not portable.
It is not portable.
It tells about the abnormal termination of the program.
It tells about the abnormal termination of the program.
It tells about the termination if the program exited with certain error when the program was being executed.
It tells about the termination if the program exited with certain error when the program was being executed.
The ‘EXIT_FAILURE’ macro is used to return code 1.
The ‘EXIT_FAILURE’ macro is used to return code 1.
It is not restrict by standard to be 1 only.
It is not restrict by standard to be 1 only.
It can be used based on how the system implements it.
It can be used based on how the system implements it.
exit(1);
Batch Script - Right String

This is used to extract characters from the end of a string.
@echo off 
set str = This message needs changed. 
echo %str% 

set str = %str:~-8% 
echo %str%
The key thing to note about the above program is, the right hand of the string is extracted by using the ~-‘number of characters to extract’ operator.
The above command produces the following output.
This message needs changed. 
changed.

 Print
 Add Notes
 Bookmark this page
What are control statements in C#?

The flow of program control is specified by control statements in C#. It includes the following −
An if statement consists of a boolean expression followed by one or more statements.
The following is the syntax −
if(boolean_expression) {
   /* statement(s) will execute if the boolean expression is true */
}
An if statement can be followed by an optional else statement, which executes when the boolean expression is false.
The following is the syntax −
if(boolean_expression) {
   /* statement(s) will execute if the boolean expression is true */
} else {
   /* statement(s) will execute if the boolean expression is false */
}
It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
The following is the syntax −
for ( init; condition; increment ) {
   statement(s);
}
It repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body.
The following is the syntax −
while(condition) {
   statement(s);
}
It is similar to a while statement, except that it tests the condition at the end of the loop body.
The following is the syntax −
do {
   statement(s);
} while( condition );