code-rag-bench/online-tutorials huggingface dataset:
Using else conditional statement with for loop in python

In this article, we will be learning about loop-else statements in Python 3.x. Or earlier. In this tutorial, we will focus on for loop & else statement way of execution.
In other languages, the else functionality is only provided in if-else pairs. But Python allows us to implement the else functionality with for loops as well .
The else functionality is available for use only when the loop terminates normally. In case of forceful termination of loop else statement is overlooked by the interpreter and hence its execution is skipped.
Now let’s take a quick glance over some illustrations to understand the loop else statement in a better manner.
 Live Demo
for i in ['T','P']:
   print(i)
else: # Loop else statement
   print("Loop-else statement successfully executed")
T
P
Loop-else statement successfully executed
 Live Demo
for i in ['T','P']:
   print(i)
   break
else: # Loop else statement
   print("Loop-else statement successfully executed")
T
Explanation − The loop else statement is executed in ILLUSTRATION 1 as the for loop terminates normally after completing its iteration over the list[‘T’,’P’].But in ILLUSTRATION 2 ,the loop-else statement is not executed as the loop is forcefully terminated by using jump statements like break .
These ILLUSTRATIONS clearly indicates the loop-else statement is not executed when loop is terminated forcefully.
Now Let’s look at an illustration wherein some condition the loop-else statement is executed and in some, it’s not.
 Live Demo
def pos_nev_test():
   for i in [5,6,7]:
   if i>=0:
      print ("Positive number")
   else:
      print ("Negative number")
      break
   else:
      print ("Loop-else Executed")
# main function
pos_nev_test()
Positive number
Positive number
Positive number
Loop-else Executed
Explanation − Here as the else block in the if-else construct is not executed as if the condition evaluates to be true, the Loop-Else statement is executed.
If we replace the list in for loop [5, 6, 7 ] by [7, -1, 3 ] then the output changes to
Positive number
Negative number
In this article, we learnt the implementation of loop-else statement and a variety of ways in which it can be implemented.
ChronoZonedDateTime format() method in Java with Examples - GeeksforGeeks

28 May, 2019
The format() method of ChronoZonedDateTime interface in Java is used to format this date-time using the specified formatter passed as parameter.This date-time will be passed to the formatter to produce a string.
Syntax:
default String format(DateTimeFormatter formatter)

Parameters: This method accepts a single parameter formatter which represents the formatter to use. This is a mandatory parameter and should not be NULL.
Return value: This method returns a String represents the formatted date-time string.
Exception: This method throws a DateTimeException if an error occurs during printing.
Below programs illustrate the format() method:Program 1:
// Java program to demonstrate// ChronoZonedDateTime.format() method  import java.time.*;import java.time.chrono.*;import java.time.format.*;  public class GFG {    public static void main(String[] args)    {          // create ChronoZonedDateTime objects        ChronoZonedDateTime zoneddatetime            = ZonedDateTime.parse(                "2018-12-06T19:21:12.123+05:30[Asia/Calcutta]");          // create a formatter        DateTimeFormatter formatter            = DateTimeFormatter.ISO_TIME;          // apply format()        String value            = zoneddatetime.format(formatter);          // print result        System.out.println("Result: " + value);    }}
Result: 19:21:12.123+05:30

Program 2:
// Java program to demonstrate// ChronoZonedDateTime.format() method  import java.time.*;import java.time.chrono.*;import java.time.format.*;  public class GFG {    public static void main(String[] args)    {          // create ChronoZonedDateTime objects        ChronoZonedDateTime zoneddatetime            = ZonedDateTime.parse(                "2018-10-25T23:12:31.123+02:00[Europe/Paris]");          // create a formatter        DateTimeFormatter formatter            = DateTimeFormatter.BASIC_ISO_DATE;          // apply format()        String value            = zoneddatetime.format(formatter);          // print result        System.out.println("Result: " + value);    }}
Result: 20181025+0200

Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoZonedDateTime.html#format-java.time.format.DateTimeFormatter-
Java-ChronoZonedDateTime
Java-Functions
Java-Time-Chrono 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
Different ways of Reading a text file in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
Introduction to Java
HashMap get() Method in Java
Strings in Java
CodeIgniter - Page Redirection

While building web application, we often need to redirect the user from one page to another page. CodeIgniter makes this job easy for us. The redirect() function is used for this purpose.
Syntax
Parameters
$uri (string) − URI string
$uri (string) − URI string
$method (string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)
$method (string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)
$code (string) − HTTP Response code (usually 302 or 303)
$code (string) − HTTP Response code (usually 302 or 303)
Return type
The first argument can have two types of URI. We can pass full site URL or URI segments to the controller you want to direct.
The second optional parameter can have any of the three values from auto, location or refresh. The default is auto.
The third optional parameter is only available with location redirects and it allows you to send specific HTTP response code.
Create a controller called Redirect_controller.php and save it in application/controller/Redirect_controller.php
<?php 
   class Redirect_controller extends CI_Controller { 
	
      public function index() { 
         /*Load the URL helper*/ 
         $this->load->helper('url'); 
   
         /*Redirect the user to some site*/ 
         redirect('http://www.tutorialspoint.com'); 
      }
		
      public function computer_graphics() { 
         /*Load the URL helper*/ 
         $this->load->helper('url'); 
         redirect('http://www.tutorialspoint.com/computer_graphics/index.htm'); 
      } 
  
      public function version2() { 
         /*Load the URL helper*/ 
         $this->load->helper('url'); 
   
         /*Redirect the user to some internal controller’s method*/ 
         redirect('redirect/computer_graphics'); 
      } 
		
   } 
