code-rag-bench/online-tutorials huggingface dataset:
compgen command in Linux with Examples - GeeksforGeeks

22 Jun, 2020

compgen is a bash built-in command which is used to list all the commands that could be executed in the Linux system. This command could also be used to count the total number of commands present in the terminal or even to look for a command with the specific keyword. This command is even used to print the bash details like bash builtin functions and stuff.
1. To list all commands available to be directly executed.
compgen -c
This will list all the commands available to you for direct use.
2. To search for commands having a specific keyword
compgen -c | grep gnome
This will search the commands having the keyword gnome in them.
3. To count total number of commands available for use
compgen -c | wc -l
This command will count the total number of commands that could be used.
4. To list all the bash alias
compgen -a
This command will list all the bash alias present in your system.
5. To list all the bash built-ins
compgen -b
This command will list all the bash built-ins present in your system.
6. To list all the bash keywords
compgen -k
This command will list all the bash keywords present in your system.
7. To list all the bash functions.
compgen -A function
This command will list all the bash functions present in your system.

linux-command


Linux-Unix

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
scp command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Python - Write Bytes to File - GeeksforGeeks

26 Nov, 2020
Files are used in order to store data permanently. File handling is performing various operations (read, write, delete, update, etc.) on these files. In Python, file handling process takes place in the following steps:
Open filePerform operationClose file
Open file
Perform operation
Close file
There are four basic modes in which a file can be opened― read, write, append, and exclusive creations. In addition, Python allows you to specify two modes in which a file can be handled― binary and text. Binary mode is used for handling all kinds of non-text data like image files and executable files.
Python stores files in the form of bytes on the disk. So, when a file is opened in text mode, these files are decoded from bytes to return string objects. While files opened in binary mode return contents as bytes objects (sequences of single bytes) without any decoding. Let us see how to write bytes to a file in Python.
First, open a file in binary write mode and then specify the contents to write in the form of bytes. Next, use the write function to write the byte contents to a binary file. 
Python3
some_bytes = b'\xC3\xA9'  # Open in "wb" mode to# write a new file, or # "ab" mode to appendwith open("my_file.txt", "wb") as binary_file:        # Write bytes to file    binary_file.write(some_bytes)
Output:
my_file.txt
In the above example, we opened a file in binary write mode and then wrote some bytes contents as bytes in the binary file.
Alternatively, open() and close() can be called explicitly as shown below. However, this method requires you to perform error handling yourself, that is, ensure that the file is always closed, even if there is an error during writing. So, using the “with” statement is better in this regard as it will automatically close the file when the block ends.
Python3
some_bytes = b'\x21'  # Open file in binary write modebinary_file = open("my_file.txt", "wb")  # Write bytes to filebinary_file.write(some_bytes)  # Close filebinary_file.close()
Output:
my_file.txt
Also, some_bytes can be in the form of bytearray which is mutable, or bytes object which is immutable as shown below.
Python3
# Create bytearray # (sequence of values in # the range 0-255 in binary form)  # ASCII for A,B,C,Dbyte_arr = [65,66,67,68] some_bytes = bytearray(byte_arr)  # Bytearray allows modification# ASCII for exclamation marksome_bytes.append(33)  # Bytearray can be cast to bytesimmutable_bytes = bytes(some_bytes)  # Write bytes to filewith open("my_file.txt", "wb") as binary_file:    binary_file.write(immutable_bytes)
Output:
my_file.txt
python-file-handling
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
BufferedWriter newLine() method in Java with Examples - GeeksforGeeks

28 May, 2020
The newLine() method of BufferedWriter class in Java is used to separate the next line as a new line. It is used as a write separator in buffered writer stream.
Syntax:
public void newLine()
            throws IOException

Parameters: This method does not accept any parameter.
Return value: This method does not return any value.
Exceptions: This method throws IOException if an I/O error occurs.
Below programs illustrate newLine() method in BufferedWriter class in IO package:
Program 1:
// Java program to illustrate// BufferedWriter newLine() method  import java.io.*;  public class GFG {    public static void main(String[] args)        throws IOException    {          // Create the string Writer        StringWriter stringWriter            = new StringWriter();          // Convert stringWriter to        // bufferedWriter        BufferedWriter buffWriter            = new BufferedWriter(                stringWriter);          // Write "A" to buffer writer        buffWriter.write(65);          // Revoke newLine() method        buffWriter.newLine();          // Write "B" to buffer writer        buffWriter.write(66);          buffWriter.flush();          System.out.println(            stringWriter.getBuffer());    }}
A
B

Program 2:
// Java program to illustrate// BufferedWriter newLine() method  import java.io.*;  public class GFG {    public static void main(String[] args)        throws IOException    {        // Create the string Writer        StringWriter stringWriter            = new StringWriter();          // Convert stringWriter to        // bufferedWriter        BufferedWriter buffWriter            = new BufferedWriter(                stringWriter);          // Write "GEEKS" to buffered writer        buffWriter.write(            "GEEKSFORGEEKS", 0, 5);          // Revoke newLine() method        buffWriter.newLine();          // Write "GEEKSFORGEEKS"        // to buffered writer        buffWriter.write(            "GEEKSFORGEEKS", 0, 13);          buffWriter.flush();          System.out.println(            stringWriter.getBuffer());    }}
GEEKS
GEEKSFORGEEKS

References:https://docs.oracle.com/javase/10/docs/api/java/io/BufferedWriter.html#newLine()
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Different ways of Reading a text file in Java
Internal Working of HashMap in Java
Introduction to Java
Comparator Interface in Java with Examples
Strings in Java
case command in Linux with examples - GeeksforGeeks

15 May, 2019
case command in Linux is the best alternative when we had to use multiple if/elif on a single variable. It is used to execute the commands based on the pattern matching.
Syntax:
case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac
Example:
Options:
help case : It displays help information.
Linux-basic-commands
linux-command
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
mv command in Linux with examples
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
How to prevent column break within an element? - GeeksforGeeks

18 Apr, 2019
We can prevent column break within an element by using a CSS break-inside Property. The break-inside property in CSS is used to specify how the column breaks inside the element. Sometimes content of an element is stuck between the column. To prevent column break we should use the break-inside Property set to avoid.
Syntax:
column-break-inside:avoid;
Example: This Example uses to prevent the column break within an element.
<html>  <head>    <style>        .x {            -moz-column-count: 3;            column-count: 3;            width: 30em;        }                  .x li {            -webkit-column-break-inside: avoid;        }    </style></head>  <body>    <h1>Geeks For Geeks</h1>    <div class='x'>        <ul>            <li>GeeksForGeeks</li>            <li>Sudo Placement</li>            <li>DataBase management System</li>            <li>Operating System</li>                <li>A computer science portal for geeks.</li>                <li>Java Programming</li>        </ul>    </div></body>  </html>
Output:
shubham_singh
Picked
CSS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
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
C# | LongLength property of an Array - GeeksforGeeks

23 Jan, 2019
Array.LongLength Property is used to get a 64-bit integer that represents the total number of elements in all the dimensions of the Array.
Syntax:
public long LongLength { get; }
Property Value: This property returns a 64-bit integer that represents the total number of elements in all the dimensions of the Array.
Example:
// C# program to illustrate the// Array.LongLength Propertyusing System;namespace geeksforgeeks {  class GFG {      // Main Method    public static void Main()    {          // Two-dimensional array        int[, ] intarray = new int[, ] { { 1, 2 },                                         { 3, 4 },                                         { 5, 6 },                                         { 7, 8 } };          // The same array with dimensions        // specified 4 row and 2 column.        int[, ] intarray_d = new int[4, 2] { { 1, 2 },                                              { 3, 4 },                                              { 5, 6 },                                              { 7, 8 } };          Console.Write("Total Number of Elements in intarray: ");          // using LongLength property        Console.Write(intarray.LongLength);          // getting the type of returned value        Console.WriteLine("\nType of returned Length: "                   + (intarray.LongLength).GetType());          // showing difference between Length        // and LongLength property by getting        // the type of the both property's        // returned value          Console.Write("\nTotal Number of Elements in intarray_d: ");          // using Length property        Console.Write(intarray_d.Length);          // getting the type of returned value        Console.WriteLine("\nType of returned Length: "                       + (intarray_d.Length).GetType());          Console.Write("\nTotal Number of Elements in intarray_d: ");          // using LongLengthLength property        Console.Write(intarray_d.LongLength);          // getting the type of returned value        Console.WriteLine("\nType of returned Length: "                  + (intarray_d.LongLength).GetType());    }}}
Total Number of Elements in intarray: 8
Type of returned Length: System.Int64

Total Number of Elements in intarray_d: 8
Type of returned Length: System.Int32

Total Number of Elements in intarray_d: 8
Type of returned Length: System.Int64