?>
Change the routes.php file in application/config/routes.php to add route for the above controller and add the following line at the end of the file.
$route['redirect'] = 'Redirect_controller'; 
$route['redirect/version2'] = 'Redirect_controller/version2'; 
$route['redirect/computer_graphics'] = 'Redirect_controller/computer_graphics';
Type the following URL in the browser, to execute the example.
http://yoursite.com/index.php/redirect

The above URL will redirect you to the tutorialspoint.com website and if you visit the following URL, then it will redirect you to the computer graphics tutorial at tutorialspoint.com.
http://yoursite.com/index.php/redirect/computer_graphics

 Print
 Add Notes
 Bookmark this page
Query returning no data in SAP Business One using Table Relationship

This looks like an issue with Join in queries. Try replacing Inner join with Left join like this. I ran this query and it is working fine:
select T0.DocNum as 'Payment Number',T0.DocDate 'Payment Date',T0.CardCode,
T0.CardName 'Customer Name',T1.BankCode 'Bankcode',T3.BankName 'Bank Name', T2.Phone1 ,
T0.CreditSum,
T0.CashSum,
T0.TrsfrSum,
t0.CheckSum,
t1.CheckNum as 'Check Number',
t1.DueDate as 'check date',
t6.VoucherNum as 'Voucher Number',
t0.TrsfrRef as 'Transfer No',
t0.TrsfrDate AS 'Transfer Date',
ousr.USER_code as 'user code',
T5.DocNum, t11.U_P_BuildingName as 'Building Name',
CASE when T5.DocNum is null then 'On Account' else 'Paid For Invoice' END AS 'Payment Status',
CASE when T5.DocStatus = 'O' then 'Open' else 'Closed' END AS ' Invoice Status',
T4.SumApplied as 'Amount Paid on Invoice',T9.U_FloorNo,T5.U_UnitCode,T5.U_Type,
t0.DocTotal as 'Payment Total',t5.DocTotal as'Invoice Total' , t8.City,
t0.Comments as'Remarks'
from ORCT T0
left join rct1 T1 on T0.DocNum=T1.DocNum
left join ocrd T2 on T2.CardCode=T0.CardCode
left outer join ODSC T3 on T3.BankCode=T0.BankCode
left join RCT2 T4 on T0.DocNum = T4.DocNum
left join RCT3 T6 on T0.DocNum = T6.DocNum
left join OINV T5 on T4.DocEntry = T5.DocEntry and T5.ObjType = T4.InvType
left join oitm t11 on t5.u_unitcode = t11.ItemCode
LEFT JOIN OWHS T8 ON T11.U_P_BuildingNum = T8.WhsCode
LEFT JOIN [dbo].[@AUND] T9 ON T5.[U_UnitCode] = T9.[Code]
INNER JOIN OSLP T10 ON T5.[SlpCode] = T10.[SlpCode]
inner join ousr on ousr.USERID = t0.usersign
where
T4.InvType <> '14' and T0.[Canceled] = 'N' and t0.docnum=200001
numpy.where() in Python - GeeksforGeeks

03 Dec, 2020
The numpy.where() function returns the indices of elements in an input array where the given condition is satisfied.
Syntax :numpy.where(condition[, x, y])Parameters:condition : When True, yield x, otherwise yield y.x, y : Values from which to choose. x, y and condition need to be broadcastable to some shape.
Returns:out : [ndarray or tuple of ndarrays] If both x and y are specified, the output array contains elements of x where condition is True, and elements from y elsewhere.
If only condition is given, return the tuple condition.nonzero(), the indices where condition is True.
Code #1:
# Python program explaining # where() function   import numpy as np  np.where([[True, False], [True, True]],         [[1, 2], [3, 4]], [[5, 6], [7, 8]])
Output :
array([[1, 6],
       [3, 4]])
 
Code #2:
# Python program explaining # where() function   import numpy as np  # a is an array of integers.a = np.array([[1, 2, 3], [4, 5, 6]])  print(a)  print ('Indices of elements <4')  b = np.where(a<4)print(b)  print("Elements which are <4")print(a[b])
Output :
[[1 2 3]
 [4 5 6]]

Indices of elements <4
(array([0, 0, 0], dtype=int64), array([0, 1, 2], dtype=int64))

Elements which are <4
array([1, 2, 3])

Python numpy-Indexing
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Python OOPs Concepts
Different ways to create Pandas Dataframe
sum() function in Python
How to Install PIP on Windows ?
Stack in Python
Bar Plot in Matplotlib
Reading and Writing to text files in Python
How are Spectrum and Bandwidth defined in Wireless Communications?

Spectrum refers to the entire range of frequencies right from the starting frequency (the lowest frequency) to the ending frequency (the highest frequency). Spectrum basically refers to the entire group of frequencies.
The electromagnetic spectrum is one good example. The electromagnetic (EM) spectrum covers frequencies right from zero (DC) to gamma band frequencies. This spectrum includes the human voice frequency band (audio band), ISM (Industrial Scientific Medical) band and optical frequency bands.
Microwave radiations span in frequency from 300 MHz to 300 GHz. What is the spectrum of microwave radiation?
Spectrum refers to the entire range of frequencies that exist in the microwave band. Therefore, the spectrum of microwave radiation is (300 MHz to 300 GHz).
The difference between spectrum and bandwidth is that spectrum refers to the ‘entirety’ while bandwidth is a ‘sub-section’ of the spectrum. Spectrum refers to the wholesome of the quantity while bandwidth, on the other hand, is a portion of the entire spectrum.
Bandwidth is a sub-section of a portion of spectrum.
If frequencies from 12 MHz up to 40 MHz are allocated for an application, the spectrum refers to the entire range of frequencies right from 12 MHz to 40 MHz Therefore, the spectrum is (12 to 40) MHz. In some cases, the entire allocated
12 MHz to 40 MHz = Spectrum
17 MHz to 20 MHz = Bandwidth
frequencies may not be used by the application. So, if only 17 MHz to 20 MHz is used by an application, then, those range of frequencies used is called the ‘bandwidth’.
The commercial FM radio is one good example that explains the difference between the spectrum and the bandwidth. Spectrum here refers to the entire range of frequencies allocated for the FM radio application which is usually around 20 MHz (108 MHz to 87.5 MHz). An FM radio station doesn’t occupy the entire frequency band but just a fraction of it. Let us say that an FM station operates over the center frequency 93.5 MHz FM radio stations are usually allocated a bandwidth of 200 kHz. So, the range of frequencies over which the FM radio station operates is 93.4 MHz to 93.6 MHz.
Let us look at one more example to understand the difference between spectrum and the bandwidth. Grapes come in different colours, sizes and tastes depending on the growing conditions and methods. The entire family is still called grapes even though there are differences in colour, size and taste. Bandwidth, however, refers to a particular group- a group of grapes grown in area X might have black colour, slightly sour taste Spectrum = 20 MHz Bandwidth of the radio station = 200 kHz and oval figure while a group of grapes grown in area Y might have green colour, sweet taste and oval figure.
Entire family of grapes = Spectrum
Different groups among grapes = Bandwidth
Python calendar module : formatmonth() method - GeeksforGeeks

04 Dec, 2020
Calendar module allows to output calendars like program, and provides additional useful functions related to the calendar. Functions and classes defined in Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions.
class calendar.TextCalendar(firstweekday=0) can be used to generate plain text calendars. formatmonth() method is one of the methods of TextCalendar instance.
formatmonth() method in Python is used to get month’s calendar in a multi-line string.
Syntax: formatmonth(year, month, width=0, lines=0)
Parameter:year: year of the calendarmonth: month of the calendarwidth: [optional] Specifies the width of the date columns, which are centeredline: [optional] Specifies the number of lines that each week will use.
Returns: Return a month’s calendar.
Code #1:
# Python program to demonstrate working of formatmonth() method  # importing calendar moduleimport calendar  text_cal = calendar.TextCalendar(firstweekday = 0)  year = 2018month = 9# default value of width is 0  # printing formatmonthprint(text_cal.formatmonth(year, month))
Output:
   September 2018
Mo Tu We Th Fr Sa Su
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

 
Code #2: With parameter width
# Python program to demonstrate working of formatmonth() method  # importing calendar moduleimport calendar  text_cal = calendar.TextCalendar(firstweekday = 0)    # default value of width is 0  # printing formatmonthprint(text_cal.formatmonth(2018, 9, w = 5))
Output:
              September 2018
 Mon   Tue   Wed   Thu   Fri   Sat   Sun
                                 1     2
   3     4     5     6     7     8     9
  10    11    12    13    14    15    16
  17    18    19    20    21    22    23
  24    25    26    27    28    29    30
 Code #3:
# Python program to demonstrate working of formatmonth() method  # importing calendar moduleimport calendar  text_cal = calendar.TextCalendar(firstweekday = 0)    # giving value of width = 6, line = 2  # printing formatmonthprint(text_cal.formatmonth(2018, 10, 6, 2))
Output:
                  October 2018

 Mon    Tue    Wed    Thu    Fri    Sat    Sun

   1      2      3      4      5      6      7

   8      9     10     11     12     13     14

  15     16     17     18     19     20     21

  22     23     24     25     26     27     28

  29     30     31
Python Calander-module
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How to convert uppercase string to lowercase using PHP ? - GeeksforGeeks

19 May, 2021
The best way to convert uppercase string to lowercase in PHP is by using the strtolower() function. It takes the string as the input and converts it’s all characters to the lower case and returns the string value.
Syntax:
string strtolower( $string )
Return value: It returns the string converted into lower string.
Example 1:
PHP
<?php  echo strtolower("GeeksForGeeks")?>
geeksforgeeks
Example 2:
PHP
<?php    $str = "Geeks For Geeks";    $lowerStr = strtolower($str);    echo $lowerStr?>
geeks for geeks
Example 3:
PHP
<?php    $str = "HelLo GeeKs hAve A wonDERful DaY";    echo strtolower($str);?>
hello geeks have a wonderful day
PHP-function
PHP-Questions
PHP-string
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Django Migrations | Python - GeeksforGeeks