Note: In the above program you can see that Array.Length property always returns the length of the type System.Int32 but Array.LongLength property always returns the length of the type System.Int64.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.array.longlength?view=netframework-4.7.2
CSharp-Arrays
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# | Constructors
C# | Class and Object
Introduction to .NET Framework
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | String.IndexOf( ) Method | Set - 1
C# | Delegates
C# | Data Types
C# | Abstract Classes
C# | Replace() Method
Apply function to each element of a list - Python - GeeksforGeeks

26 Nov, 2020
In this article, we will learn how to apply a function to each element of a Python list. Let’s see what exactly is Applying a function to each element of a list means:
Suppose we have a list of integers and a function that doubles each integer in this list. On applying the function to the list, the function should double all the integers in the list. We achieve this functionality in the following ways:
map() method.Using list comprehensions.lambda function
map() method.
Using list comprehensions.
lambda function
map() methods take two arguments: iterables and functions and returns a map object. We use list() to convert the map object to a list.
Program:
Python3
def double(integer):    return integer*2    # driver codeinteger_list = [1, 2, 3]  # Map method returns a map object# so we cast it into list using list()output_list = list(map(double, integer_list))  print(output_list)
Output:
[2, 4, 6]
Time Complexity: O(n)*(O complexity of function applied on list)
We use a list comprehension to call a function on each element of the list and then double it for this case.
Program:
Python3
def double(integer):    return integer*2    # driver codeinteger_list = [1, 2, 3]  # Calling double method on each integer# in list using list comprehension.output_list = [double(i) for i in integer_list]  print(output_list)
Output:
[2, 4, 6]
Time Complexity: O(n)*(O complexity of function applied on list)
A lambda function can also be employed to produce the above functionality. Lambda is capable of creating an anonymous function that can be made enough to fit the given requirement.
Program:
Python3
lst = [1, 2, 3]  ans = []  for x in lst:    def res(x): return x*2    ans.append(res(x))  print(ans)
Output:
[2, 4, 6]
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Create a directory in Python
Defaultdict in Python
Python | Get unique values from a list
Difference between 2-address instruction and 1-address instructions - GeeksforGeeks

19 Jun, 2020
Prerequisite – Instruction Formats1. Two-Address Instructions :Two-address instruction is a format of machine instruction. It has one opcode and two address fields. One address field is common and can be used for either destination or source and other address field for source.
Example:
X = (A + B) x (C + D) 
Solution:
MOV R1, A      R1 <- M[A]
ADD R1, B      R1 <- R1 + M[B]
MOV R2, C      R2 <- M[C]
ADD R2, D      R2 <- R2 + D
MUL R1, R2     R1 <- R1 x R2
MOV X, R1      M[X] <- R1 
2. One-Address Instructions :One-Address instruction is also a format of machine instruction. It has only two fields. One for opcode and other for operand.
Example:
X = (A + B) x (C + D) 
Solution:
LOAD A      AC <- M[A]
ADD B       AC <- AC + M[B]
STORE T     M[T] <- AC
LOAD C      AC <- M[C]
ADD D       AC <- AC + M[D]
MUL T       AC <- AC x M[T]
STORE X     M[X] <- AC  
Difference between Two-Address Instruction and One-Address Instruction :
Computer Organization & Architecture
Difference Between
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Architecture of 8085 microprocessor
Pin diagram of 8086 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Direct Access Media (DMA) Controller in Computer Architecture
General purpose registers in 8086 microprocessor
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between Process and Thread
Difference between var, let and const keywords in JavaScript
DateFormat format(Date obj) method in Java - GeeksforGeeks

28 Feb, 2019
The format() method of DateFormat class in Java is used to format a given Date object into a string representing Date/Time.
Syntax:
String format(Date date)

Parameters: This method accepts a single parameter date which is a Date object.
Return Value: This method returns a String which is the formatted date-time value of the Date object passed as a parameter to the method.
Below programs illustrate the above method:
Program 1:
// Java program to illustrate the// format() method  import java.text.DateFormat;import java.util.Date;  public class GFG {    public static void main(String[] args)    {        // Create a Date instance        Date currentDate = new Date();          // Create a DateFormat instance and format        // current Date        String dateToStr = DateFormat.getInstance()                               .format(currentDate);          System.out.println("Formatted Date String: "                           + dateToStr);    }}
Formatted Date String: 2/27/19 3:31 PM