03 Jul, 2019
Prerequisite: Django Models
The class defined in product/models.py is the mere idea of what our database is going to look like but it didn’t create any table in the database. We can assume class Phone as conceptual schema. Before the creation of any table, if we try to access the table before creation, it will throw an error like this.
OperationalError at /admin/product/phone/
no such table: product_phone
Python provides certain commands for user convenience so that without going into details of SQL,a user can interact with the database. Now, we have created the class (conceptual schema of the database), we can use migrate command to create the actual schema in the database. Stop the server using CTRL+C if running and run the following command in the database.
python manage.py makemigrations
Above command will let the project know that we want to make changes in the database. You will see following quoting that Create model Phone.what does this command do? This command will generate SQL statements that are supposed to be executed if we wish to make changes in the database.If you want to see the generated commands, navigate to product/migrations/0001_initial.py. You will see file contentIf you try to run the server now using command
python manage.py runserver
you will see
You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): product. Run ‘python manage.py migrate’ to apply them.
As written in warning, run
python manage.py migrate
in your terminal. This will result in creation of table in database.
Python Django
Web technologies
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Program to Convert Radian to Degree in C

If input is in radian convert it to degree else input will be in radian convert it to degree. There are formulas that can be used for this conversion.
Radian is the standard unit for measuring angles whereas the complete angle of circle is divided into 360 degree. Also, radian is the smaller value as 1 degree = 180 radians.
Conversion Formulas −
degree = radian * (180/pi)
where, pi=3.14 or 22/7
Example
Input-: radian = 9.0
Output-: degree is : 515.92357
Start
Step 1 -> define macro as #define pi 3.14
Step 2 -> declare function for converting radian to degree
   double convert(double radian)
      return(radian * (180/pi))
Step 3 -> In main()
   Declare variable as double radian = 9.0
   Declare and set double degree = convert(radian)
   Print degree
Stop
#include <stdio.h>
#define pi 3.14
// Function for converting radian to degree
double convert(double radian){
   return(radian * (180/pi));
}
   int main(){
   double radian = 9.0;
   double degree = convert(radian);
   printf("degree is : %.5lf", degree);
   return 0;
}
degree is : 515.92357
CSS elevation Property

01 Oct, 2020
The CSS elevation property is used to set the sound source on the vertical axis depending on the listener’s environment.
 Syntax:
elevation: angle:

Parameters: This property accepts single value as mentioned above and described below:
angle: This parameter holds the angle of the source, where the sound is generated. There are few possible values that is accepted by this parameter in the range of 90deg to -90deg. Name of the positions is acceptable.
above = 90deg
level = 0deg
below = -90deg
higher = shifted upwards by 10deg compare to initial(0deg)
lower = shifted downwards by 10deg compare to initial(0deg)


Example 1:
HTML
<!DOCTYPE html><html>  <head>    <style>        audio {            elevation: above;        }    </style></head>  <body style="text-align: center;">    <h1 style="color: green;">GeeksforGeeks</h1>      <p>CSS elevation Property</p>      <audio controls>        <source src="https://media.geeksforgeeks.org/wp-content/uploads/20190625153922/frog.mp3"        type="audio/mp3">    </audio></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <head>    <style>        audio {            elevation: below;        }    </style></head>  <body style="text-align: center;">    <h1 style="color: green;">        GeeksforGeeks    </h1>      <p>CSS elevation Property</p>      <audio controls>        <source src="https://media.geeksforgeeks.org/wp-content/uploads/20190625153922/frog.mp3"        type="audio/mp3">    </audio></body>  </html>
Output:
Supported Browsers: This property is deprecated in CSS3 so the major browsers are not supported by this property
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
FIRST Set in Syntax Analysis

31 Jul, 2021
FIRST(X) for a grammar symbol X is the set of terminals that begin the strings derivable from X. 
Rules to compute FIRST set: 
If x is a terminal, then FIRST(x) = { ‘x’ }If x-> Є, is a production rule, then add Є to FIRST(x).If X->Y1 Y2 Y3....Yn is a production, FIRST(X) = FIRST(Y1)If FIRST(Y1) contains Є then FIRST(X) = { FIRST(Y1) – Є } U { FIRST(Y2) }If FIRST (Yi) contains Є for all i = 1 to n, then add Є to FIRST(X).
If x is a terminal, then FIRST(x) = { ‘x’ }
If x-> Є, is a production rule, then add Є to FIRST(x).
If X->Y1 Y2 Y3....Yn is a production, FIRST(X) = FIRST(Y1)If FIRST(Y1) contains Є then FIRST(X) = { FIRST(Y1) – Є } U { FIRST(Y2) }If FIRST (Yi) contains Є for all i = 1 to n, then add Є to FIRST(X).
FIRST(X) = FIRST(Y1)If FIRST(Y1) contains Є then FIRST(X) = { FIRST(Y1) – Є } U { FIRST(Y2) }If FIRST (Yi) contains Є for all i = 1 to n, then add Є to FIRST(X).
FIRST(X) = FIRST(Y1)
If FIRST(Y1) contains Є then FIRST(X) = { FIRST(Y1) – Є } U { FIRST(Y2) }
If FIRST (Yi) contains Є for all i = 1 to n, then add Є to FIRST(X).
Example 1: 
Production Rules of Grammar
E  -> TE’
E’ -> +T E’|Є
T  -> F T’
T’ -> *F T’ | Є
F  -> (E) | id