Program 2:
// Java program to illustrate the// format() method  import java.text.DateFormat;import java.util.*;  public class GFG {    public static void main(String[] args)    {        // Create a Date instance        Date date = new Date(2323223232L);          // Create a DateFormat instance and format        // the specified Date        String dateToStr = DateFormat.getInstance()                               .format(date);          System.out.println("Formatted Date String: "                           + dateToStr);    }}
Formatted Date String: 1/27/70 9:20 PM

Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#format(java.util.Date)\
Java-Date-Time
Java-Functions
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
Stream In Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
ArrayList in Java
Stack Class in Java
Singleton Class in Java
Multidimensional Arrays in Java
HTML | Clearing the input field - GeeksforGeeks

29 Jul, 2021
To clear the entire input field without having to delete the whole thing manually Or what if there is already a pre-suggested input present in the input field, that the user doesn’t want. There could be many scenarios. Therefore, in this article, we are going to learn about how to clear the input field.
There are two ways to do this and both are super easy and short. Let us check out both of them.
Method 1: Clearing Input on Focus.
Syntax:
<input onfocus=this.value=''>
Approach:
Create an input field.
Set the onfocus attribute to NULL using this.value
Example:
<!DOCTYPE html><html>  <body>      <body style="text-align:center">        <h2 style="color:green">GeeksForGeeks</h2>        <h2 style="color:purple">Clearing Input Field</h2>        <p>The below input field will be cleared, as soon as it gets the focus</p>        <input type="text" onfocus="this.value=''" value="Click here to clear">    </body>  </html>
Output:Before:
After:
Method 2: Clearing Input with the help of button.
Syntax:
<button onclick="document.getElementById('InputID').value = ''>
Approach:
Create a button.
Get the id of input field.
Set the value NULL of input field using document.getElementById(‘myInput’).value = ”
<!DOCTYPE html><html>  <body style="text-align:center">    <h2 style="color:green">          GeeksForGeeks      </h2>    <h2 style="color:purple">      Clearing Input Field  </h2>    <p>The below input field will be      cleared, as soon as the button      gets clicked  </p>    <button onclick=            "document.getElementById(             'myInput').value = ''">      Click here to clear  </button>    <input type="text"            value="GeeksForGeeks"            id="myInput"></body>  </html>
Output:Before:
After:
HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubham_singh
HTML-Misc
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
How to Insert Form Data into Database using PHP ?
How to position a div at the bottom of its container using CSS?
Form validation using HTML and JavaScript
Remove elements from a JavaScript Array
Installation of Node.js on Linux
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
User-defined Exceptions in Python with Examples

Python throws errors and exceptions whenever code behaves abnormally & its execution stop abruptly. Python provides us tools to handle such scenarios by the help of exception handling method using try-except statements. Some standard exceptions which are found are include ArithmeticError, AssertionError, AttributeError, ImportError, etc.
Here we created a new exception class i.e. User_Error. Exceptions need to be derived from the built-in Exception class, either directly or indirectly. Let’s look at the given example which contains a constructor and display method within the given class.
 Live Demo
# class MyError is extended from super class Exception
class User_Error(Exception):
   # Constructor method
   def __init__(self, value):
      self.value = value
   # __str__ display function
   def __str__(self):
      return(repr(self.value))
try:
   raise(User_Error("User defined error"))
   # Value of Exception is stored in error
except User_Error as error:
   print('A New Exception occured:',error.value)
A New Exception occured: User defined error
Derived class Exceptions are created when a single module handles multiple several distinct errors. Here we created a base class for exceptions defined by that module. This base class is inherited by various user-defined class to handle different types of errors.
 Live Demo
# define Python user-defined exceptions
class Error(Exception):
   """Base class for other exceptions"""
   pass
class Dividebyzero(Error):
   """Raised when the input value is zero"""
   pass
try:
   i_num = int(input("Enter a number: "))
   if i_num ==0:
      raise Dividebyzero
except Dividebyzero:
   print("Input value is zero, try again!")
   print()
Enter a number: Input value is zero, try again!
Runtime error is a built-in class which is raised whenever a generated error does not fall into mentioned categories. The program below explains how to use runtime error as base class and user-defined error as derived class.
 Live Demo
# User defined error
class Usererror(RuntimeError):
   def __init__(self, arg):
      self.args = arg
try:
   raise Usererror("userError")
except Usererror as e:
   print (e.args)
('u', 's', 'e', 'r', 'E', 'r', 'r', 'o', 'r')
In this article, we learnt how we declare and implement user-defined exceptions in Python 3.x. Or earlier.
Python Program for Column to Row Transpose using Pandas

20 Jan, 2022
Given an Input File, having columns Dept and Name, perform an operation to convert the column values to rows. Name contains pipe separated values that belong to a particular department identified by the column Dept.
Attached Dataset: emp_data
Examples:
Input:
dept, name
10, Vivek|John
20, Ritika|Shubham|Nitin
30, Vishakha|Ankit

Output:
dept, name
10, Vivek
10, John
20, Ritika
20, Shubham
20, Nitin
30, Vishakha
30, Ankit

Method 1: Pythonic Way
Python
# Reading Data From the text# filedata = pd.read_csv(r'GFG.txt')    # create new data frame with # split value columns separates# data into three columns as per# separator mentionednew = data["name"].str.split("|",expand = True)   # making separate first name column# from new data frame assign columnn# values to dataframe new columns# named as name*data["Name1"] = new[0]data["Name2"] = new[1]data["Name3"] = new[2]  # Dropping old Name columns data.drop(columns =["name"], inplace = True)    # create separate dataframes with two# columns id,named_name1 = data[['dept','Name1']]d_name2 = data[['dept','Name2']]d_name3 = data[['dept','Name3']]   # perform concat/unions operation for# vertical merging of dataframesunion_df=pd.concat([d_name1,d_name2,d_name3],ignore_index=True)union_df.fillna('',inplace=True)  # concatenate values of series into one# series "name"union_df['name'] = union_df['Name1'].astype(str)+union_df['Name2'].astype(str)+union_df['Name3'].astype(str)   # drop column namesunion_df.drop(['Name1','Name2','Name3'],axis=1,inplace=True)  # drop rows having empty valuesfinal_df=union_df[union_df['name']!='']  # sort the dataframe data by dept valuesfinal_df.sort_values('dept')
Output:
Note: Shortcoming of above method is when there are more than 3 names separated by |
Method 2: Exploring Pandas
Python
emp_df = pd.read_csv(r'GFG.txt')  # split column data on basis of separator# convert it into list using to_list# stack method performs transpose operation# to the dataemp_df1 = pd.DataFrame(emp_df.name.str.split('|').to_list(),                       index = emp_df.dept).stack()  emp_df1 = emp_df1.reset_index([0, 'dept'])emp_df1.columns =['Dept', 'Name']  emp_df1
Method 3: The Pandas way: explode()
Python
df = pd.read_csv(r'GFG.txt')  # separate values using split()# transpose is performed by explode # function explode function overcomes # the method1 shortcomings incase we# have many columns we explode will do# the task in no time and with no hassledf1 = df.assign(name = df['name'].str.split('|')).explode('name')df1
Output:
sweetyty
simmytarika5
Python pandas-dataFrame
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 ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
Python – Append List every Nth index

11 Oct, 2020
Given 2 list, append list to the original list every nth index.
Input : test_list = [3, 7, 8, 2, 1, 5, 8], app_list = [‘G’, ‘F’, ‘G’], N = 3 Output : [‘G’, ‘F’, ‘G’, 3, 7, 8, ‘G’, ‘F’, ‘G’, 2, 1, 5, ‘G’, ‘F’, ‘G’, 8] Explanation : List is added after every 3rd element.Input : test_list = [3, 7, 8, 2, 1, 5, 8, 9], app_list = [‘G’, ‘F’, ‘G’], N = 4 Output : [‘G’, ‘F’, ‘G’, 3, 7, 8, 2, ‘G’, ‘F’, ‘G’, 1, 5, 8, 9 ‘G’, ‘F’, ‘G’] Explanation : List is added after every 4th element.  
Method #1 : Using loop
This is brute way to solve this problem, in this, every nth index, inner loop is used to append all other list elements.
Python3
# Python3 code to demonstrate working of # Append List every Nth index# Using loop  # initializing listtest_list = [3, 7, 8, 2, 1, 5, 8, 9, 3]  # printing original listprint("The original list is : " + str(test_list))  # initializing Append list app_list = ['G', 'F', 'G']  # initializing N N = 3  res = []for idx, ele in enumerate(test_list):          # if index multiple of N    if idx % N == 0:        for ele_in in app_list:            res.append(ele_in)    res.append(ele)  # printing result print("The appended list : " + str(res))
Output:
The original list is : [3, 7, 8, 2, 1, 5, 8, 9, 3]The appended list : [‘G’, ‘F’, ‘G’, 3, 7, 8, ‘G’, ‘F’, ‘G’, 2, 1, 5, ‘G’, ‘F’, ‘G’, 8, 9, 3]
Method #2 : Using extend()
Another way to solve this problem. In this, we use extend to get all the elements in every Nth index, rather than inner list.
Python3
# Python3 code to demonstrate working of # Append List every Nth index# Using extend()  # initializing listtest_list = [3, 7, 8, 2, 1, 5, 8, 9, 3]  # printing original listprint("The original list is : " + str(test_list))  # initializing Append list app_list = ['G', 'F', 'G']  # initializing N N = 3  res = []for idx, ele in enumerate(test_list):          # if index multiple of N    if idx % N == 0:                  # extend to append all elements        res.extend(app_list)              res.append(ele)  # printing result print("The appended list : " + str(res))
Output:
The original list is : [3, 7, 8, 2, 1, 5, 8, 9, 3]The appended list : [‘G’, ‘F’, ‘G’, 3, 7, 8, ‘G’, ‘F’, ‘G’, 2, 1, 5, ‘G’, ‘F’, ‘G’, 8, 9, 3]
Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to count occurrences of a word in a string