FIRST sets
FIRST(E) = FIRST(T) = { ( , id }
FIRST(E’) = { +, Є }
FIRST(T) = FIRST(F) = { ( , id }
FIRST(T’) = { *, Є }
FIRST(F) = { ( , id }
Example 2: 
Production Rules of Grammar
S -> ACB | Cbb | Ba
A -> da | BC
B -> g | Є
C -> h | Є

FIRST sets
FIRST(S) = FIRST(ACB) U FIRST(Cbb) U FIRST(Ba)
         = { d, g, h, b, a, Є}
FIRST(A) = { d } U FIRST(BC) 
         = { d, g, h, Є }
FIRST(B) = { g , Є }
FIRST(C) = { h , Є }
Notes: 
The grammar used above is Context-Free Grammar (CFG). Syntax of most of the programming language can be specified using CFG.CFG is of the form A -> B , where A is a single Non-Terminal, and B can be a set of grammar symbols ( i.e. Terminals as well as Non-Terminals)
The grammar used above is Context-Free Grammar (CFG). Syntax of most of the programming language can be specified using CFG.
CFG is of the form A -> B , where A is a single Non-Terminal, and B can be a set of grammar symbols ( i.e. Terminals as well as Non-Terminals)
In the next article “FOLLOW sets in Compiler Design” we will see how to compute Follow sets. 
This article is compiled by Vaibhav Bajpai. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
VaibhavRai3
1watyd6bxgvi21srkng09kmrlpsl0yb4pdr2dyx9
alvinshaita
Compiler Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas MultiIndex.from_arrays()

24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas MultiIndex.from_arrays() function is used to convert arrays into MultiIndex. It is one of the several ways in which we construct a MultiIndex.
Syntax: MultiIndex.from_arrays(arrays, sortorder=None, names=None)
Parameters :arrays : Each array-like gives one level’s value for each data point. len(arrays) is the number of levelssortorder : Level of sortedness (must be lexicographically sorted by that level)
Returns: index : MultiIndex
Example #1: Use MultiIndex.from_arrays() function to construct a MultiIndex from arrays.
# importing pandas as pdimport pandas as pd  # Creating the arrayarray =[[1, 2, 3], ['Sharon', 'Nick', 'Bailey']]  # Print the arrayprint(array)
Output :
Now let’s create the MultiIndex using this array
# Creating the MultiIndexmidx = pd.MultiIndex.from_arrays(array,            names =('Number', 'Names'))  # Print the MultiIndexprint(midx)
Output :As we can see in the output, the function has created a MultiIndex object using the arrays. Example #2: Use MultiIndex.from_arrays() function to construct a MultiIndex from arrays.
# importing pandas as pdimport pandas as pd  # Creating the arrayarray =[[1, 2, 3], ['Sharon', 'Nick', 'Bailey'],           ['Doctor', 'Scientist', 'Physicist']]  # Print the arrayprint(array)
Output :
Now let’s create the MultiIndex using this array
# Creating the MultiIndexmidx = pd.MultiIndex.from_arrays(array,    names =('Ranking', 'Names', 'Profession'))  # Print the MultiIndexprint(midx)
Output :As we can see in the output, the function has created a MultiIndex using the passed arrays.
Python pandas-multiIndex
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
Java protected Keyword

❮ Java Keywords

The Student subclass accesses a Person class with protected attributes:
class Person {
  protected String fname = "John";
  protected String lname = "Doe";
  protected String email = "john@doe.com";
  protected int age = 24;
}

class Student extends Person {
  private int graduationYear = 2018;
  public static void main(String[] args) {
    Student myObj = new Student();
    System.out.println("Name: " + myObj.fname + " " + myObj.lname);
    System.out.println("Email: " + myObj.email);
    System.out.println("Age: " + myObj.age);
    System.out.println("Graduation Year: " + myObj.graduationYear);
  }
}


Try it Yourself »

The protected keyword is an access modifier used for attributes, methods and constructors, making them accessible in the same package and subclasses.
Read more about modifiers in our Java Modifiers Tutorial.

❮ Java Keywords

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Instanceof operator in JavaScript

The instance of operator tests whether the prototype property of a constructor appears anywhere in the prototype chain of an object. In a simpler languange, it tests if a variable is of a certain type. But it has a few caveats. Let us look at some examples.
Strings and numbers are primitive values, not objects and therefore don't have a [[Prototype]], so it'll only work if you wrap them in regular objects.
console.log(1 instanceof Number)
console.log(new Number(1) instanceof Number)
console.log("" instanceof String)
console.log(new String("") instanceof String)
false
true
false
true
Functions that return their objects(JS Classes) can have their objects checked using the instanceof operator.
function Person(name) {
   this.name = name
}
let john = new Person("John");
console.log(john instanceof Person)
true
JS supports prototypical inheritence, so if you check for instanceof for any class in the hierarchy, it'll return true.
class Person {}
class Student extends Person {
   constructor(name) {
      super()
      this.name = name
   }
}
let john = new Student("John");
console.log(john instanceof Person)
console.log(john instanceof Student)
true
true
Concat a field in MySQL SELECT?

To concat a field in MySQL SELECT, use the CONCAT() function as shown in the below syntax.
SELECT CONCAT(yourColumnName1,’anyConcatenationString’),CONCAT(yourColumnName2,’anyC
   oncatenationString’),....N from yourTableName;
To understand the above syntax, let us first create a table. The query to create a table is as follows.
mysql> create table selectConcat
-> (
-> StudentId int,
-> StudentName varchar(100),
-> StudentAge int
-> );
Query OK, 0 rows affected (1.32 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into selectConcat values(1,'Carol',23);
Query OK, 1 row affected (0.19 sec)

mysql> insert into selectConcat values(2,'John',24);
Query OK, 1 row affected (0.25 sec)

mysql> insert into selectConcat values(3,'Adam',25);
Query OK, 1 row affected (0.14 sec)

mysql> insert into selectConcat values(4,'Bob',21);
Query OK, 1 row affected (0.20 sec)

mysql> insert into selectConcat values(5,'Sam',22);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from selectConcat;
The following is the output.
+-----------+-------------+------------+
| StudentId | StudentName | StudentAge |
+-----------+-------------+------------+
| 1         | Carol       | 23         |
| 2         | John        | 24         |
| 3         | Adam        | 25         |
| 4         | Bob         | 21         |
| 5         | Sam         | 22         |
+-----------+-------------+------------+
5 rows in set (0.00 sec)
Contact the field in select statement. The query is as follows.
mysql> select concat(StudentId,' as an Id'),concat(StudentName,' as a Name') from selectConcat;
The following is the output.
+-------------------------------+----------------------------------+
| concat(StudentId,' as an Id') | concat(StudentName,' as a Name') |
+-------------------------------+----------------------------------+
| 1 as an Id                    | Carol as a Name                  |
| 2 as an Id                    | John as a Name                   |
| 3 as an Id                    | Adam as a Name                   |
| 4 as an Id                    | Bob as a Name                    |
| 5 as an Id                    | Sam as a Name                    |
+-------------------------------+----------------------------------+
5 rows in set (0.00 sec)
How to call a stored procedure using select statement in MySQL?

In MySQL, it is not possible to use select from procedure in FROM clause. You can use CALL command and after that the SELECT statement can be executed.
Let us first create a table:
mysql> create table DemoTable2
   -> (
   -> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> CustomerName varchar(100),
   -> ShippingDateTime datetime
   -> );
Query OK, 0 rows affected (0.66 sec)
Following is the query to create stored procedure:
mysql> DELIMITER //
mysql> CREATE PROCEDURE insert_information(Name varchar(100),shippingtime datetime)
   -> BEGIN
   ->
   -> INSERT INTO DemoTable2(CustomerName,ShippingDateTime) VALUES(Name,shippingtime);
   -> END
   -> //
Query OK, 0 rows affected (0.16 sec)

mysql> DELIMITER ;
Now you can call the stored procedure using call command:
mysql> call insert_information('Chris',NOW());
Query OK, 1 row affected, 1 warning (0.15 sec)
Here is the query to display records from the table using select statement after calling stored procedure.
mysql> select *from DemoTable2;
This will produce the following output
+------------+--------------+---------------------+
| CustomerId | CustomerName | ShippingDateTime    |
+------------+--------------+---------------------+
| 1          | Chris        | 2019-04-08 15:03:07 |
+------------+--------------+---------------------+
1 row in set (0.00 sec)
Angular 10 I18nPluralPipe API - GeeksforGeeks

04 Aug, 2021
In this article, we are going to see what is I18nPluralPipe in Angular 10 and how to use it. The I18nPluralPipe is a map that takes a string value that pluralizes according to given rules.
Syntax:
{{ value |  i18nPlural : map [ : rule]}}
NgModule: Module used by I18nPluralPipe is:
CommonModule
Approach: 
Create an angular app to be used.
There is no need for any import for the I18nPluralPipe to be used.
In app.component.ts define the variables that takes the I18nPluralPipe value.
In app.component.html use the above syntax with ‘|’ symbol to make I18nPluralPipe element.
Serve the angular app using ng serve to see the output.
 
Input value:
value: it takes a number value.
Parameters:
pluralMap: It takes an object value.
locale: It takes a string value.
Example 1:
app.component.ts
import { Component, OnInit } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})export class AppComponent {      // Color array    colors: any[] = ['red','green','blue'];      // Map from which I18nPluralPipe takes the value    gfg:        {[k: string]: string} = {            '=0': 'No color',             '=1': 'one color',              'other': '# colors'        };}
app.component.html
<!-- In Below Code I18nPluralPipe is used --><div>there are: {{ colors.length | i18nPlural: gfg }}</div>
Output:
Example 2:
app.component.ts
import { Component } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html'})export class AppComponent {      // Language array    language: any[] = [];      // Map from which I18nPluralPipe    // takes the value    gfg:        {[k: string]: string} = {            '=0': 'zero languages',             '=1': 'one language',            'other': '# languages'        };}
app.component.html
<!-- In Below Code I18nPluralPipe is used --><div>there are: {{ language.length | i18nPlural: gfg }}</div>
Output:
Reference: https://angular.io/api/common/I18nPluralPipe
bunnyram19
Angular10
AngularJS-API
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
Angular PrimeNG Dropdown Component
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to horizontal align text content into center in HTML ? - GeeksforGeeks

25 Dec, 2020
In this article, we will align the text content into center using HTML. We use align=”center” attribute to set the text content into center.
Syntax:
<element_name align="center"> Contents... <element_name>
The align=”center” attribute is used to set the text content into center.
Example 1:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to horizontal align text        content into center in HTML?    </title>      <style>        h1 {            color: green;        }    </style></head>  <body>    <h1 align="center">        GeeksforGeeks    </h1>      <h3 align="center">        How to horizontal align text        content into center in HTML?    </h3>      <p align="center">        GeeksforGeeks: A computer        science portal for geeks    </p>  </body>  </html>
Output:
Example 2: Use CSS text-align=”center” property to set the text content into center.
HTML
<!DOCTYPE html><html>  <head>    <title>        How to horizontal align text        content into center in HTML?    </title>      <style>        body {            text-align: center;        }          h1 {            color: green;        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>      <h3>        How to horizontal align text        content into center in HTML?    </h3>            <p>        GeeksforGeeks: A computer        science portal for geeks    </p>  </body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
HTML <textarea> cols Attribute

The cols attribute of the <textarea> element is used to set the width of the textarea. The cols set it and the width is visible under the textarea itself.
Following is the syntax −
<textarea cols="num">
Above, num is the width of the textarea. The default value is 20.
Let us now see an example to implement the cols attribute of the <textarea> element −
 Live Demo
<!DOCTYPE html>
<html>
<body>
<h2>Interview Questions</h2>
<p>Why do you want go for the Editor Job Profile? (100 words)</p>
   <textarea rows="6" cols="70">
      Write the answer in 100 words only...
   </textarea>
   <p>What are your weaknesses? (50 words)</p>
   <textarea rows="4" cols="70">
Write the answer in 50 words only...
</textarea>
</body>
</html>
In the above example, we have set two textarea −
<textarea rows="6" cols="70">
Write the answer in 100 words only...
</textarea>
<p>What are your weaknesses? (50 words)</p>
<textarea rows="4" cols="70">
Write the answer in 50 words only...
</textarea>
The width of the textarea is set with the cols attribute −
<textare arows="6" cols="70" autofocus>
How to select only numeric columns from an R data frame?

The easiest way to do it is by using select_if function of dplyr package but we can also do
it through lapply.
Using dplyr
> df <- data.frame(X1=1:10,X2=11:20,X3=21:30,X4=letters[1:10], X5=letters[11:20])
> df
X1 X2 X3 X4 X5
1 1 11 21 a k
2 2 12 22 b l
3 3 13 23 c m
4 4 14 24 d n
5 5 15 25 e o
6 6 16 26 f p
7 7 17 27 g q
8 8 18 28 h r
9 9 19 29 i s
10 10 20 30 j t
>library("dplyr")
> select_if(df, is.numeric)
X1 X2 X3
1 1 11 21
2 2 12 22
3 3 13 23
4 4 14 24
5 5 15 25
6 6 16 26
7 7 17 27
8 8 18 28
9 9 19 29
10 10 20 30
Using lapply
> numeric_only <- unlist(lapply(df, is.numeric))
> df[ , numeric_only]
  X1 X2 X3
1 1 11 21
2 2 12 22
3 3 13 23
4 4 14 24
5 5 15 25
6 6 16 26
7 7 17 27
8 8 18 28
9 9 19 29
10 10 20 30
XML - Processing

This chapter describes the Processing Instructions (PIs). As defined by the XML 1.0 Recommendation,
Processing instructions (PIs) can be used to pass information to applications. PIs can appear anywhere in the document outside the markup. They can appear in the prolog, including the document type definition (DTD), in textual content, or after the document.
Following is the syntax of PI −
<?target instructions?>

Where
target − Identifies the application to which the instruction is directed.
target − Identifies the application to which the instruction is directed.
instruction − A character that describes the information for the application to process.
instruction − A character that describes the information for the application to process.
A PI starts with a special tag <? and ends with  ?>. Processing of the contents ends immediately after the string ?> is encountered.
PIs are rarely used. They are mostly used to link XML document to a style sheet. Following is an example −
<?xml-stylesheet href = "tutorialspointstyle.css" type = "text/css"?>

Here, the target is xml-stylesheet. href="tutorialspointstyle.css" and type="text/css" are data or instructions the target application will use at the time of processing the given XML document.
In this case, a browser recognizes the target by indicating that the XML should be transformed before being shown; the first attribute states that the type of the transform is XSL and the second attribute points to its location.
A PI can contain any data except the combination ?>, which is interpreted as the closing delimiter. Here are two examples of valid PIs −
<?welcome to pg = 10 of tutorials point?>

<?welcome?>

    84 Lectures 
     6 hours 

 Frahaan Hussain

    29 Lectures 
     2 hours 

 YouAccel

    27 Lectures 
     1 hours 

 Jordan Stanchev

    16 Lectures 
     2 hours 

 Simon Sez IT
 Print
 Add Notes
 Bookmark this page
HTM5 checkValidity() method

The HTML5 checkValidity() works in Google Chrome and Opera as well. This works as well:
<!DOCTYPE html>
<html>
   <body>
      <style>
         .valid { color: #0B7866; }
         .invalid { color: #0B6877; }
      </style>
      <div id="result"></div>
      <script>
         function check(input) {
            var out = document.getElementById('result');
           
            if (input.validity) {
               if (input.validity.valid === true) {
                  out.innerHTML = "<span class='valid'>" + input.id + " valid</span>";
               } else {
                  out.innerHTML = "<span class='invalid'>" + input.id + " not valid</span>";
               }
            }
           console.log(input.checkValidity());
         };
      </script>
      <form id="testform" onsubmit="return false;">
         <label>Minimum:
            <input oninput="check(this)" id="min_input" type=number min=4 />
         </label><br>
      </form>
   </body>
</html>
How to read a 2d array from a file in java?

A 2d array is an array of one dimensional arrays to read the contents of a file to a 2d array –
Instantiate Scanner or other relevant class to read data from a file.
 Create an array to store the contents.
To copy contents, you need two loops one nested within the other. the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.
Create an outer loop starting from 0 up to the length of the array. Within this loop read each line trim and split it using nextLine(), trim(), and split() methods respectively.
Create the second loop starting from 0 up to the length of the line. Within this loop convert each element of the string array to integer and assign to the array created in the previous step.
import java.io.BufferedReader;
import java.io.FileReader;

import java.util.Arrays;
import java.util.Scanner;

public class Reading2DArrayFromFile {
   public static void main(String args[]) throws Exception {
      Scanner sc = new Scanner(new BufferedReader(new FileReader("sample.txt")));
      int rows = 4;
      int columns = 4;
      int [][] myArray = new int[rows][columns];
      while(sc.hasNextLine()) {
         for (int i=0; i<myArray.length; i++) {
            String[] line = sc.nextLine().trim().split(" ");
            for (int j=0; j<line.length; j++) {
               myArray[i][j] = Integer.parseInt(line[j]);
            }
         }
      }
      System.out.println(Arrays.deepToString(myArray));
   }
}
[[2, 2, 2, 2], [6, 6, 6, 6], [2, 2, 2, 2], [4, 4, 4, 4]]
AtomicLong set() method in Java with examples - GeeksforGeeks

29 Jan, 2019
The Java.util.concurrent.atomic.AtomicLong.set() is an inbuilt method in java that updates the previous value and sets it to a new value which is passed in the parameter.
Syntax:
public final void set(long newVal)

Parameters: The function accepts a single mandatory parameter newVal which is to be updated.
Return value: The function does not returns anything.
Below programs illustrate the above method:
Program 1:
// Java program that demonstrates// the set() function  import java.util.concurrent.atomic.AtomicLong;  public class GFG {    public static void main(String args[])    {          // Initially value as 0        AtomicLong val = new AtomicLong(0);          System.out.println("Previous value: "                           + val);          val.set(10);          // Prints the updated value        System.out.println("Current value: "                           + val);    }}
Previous value: 0
Current value: 10

Program 2:
// Java program that demonstrates// the set() function  import java.util.concurrent.atomic.AtomicLong;  public class GFG {    public static void main(String args[])    {          // Initially value as 18        AtomicLong val = new AtomicLong(18);          System.out.println("Previous value: "                           + val);          val.set(200);          // Prints the updated value        System.out.println("Current value: "                           + val);    }}
Previous value: 18
Current value: 200

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html#set–
Java - util package
Java-AtomicLong
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Interfaces in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Singleton Class in Java
Stream In Java
Set in Java
Overriding in Java
LinkedList in Java
Find longest length number in a string in C++

In this problem, we are given a string str consisting of character and alphabets only. Our task is to find the longest length number in a string. 
Problem Description: we need to find the length of the number i.e. consecutive numerical characters in the string.
Let’s take an example to understand the problem, 
Input: str = “code001tutorials34124point”
Output: 34124
Explanation:  
Numbers in the string are
001 - size 3
34124 - size 5
A simple solution to the problem is by traversing the sting and finding the number’s length and its starting index. We will store the starting position and count of characters in the string for each number in the string. And at the end, return the number.
Live Demo
#include <iostream>
using namespace std;

string findLongestNumber(string str, int l) {
   
   int count = 0, max = 0, maxLenPos = -1, currPos, currLen, maxLen = 0;

   for (int i = 0; i < l; i++) {
      currPos = maxLenPos;
      currLen = maxLen;
      count = 0;
      maxLen = 0;
      if (isdigit(str[i]))
         maxLenPos = i;
      while (isdigit(str[i])) {
         count++;
         i++;
         maxLen++;
      }
      if (count > max) {
         max = count;
      }
      else {
         maxLenPos = currPos;
         maxLen = currLen;
      }
   }
   return (str.substr(maxLenPos, maxLen));
}

int main() {
   
   string str = "code001tutorials34124point";
   int l = str.length();
   cout<<"The longest length number in string is "<<findLongestNumber(str, l);
   return 0;
}
The longest length number in string is 34124