In this tutorial, we are going to write a program that counts the number of times a word occurs in the string. You are given the word and a string, we have to calculate the frequency of the word in the string.
Suppose we have a string I am a programmer. I am a student. And the word is. The program that we are going to write will return a number 2 as the word occurs two times in the string.
Let's follow the below steps to achieve our goal.
1. Initialize the string and the word as two variables.
2. Split the string at spaces using the split() method. We will get a list of words.
3. Initialize a variable count to zero.
4. Iterate over the list.
4.1. Check whether the word in the list is equal to the given the word or not.
4.1.1. Increment the count if the two words are matched.
5. Print the count.
Try to write the code for the program on your own first. Let's see the code.
## initializing the string and the word
string = "I am programmer. I am student."
word = "am"
## splitting the string at space
words = string.split()
## initializing count variable to 0
count = 0
## iterating over the list
for w in words:
   ## checking the match of the words
   if w == word:
      ## incrementint count on match
      count += 1
## printing the count
print(count)
If you run the above program, you will get the following results.
2
If you have any doubts regarding the program, ask them in the comment section.
PrintStream print(char) method in Java with Examples

31 Jan, 2019
The print(char) method of PrintStream Class in Java is used to print the specified char value on the stream. This char value is taken as a parameter.
Syntax:
public void print(char charValue)
Parameters: This method accepts a mandatory parameter charValue which is the char value to be written on the stream.
Return Value: This method do not returns any value.
Below methods illustrates the working of print(char) method:
Program 1:
// Java program to demonstrate// PrintStream print(char) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a PrintStream instance            PrintStream printr                = new PrintStream(System.out);              // Print the char value 'A'            // to this stream using print() method            // This will put the charValue in the            // stream till it is printed on the console            printr.print('A');              printr.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
A

Program 2:
// Java program to demonstrate// PrintStream print(char) method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a PrintStream instance            PrintStream printr                = new PrintStream(System.out);              // Print the char value 'G'            // to this stream using print() method            // This will put the charValue in the            // stream till it is printed on the console            printr.print('G');              printr.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
G

Java-Functions
Java-IO package
Java-PrintStream
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Primary and Candidate Key

22 Mar, 2021
Prerequisite – DBMS | Keys in Relational Model Both Primary Key and Candidate Key are the attributes that are used to access tuples from a table. These(Primary key and Candidate key) are also can be used to create a relationship between two tables. 
Primary Key: Primary Key is a set of attributes (or attribute) which uniquely identify the tuples in relation or table. The primary key is a minimal super key, so there is one and only one primary key in any relationship. For example,  
Student{ID, F_name, M_name, L_name, Age} 
Here only ID can be primary key because the name, age and address can be same, but ID can’t be same. 
Candidate Key: A candidate key is a set of attributes (or attribute) which uniquely identify the tuples in relation or table. As we know that Primary key is a minimal super key, so there is one and only one primary key in any relationship but there is more than one candidate key can take place. Candidate key’s attributes can contain a NULL value which opposes to the primary key. For example,  
Student{ID, First_name, Last_name, Age} 
Here we can see the two candidate keys ID and {First_name, Last_name, DOB}. So here, there are present more than one candidate keys, which can uniquely identify a tuple in a relation. 
Difference between Primary and Candidate Key:  
shriwastavaraj52
DBMS
Difference Between
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
MySQL | Regular expressions (Regexp)
Difference between OLAP and OLTP in DBMS
OLAP Guidelines (Codd's Rule)
What is Temporary Table in SQL?
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
How to fill up the rest of screen height using Tailwind CSS ?

26 May, 2021
In this article, we will learn how to fill up the rest of the screen height using Tailwind CSS.
Approach: To solve the above problem we’ll be using the Flex Class and Height Class of Tailwind CSS. 
The classes that we’ll be using to solve this are as follows.
flex: It is used to set the length of flexible items. The flex class is much responsive and mobile-friendly.
flex-col: It is used to position flex items vertically.
h-screen: This class is used to make an element span the entire height of the viewport.
Example:
HTML
<!DOCTYPE html><html>  <head>    <link href="https://unpkg.com/tailwindcss@1.8.12/dist/tailwind.min.css"        rel="stylesheet" /></head>  <body>    <div class="flex flex-col h-screen">        <div class="bg-yellow-500 py-8 hidden sm:block ">            <div class="flex space-x-4">                <a href="#" class="bg-gray-900 text-white                         px-3 py-2 rounded-md text-sm                         font-medium" aria-current="page">                    GeeksForGeeks Dashboard                </a>                                  <a href="#" class="text-gray-300                         hover:bg-gray-700                         hover:text-white px-3 py-2                         rounded-md text-sm font-medium">                    Team                </a>                                  <a href="#" class="text-gray-300                         hover:bg-gray-700                        hover:text-white px-3 py-2                         rounded-md text-sm font-medium">                    Projects                </a>                                  <a href="#" class="text-gray-300                         hover:bg-gray-700 hover:text-white                         px-3 py-2 rounded-md                         text-sm font-medium">                    Calendar                </a>            </div>        </div>                  <div class="bg-green-500 flex flex-grow">            This is the other content on screen        </div>    </div></body>  </html>
Output:
Picked
Tailwind CSS-Questions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a Tribute Page using HTML & CSS
Form validation using jQuery
How to Change the Position of Scrollbar using CSS ?
Build a Survey Form using HTML and CSS
Installation of Node.js on Linux
How to set the default value for an HTML <select> element ?
How do you run JavaScript script through the Terminal?
Node.js fs.readFileSync() Method
How to set space between the flexbox ?
Python Continue Statement

27 Aug, 2021
In this article, we will discuss continue statements in Python for altering the flow of loops.
Loops in Python automates and repeats the tasks in an efficient manner. But sometimes, there may arise a condition where you want to exit the loop completely, skip an iteration or ignore that condition. These can be done by loop control statements. Continue is a type of loop control statement that can alter the flow of the loop. 
Continue statement is a loop control statement that forces to execute the next iteration of the loop while skipping the rest of the code inside the loop for the current iteration only i.e. when the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped for the current iteration and the next iteration of the loop will begin.
Syntax: 
continue
Consider the situation when you need to write a program which prints the number from 1 to 10 and but not 6. It is specified that you have to do this using loop and only one loop is allowed to use. Here comes the usage of continue statement. What we can do here is we can run a loop from 1 to 10 and every time we have to compare the value of the iterator with 6. If it is equal to 6 we will use the continue statement to continue to the next iteration without printing anything otherwise we will print the value.
Below is the implementation of the above idea:
Python3
# Python program to# demonstrate continue# statement # loop from 1 to 10for i in range(1, 11):     # If i is equals to 6,    # continue to next iteration    # without printing    if i == 6:        continue    else:        # otherwise print the value        # of i        print(i, end=" ")
Output: 
1 2 3 4 5 7 8 9 10 
Note: The continue statement can be used with any other loop also like while loop in a similar way as it is used with for loop above.
Exercise Problem: 
Given a number n, print triangular pattern. We are allowed to use only one loop.
Input: 7
Output:
*
* * 
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
Solution: Print the pattern by using one loop | Set 2 (Using Continue Statement)
nikhilaggarwal3
kapoorsagar226
Python-OOP
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
Iterate over a list in Python
How to create line chart using react bootstrap ?

21 Jun, 2021
Line charts are used to represent the relation between two data X and Y on a different axis. One of the axes of the plot represents the specific categories being compared, while the other axis represents the measured values corresponding to those categories.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.npx create-react-app foldername
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 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 required modules using the following command.npm install --save mdbreact react-chartjs-2
Step 3: After creating the ReactJS application, Install the required modules using the following command.
npm install --save mdbreact react-chartjs-2
Step 4: Add Bootstrap CSS and fontawesome CSS to index.js.import '@fortawesome/fontawesome-free/css/all.min.css';  
import 'bootstrap-css-only/css/bootstrap.min.css';  
import 'mdbreact/dist/css/mdb.css';
Step 4: Add Bootstrap CSS and fontawesome CSS to index.js.
import '@fortawesome/fontawesome-free/css/all.min.css';  
import 'bootstrap-css-only/css/bootstrap.min.css';  
import 'mdbreact/dist/css/mdb.css';
Project Structure: It will look like the following.
Project Structure
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from "react";import { MDBContainer } from "mdbreact";import { Line } from "react-chartjs-2";  const App = () => {    // Sample data  const data = {    labels: ["Sunday", "Monday", "Tuesday",      "Wednesday", "Thursday", "Friday", "Saturday"],    datasets: [      {        label: "Hours Studied in Geeksforgeeks",        data: [2, 5, 7, 9, 7, 6, 4],        fill: true,        backgroundColor: "rgba(6, 156,51, .3)",        borderColor: "#02b844",      }    ]  }    return (    <MDBContainer>      <Line data={data} />    </MDBContainer>  );}  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:
Picked
React-Bootstrap
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create a GitHub repository

A GitHub account is a pre-requisite for creating a GitHub repository. Follow the below steps after registering with GitHub.
Step 1 − Login to the GitHub account. Once you login to your account you will see a ‘+’ button on the right. Click on the button and select "New repository" option to create a new repository.
Configure the following in the create a new repository page.
Repository name: GitHub will validate the repository name that you have entered.
Repository name: GitHub will validate the repository name that you have entered.
Type of the repository: GitHub lets you create the following types of repositories −Private repository − Private Repository is the one that can be accessed only by the repository owner and individuals with whom the repository has been shared. Anyone who is not explicitly granted access to the repository cannot view the source code. Private repositories can be used for programs that are proprietary for you at the moment and you don't want to share.Public repository − Public Repository is the one which is open and available for everyone. Public Repositories can be used for open-source projects.
Type of the repository: GitHub lets you create the following types of repositories −
Private repository − Private Repository is the one that can be accessed only by the repository owner and individuals with whom the repository has been shared. Anyone who is not explicitly granted access to the repository cannot view the source code. Private repositories can be used for programs that are proprietary for you at the moment and you don't want to share.
Private repository − Private Repository is the one that can be accessed only by the repository owner and individuals with whom the repository has been shared. Anyone who is not explicitly granted access to the repository cannot view the source code. Private repositories can be used for programs that are proprietary for you at the moment and you don't want to share.
Public repository − Public Repository is the one which is open and available for everyone. Public Repositories can be used for open-source projects.
Public repository − Public Repository is the one which is open and available for everyone. Public Repositories can be used for open-source projects.
We will create a public repository for the purpose of demonstration. You can keep the default settings. We have selected the option to add a README.txt. This file is used to provide repo description.
You will find the URL of your first project in the format shown below. In the below URL sample_repo is the name of the repository and author_name will be your GitHub account name.
https://github.com/{author_name}/sample_repo
Once you refresh the URL, you will be able to see the sample README.md file and all commits as shown below.
Select the next row after skipping every 2 rows in MySQL

To skip rows, you can use OFFSET. Let us first create a table −
mysql> create table DemoTable617(Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,FirstName varchar(100));
Query OK, 0 rows affected (1.70 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable617(FirstName) values('John');
Query OK, 1 row affected (0.39 sec)
mysql> insert into DemoTable617(FirstName) values('Sam');
Query OK, 1 row affected (0.39 sec)
mysql> insert into DemoTable617(FirstName) values('Carol');
Query OK, 1 row affected (0.24 sec)
mysql> insert into DemoTable617(FirstName) values('Mike');
Query OK, 1 row affected (0.34 sec)
mysql> insert into DemoTable617(FirstName) values('David');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable617(FirstName) values('Bob');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable617(FirstName) values('Robert');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable617(FirstName) values('Chris');
Query OK, 1 row affected (0.27 sec)
mysql> insert into DemoTable617(FirstName) values('Mike');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable617(FirstName) values('Adam');
Query OK, 1 row affected (0.49 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable617;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
| 1 | John       |
| 2 | Sam        |
| 3 | Carol      |
| 4 | Mike       |
| 5 | David      |
| 6 | Bob        |
| 7 | Robert     |
| 8 | Chris      |
| 9 | Mike       |
| 10| Adam      |
+----+-----------+
10 rows in set (0.00 sec)
Following is the query to select rows. At first order by DESC. After that, it will skip two rows and display 5 rows using LIMIT 5 −
mysql> select tbl.* from (select *from DemoTable617 order by FirstName DESC LIMIT 5 OFFSET 2) AS tbl ORDER BY tbl.Id
;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
| 1 | John       |
| 4 | Mike       |
| 5 | David      |
| 8 | Chris      |
| 9 | Mike       |
+----+-----------+
5 rows in set (0.00 sec)