code-rag-bench/online-tutorials huggingface dataset:
C# program to print all the common elements of two lists

Firstly create the two lists −
List list1 = new List() {40, 20, 60, 3, 55};
List list2 = new List() {20, 70, 55, 80};
To find the common elements, use the Intersect −
list1.Intersect(list2)
The following is the complete code to find the common elements between the two lists −
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         List list1 = new List() {40, 20, 60, 3, 55};
         List list2 = new List() {20, 70, 55, 80};
         Console.WriteLine("Common elements:");
         foreach(int value in list1.Intersect(list2))
         Console.WriteLine(value);
      }
   }
}
Common elements:
20
55
How to arrange data in s specific order in MySQL?

Use ORDER BY IF() to arrange data in a specific order. Following is the syntax −
select *from yourTableName ORDER BY IF(yourColumnName=yourValue1 OR
yourColumnName=yourValue2 OR yourColumnName=yourValue3,yourColumnName,
~yourColumnName) ASC;
Let us first create a table −
mysql> create table arrangeDataInSpecificOrder
   -> (
   -> StudentId int,
   -> StudentName varchar(20)
   -> );
Query OK, 0 rows affected (0.64 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into arrangeDataInSpecificOrder values(10,'Larry');
Query OK, 1 row affected (0.12 sec)
mysql> insert into arrangeDataInSpecificOrder values(15,'Mike');
Query OK, 1 row affected (0.09 sec)
mysql> insert into arrangeDataInSpecificOrder values(100,'Sam');
Query OK, 1 row affected (0.16 sec)
mysql> insert into arrangeDataInSpecificOrder values(70,'Carol');
Query OK, 1 row affected (0.12 sec)
mysql> insert into arrangeDataInSpecificOrder values(90,'Bob');
Query OK, 1 row affected (0.14 sec)
mysql> insert into arrangeDataInSpecificOrder values(300,'David');
Query OK, 1 row affected (0.12 sec)
Following is the query to display all records from the table using select statement −
mysql> select * from arrangeDataInSpecificOrder;
This will produce the following output −
+-----------+-------------+
| StudentId | StudentName |
+-----------+-------------+
| 10        | Larry       |
| 15        | Mike        |
| 100       | Sam         |
| 70        | Carol       |
| 90        | Bob         |
| 300       | David       |
+-----------+-------------+
6 rows in set (0.00 sec)
Here is the query to arrange data in specific order −
mysql> select * from arrangeDataInSpecificOrder ORDER BY IF(StudentId=300 OR
StudentId=100 OR StudentId=10,StudentId, ~StudentId) ASC;
This will produce the following output −
+-----------+-------------+
| StudentId | StudentName |
+-----------+-------------+
| 10        | Larry       |
| 100       | Sam         |
| 300       | David       | 
| 90        | Bob         |
| 70        | Carol       |
| 15        | Mike        |
+-----------+-------------+
6 rows in set (0.00 sec)
MySQL If statement with multiple conditions?

You can use if statement in a stored procedure with multiple conditions with the help of AND or OR operator. The syntax is as follows −
DECLARE X int;
DECLARE Y int;
SET X = value1;
SET Y = value2;
IF ( (X < Y AND X > value1 AND Y >value2) OR X! = anyValueToCompare) THEN
   yourStatement;
ELSE
   yourStatement;
END IF
Now to understand the above syntax, let us create a stored procedure. The query to create a stored procedure is as follows −
mysql> create procedure SP_IFELSEDEMO()
   -> BEGIN
   -> DECLARE X int;
   -> DECLARE Y int;
   -> SET X=100;
   -> SET Y=400;
   -> IF ( (X < Y AND X > 99 AND Y >300) OR X! = 10 ) THEN
   ->    SELECT 'Logic is Correct';
   -> ELSE
   ->    SELECT 'Logic is not Correct';
   -> END IF;
   -> END;
   -> //
Query OK, 0 rows affected (0.27 sec)
mysql> DELIMITER ;
Now call the stored procedure with the help of the CALL command. The query is as follows −
mysql> call SP_IF ELSEDEMO();
+------------------+
| Logic is Correct |
+------------------+
| Logic is Correct |
+------------------+
1 row in set (0.04 sec)
Query OK, 0 rows affected (0.07 sec)
How to load data from a pickle file in S3 using Python | by Natalie Olivo | Towards Data Science

I don’t know about you but I love diving into my data as efficiently as possible. Pulling different file formats from S3 is something I have to look up each time, so here I show how I load data from pickle files stored in S3 to my local Jupyter Notebook.
Never hard code your credentials! And if you do, make sure to never upload that code to a repository, especially Github. There are web crawlers looking for accidentally uploaded keys and your AWS account WILL be compromised. Instead, use boto3.Session().get_credentials()
In older versions of python (before Python 3), you will use a package called cPickle rather than pickle, as verified by this StackOverflow.
Viola! And from there, data should be a pandas DataFrame.
Something I found helpful was eliminating whitespace from fields and column names in the DataFrame. I’m not sure if this is a pickle file thing, or specific to my data. If this problem affects you, here’s what I used:
To eliminate whitespace in column names:
col_list = []for col in list(data.columns):    col_list.append(col.strip())data.columns = col_list
To eliminate whitespace in data:
data = data.applymap(lambda x: x.strip() if type(x)==str else x)
Document.title() use in JavaScript?

The title property sets or returns the value of the title attribute of an element, nothing but providing extra information regarding the element. This is mostly used as a tooltip, which displays the text on mouse hovering. Javascript has provided document.title() to get the title.
document.title();
In the following example, an abbr attribute is used inside a 'p' tag and the respective title abbreviation is found out using the method document.title(). Later on, the result is displayed in the output.
<html>
<body>
<p><abbr id="Abbr" title="Abraham lincoln"></abbr>A-l is one of the best presidents of America </p>
<p id="title"></p>
<script>
   var x = document.getElementById("Abbr").title;
   document.getElementById("title").innerHTML = x;
</script>
</body>
</html>
A-l is one of the best presidents of America

Abraham lincoln
\neq - Tex Command

\neq - Used to create neq symbol.
{ \neq}
\neq command draws neq symbol.

\neq

≠



\neq

≠


\neq

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Difference between "int main()" and "int main(void)" in C/C++? - GeeksforGeeks

07 Sep, 2018
Consider the following two definitions of main().
int main(){   /*  */   return 0;}
and
int main(void){   /*  */   return 0;}
What is the difference?
In C++, there is no difference, both are same.
Both definitions work in C also, but the second definition with void is considered technically better as it clearly specifies that main can only be called without any parameter.In C, if a function signature doesn’t specify any argument, it means that the function can be called with any number of parameters or without any parameters. For example, try to compile and run following two C programs (remember to save your files as .c). Note the difference between two signatures of fun().
// Program 1 (Compiles and runs fine in C, but not in C++)void fun() {  } int main(void){    fun(10, "GfG", "GQ");    return 0;}
The above program compiles and runs fine (See this), but the following program fails in compilation (see this)
// Program 2 (Fails in compilation in both C and C++)void fun(void) {  }int main(void){    fun(10, "GfG", "GQ");    return 0;}
Unlike C, in C++, both of the above programs fails in compilation. In C++, both fun() and fun(void) are same.
So the difference is, in C, int main() can be called with any number of arguments, but int main(void) can only be called without any argument. Although it doesn’t make any difference most of the times, using “int main(void)” is a recommended practice in C.
Exercise:Predict the output of following C programs.
Question 1
#include <stdio.h>int main(){    static int i = 5;    if (--i){        printf("%d ", i);        main(10);    }}
Question 2
#include <stdio.h>int main(void){    static int i = 5;    if (--i){        printf("%d ", i);        main(10);    }}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C Basics
CPP-Functions
cpp-main
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
fork() in C
Command line arguments in C/C++
Substring in C++
Function Pointer in C
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Map in C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
C++ | Function Overloading and Default Arguments | Question 2 - GeeksforGeeks

28 Jun, 2021
Output?
#include<iostream>using namespace std;  int fun(int x = 0, int y = 0, int z){  return (x + y + z); }  int main(){   cout << fun(10);   return 0;}
(A) 10(B) 0(C) 20(D) Compiler ErrorAnswer: (D)Explanation: All default arguments must be the rightmost arguments. The following program works fine and produces 10 as output.
#include <iostream>
using namespace std;

int fun(int x, int y = 0, int z = 0)
{  return (x + y + z); }

int main()
{
   cout << fun(10);
   return 0;
}

Quiz of this Question
C++-Function Overloading and Default Arguments
Function Overloading and Default Arguments
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Command line arguments in C/C++
Substring in C++
C++ | Exception Handling | Question 3
C++ | const keyword | Question 2
C++ | Operator Overloading | Question 5
C++ | new and delete | Question 4
C++ | Inheritance | Question 7
SQL Tryit Editor v1.6

SELECT CustomerName, /*City,*/ Country FROM Customers;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
C program to replace all zeros with one in a given integer.

Write a program to replace all zeros (0's) with 1 in a given integer.
Given an integer as an input, all the 0's in the number has to be replaced with 1.
Consider an example given below −
Here, the input is 102410 and the output is 112411.
Refer an algorithm given below to replace all the 0’s to 1 in an integer.
Step 1 − Input the integer from the user.
Step 2 − Traverse the integer digit by digit.
Step 3 − If a '0' is encountered, replace it by '1'.
Step 4 − Print the integer.
Given below is the C program to replace all 0's with 1 in a given integer −
 Live Demo
#include<stdio.h>
int replace(long int number){
   if (number == 0)
   return 0;
   //check last digit and change it if needed
   int digit = number % 10;
   if (digit == 0)
   digit = 1;
   // Convert remaining digits and append to its last digit
   return replace(number/10) * 10 + digit;
}
int Convert(long int number){
   if (number == 0)
      return 1;
   else
      return replace(number);
}
int main(){
   long int number;
   printf("\nEnter any number : ");
   scanf("%d", &number);
   printf("\nAfter replacement the number is : %dn", Convert(number));
   return 0;
}
When the above program is executed, it produces the following output −
Enter any number: 1056110010
After replacement the number is: 1156111111
Haskell - Basic Operators

In this chapter, we will learn about different operators used in Haskell. Like other programming languages, Haskell intelligently handles some basic operations like addition, subtraction, multiplication, etc. In the upcoming chapters, we will learn more about different operators and their use.
In this chapter, we will use different operators in Haskell using our online platform (https://www.tutorialspoint.com/codingground.htm). Remember we are using only integer type numbers because we will learn more about decimal type numbers in the subsequent chapters.
As the name suggests, the addition (+) operator is used for addition function.  The following sample code shows how you can add two integer numbers in Haskell −
main = do 
   let var1 = 2 
   let var2 = 3 
   putStrLn "The addition of the two numbers is:" 
   print(var1 + var2) 
In the above file, we have created two separate variables var1 and var2. At the end, we are printing the result using the addition operator. Use the compile and execute button to run your code.
This code will produce the following output on screen −
The addition of the two numbers is:
5

As the name suggests, this operator is used for subtraction operation. The following sample code shows how you can subtract two integer numbers in Haskell −
main = do 
   let var1 = 10 
   let var2 = 6 
   putStrLn "The Subtraction of the two numbers is:" 
   print(var1 - var2)
In this example, we have created two variables var1 and var2. Thereafter, we use the subtraction (−) operator to subtract the two values.
This code will produce the following output on screen −
The Subtraction of the two numbers is:
4

This operator is used for multiplication operations. The following code shows how to multiply two numbers in Haskell using the Multiplication Operator −
main = do 
   let var1 = 2 
   let var2 = 3 
   putStrLn "The Multiplication of the Two Numbers is:" 
   print(var1 * var2) 
This code will produce the following output, when you run it in our online platform −
The Multiplication of the Two Numbers is:
6 

Take a look at the following code. It shows how you can divide two numbers in Haskell −
main = do 
   let var1 = 12 
   let var2 = 3 
   putStrLn "The Division of the Two Numbers is:" 
   print(var1/var2)
It will produce the following output −
The Division of the Two Numbers is: 
4.0 

Sequence or Range is a special operator in Haskell. It is denoted by "(..)". You can use this operator while declaring a list with a sequence of values.
If you want to print all the values from 1 to 10, then you can use something like "[1..10]". Similarly, if you want to generate all the alphabets from "a" to "z", then you can just type "[a..z]".
The following code shows how you can use the Sequence operator to print all the values from 1 to 10 −
main :: IO() 
main = do 
   print [1..10]
It will generate the following output −
[1,2,3,4,5,6,7,8,9,10] 

 Print
 Add Notes
 Bookmark this page
Arduino - while loop

while loops will loop continuously, and infinitely, until the expression inside the parenthesis, () becomes false. Something must change the tested variable, or the while loop will never exit.
while(expression) {
   Block of statements;
}


    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
SQL WHERE Clause

The WHERE clause is used to filter records.
It is used to extract only those records that fulfill a specified 
condition.
Note: The WHERE clause is not only used in 
SELECT statements, it is also used in UPDATE,
DELETE, etc.!
Below is a selection from the "Customers" table in the Northwind sample database:
The following SQL statement selects all the customers from the country 
"Mexico", in the "Customers" table:
SQL requires single quotes around text values (most database systems will 
also allow double quotes).
However, numeric fields should not be enclosed in quotes:
The following operators can be used in the WHERE clause:
Select all records where the City column has the value "Berlin".
SELECT * FROM Customers
  = ;

Start the Exercise
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.
How to Compile a Lua Executable?

While there are different ways with which a person can compile a Lua executable, some of them require more time and resources.
The most basic approach is to set the Lua Path environment variable and then simply run the lua command. While this might seem to be not much of a pain, setting the Lua Path definitely requires some work.
Instead of setting the Lua path, we can simply make use of the env and lua combination which will allow us to convert a Lua file into an executable or run a Lua script.
The command shown below does the same −
#!/USR/BIN/ENV LUA
In the above command there are different keywords that we can understand individually, let’s do that.
The #! line at the beginning of a script needs an absolute path of the program to run this script.
env is a program that runs another program in the path if executed as "env program", and its absolute path is (or should be) /usr/bin/env.
So, put these two facts together as you will often do, and there you have #!
/usr/bin/env lua
It should be noted that we need to have Lua installed on the machine where we are intending to make use of the above command.
How to create a column in an R data frame with cumulative sum?

The cumulative sum is used to determine the total sum of a variable or group and helps us to understand the changes in the values of that variable or group over time. While creating the cumulative, we must be sure that the total sum and the cumulative sum of the last value (depending on the direction of sum) are same. We can use mutate function of dplyr package to find the cumulative and create a column for it.
Consider the below data frame −
x1 <-1:20
grp <-rep(LETTERS[1:4],each=5)
df <-data.frame(x1,grp)
df
x1 grp
1 1 A
2 2 A
3 3 A
4 4 A
5 5 A
6 6 B
7 7 B
8 8 B
9 9 B
10 10 B
11 11 C
12 12 C
13 13 C
14 14 C
15 15 C
16 16 D
17 17 D
18 18 D
19 19 D
20 20 D
Creating a column cumusum with cumulative sum of values in x1 per grp −
df%>%group_by(grp)%>%mutate(cumusum=cumsum(x1))
# A tibble: 20 x 3
# Groups: grp [4]
x1 grp cumusum
<int> <fct> <int>
1 1 A 1
2 2 A 3
3 3 A 6
4 4 A 10
5 5 A 15
6 6 B 6
7 7 B 13
8 8 B 21
9 9 B 30
10 10 B 40
11 11 C 11
12 12 C 23
13 13 C 36
14 14 C 50
15 15 C 65
16 16 D 16
17 17 D 33
18 18 D 51
19 19 D 70
20 20 D 90
Lets’ have a look at another example −
set.seed(1)
Class <-rep(c("C1","C2","C3","C4","C5"),each=4)
Frequency <-sample(1:100,20)
data <-data.frame(Class,Frequency)
data
Class Frequency
1 C1 68
2 C1 39
3 C1 1
4 C1 34
5 C2 87
6 C2 43
7 C2 14
8 C2 82
9 C3 59
10 C3 51
11 C3 85
12 C3 21
13 C4 54
14 C4 74
15 C4 7
16 C4 73
17 C5 79
18 C5 37
19 C5 83
20 C5 97
Creating a column cumusum with cumulative sum of values in Frequency per Class −
data%>%group_by(Class)%>%mutate(cumusum=cumsum(Frequency))
# A tibble: 20 x 3
# Groups: Class [5]
Class Frequency cumusum
<fct> <int> <int>
1 C1 68 68
2 C1 39 107
3 C1 1 108
4 C1 34 142
5 C2 87 87
6 C2 43 130
7 C2 14 144
8 C2 82 226
9 C3 59 59
10 C3 51 110
11 C3 85 195
12 C3 21 216
13 C4 54 54
14 C4 74 128
15 C4 7 135
16 C4 73 208
17 C5 79 79
18 C5 37 116
19 C5 83 199
20 C5 97 296
How to extract the split string elements in R?

To split string vector elements, we can use strsplit function. And if we want to extract the string elements after splitting then double and single square brackets will be used. The double square bracket will extract the string vector element and the single square will extract the element after splitting. Check out the examples to understand how it works.
Live Demo
> x1<-c("Tutorialspoint is an E-learning platform","E-learning is important","It helps in learning and growing at a faster rate")
> x1
[1] "Tutorialspoint is an E-learning platform"
[2] "E-learning is important"
[3] "It helps in learning and growing at a faster rate"
> x1<-strsplit(x1," ")
> x1
[[1]]
[1] "Tutorialspoint" "is" "an" "E-learning"
[5] "platform"

[[2]]
[1] "E-learning" "is" "important"

[[3]]
[1] "It" "helps" "in" "learning" "and" "growing"
[7] "at" "a" "faster" "rate"
> x1[[1]][1]
[1] "Tutorialspoint"
> x1[[1]][4]
[1] "E-learning"
> x1[[2]][1]
[1] "E-learning"
> x1[[3]][1]
[1] "It"
> x1[[3]][4]
[1] "learning"
> x1[[3]][8]
[1] "a"
Live Demo
> x2<-c("The purpose of our lives is to be happy","Difficult roads often lead to beautiful destinations","Sometimes the heart sees what is invisible to the eye","Life is beautiful","God is the greatest","Don't let yesterday take up too much today","Clarity is very important","Satisfaction defines the success","My life is my message","The best is yet to come","Life is a journey not a race","Life is short and the world is wide","Time is free but it's priceless","Your dream does not have an expiration date")
> x2
[1] "The purpose of our lives is to be happy"
[2] "Difficult roads often lead to beautiful destinations"
[3] "Sometimes the heart sees what is invisible to the eye"
[4] "Life is beautiful"
[5] "God is the greatest"
[6] "Don't let yesterday take up too much today"
[7] "Clarity is very important"
[8] "Satisfaction defines the success"
[9] "My life is my message"
[10] "The best is yet to come"
[11] "Life is a journey not a race"
[12] "Life is short and the world is wide"
[13] "Time is free but it's priceless"
[14] "Your dream does not have an expiration date"
> x2<-strsplit(x2," ")
> x2
[[1]]
[1] "The" "purpose" "of" "our" "lives" "is" "to"
[8] "be" "happy"

[[2]]
[1] "Difficult" "roads" "often" "lead" "to"
[6] "beautiful" "destinations"

[[3]]
[1] "Sometimes" "the" "heart" "sees" "what" "is"
[7] "invisible" "to" "the" "eye"

[[4]]
[1] "Life" "is" "beautiful"

[[5]]
[1] "God" "is" "the" "greatest"

[[6]]
[1] "Don't" "let" "yesterday" "take" "up" "too"
[7] "much" "today"

[[7]]
[1] "Clarity" "is" "very" "important"

[[8]]
[1] "Satisfaction" "defines" "the" "success"

[[9]]
[1] "My" "life" "is" "my" "message"

[[10]]
[1] "The" "best" "is" "yet" "to" "come"

[[11]]
[1] "Life" "is" "a" "journey" "not" "a" "race"

[[12]]
[1] "Life" "is" "short" "and" "the" "world" "is" "wide"

[[13]]
[1] "Time" "is" "free" "but" "it's" "priceless"

[[14]]
[1] "Your" "dream" "does" "not" "have"
[6] "an" "expiration" "date"
> x2[[1]][1]
> x2[[1]][2]
> x2[[3]][1]
> x2[[10]][2]
> x2[[12]][1]
> x2[[10]][1]
> x2[[14]][2]
[1] "The"
[1] "purpose"
[1] "Sometimes"
[1] "best"
[1] "Life"
[1] "The"
[1] "dream"
Instruction type ADC R in 8085 Microprocessor

In 8085 assembly language coding, sometimes there is a requirement to add two numbers and where each of these numbers are having several Bytes in size. As example, let us add the following two 16-bit numbers.
    1
   10 50H
   A0 F1H
   ------
   B1 01H

In this example, the addition of 50H and F1H results in a sum of 01H with a carry of 1. Now, we are supposed to add 10H and A0H along with this carry of 1. To carry out such a calculation, 8085 supports us with suitable instructions to add two numbers along with carry value.
Here, ADC is a mnemonic that stands for ‘ADd with Carry’ and ‘R’ stands for any of the following registers, or memory location M pointed by HL pair.This instruction is mainly used to add contents of R register and Accumulator along with the carry value. Here the carry can be either 0 or 1. The result of this addition operation will be stored in the Accumulator itself overwriting its previous content. This is 1-Byte instruction so also occupies 1-Byte in the memory. So this R can have 8 possible values and thus 8 possible opcodes.
R = A, B, C, D, E, H, L, or M

Let us consider ADC E as a sample instruction falling in this category. As mentioned, it is a 1-Byte instruction. Let us consider E register and Accumulator are initial having values 10H and A0H with initial Carry=1. Now if we execute the instruction ADC E, then the result B1H will remain stored on the Accumulator. The result of execution of this instruction is shown below with tracing table.
(E)
(A)
(F)
Here is the timing diagram for the instruction ADC E as shown below
Summary − So this instruction ADC requires 1-Byte, 1 Machine Cycles (Opcode Fetch) and 4 T-States for execution as shown in the timing diagram.
Gaussian filtering an image with NaN in Python Matplotlib

Gaussian filtering an image with NaN values makes all the values of a matrix NaN, which produces an NaN valued matrix.
Create a figure and a set of subplots.
Create a matrix with NaN value in that matrix.
Display the data as an image, i.e., on a 2D regular raster, data.
Apply Gaussian filter on the data.
Display the data as an image, i.e., on a 2D regular raster, gaussian_filter_data.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
from scipy.ndimage import gaussian_filter
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, axes = plt.subplots(2)
data = np.array([[1., 1.2, 0.89, np.nan],
   [1.2, np.nan, 1.89, 2.09],
   [.78, .67, np.nan, 1.78],
   [np.nan, 1.56, 1.89, 2.78]])
axes[0].imshow(data, cmap="cubehelix_r")
gaussian_filter_data = gaussian_filter(data, sigma=1)
axes[1].imshow(gaussian_filter_data, cmap="cubehelix_r")
plt.show()
How do I identify if a string is a number in C#?

Let us say our string is −
string str = "3456";
Now, to check whether the entered string is a number or not −
str.All(c => char.IsDigit(c))
The above returns true if the string is a number, else false.
Here is the complete code −
 Live Demo
using System;
using System.Linq;

namespace Demo {
   public class MyApplication {
      public static void Main(string[] args) {
         string str = "3456";
         // checking if string is a number or not
         Console.WriteLine(str.All(c => char.IsDigit(c)));
      }
   }
}
True
C# program to print unique values from a list

Set the list.
List < int > list = new List < int > ();
list.Add(99);
list.Add(49);
list.Add(32);
To get unique elements.
List<int> myList = list.Distinct().ToList();
Here is the complete example to display unique values from a list.
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;

public class Demo {
   public static void Main() {
      List < int > list = new List < int > ();
      list.Add(55);
      list.Add(45);
      list.Add(55);
      list.Add(65);
      list.Add(73);
      list.Add(24);
      list.Add(65);

      Console.WriteLine("Initial List...");
      foreach(int a in list) {
         Console.WriteLine("{0}", a);
      }

      List < int > myList = list.Distinct().ToList();
      Console.WriteLine("Unique elements...");
      foreach(int a in myList) {
         Console.WriteLine("{0}", a);
      }
   }
}
Initial List...
55
45
55
65
73
24
65
Unique elements...
55
45
65
73
24
How to change the background image using jQuery ?

03 Aug, 2021
To change the background image using jQuery, you can use the jQuery CSS() method. For this, the whole property value is specified using the url() functional notation.
Approach: Suppose we have an image URL stored in a variable and then use css() method to change the value of background image.
Below example illustrates the above approach:
Example:
   <!DOCTYPE html><html lang="en">  <head>    <title>    jQuery Changing background-image CSS Property    </title>    <style>        .box {            width: 700px;            height: 220px;            border: 2px solid black;            background-repeat: no-repeat;            background-image: url("https://www.geeksforgeeks.org/wp-content/uploads/javascript-768x256.png");        }        h1{            color:green;        }    </style>    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>    <script>        $(document).ready(function() {            // Change background image of a div by clicking on the button            $("button").click(function() {                var imageUrl = "https://www.geeksforgeeks.org/wp-content/uploads/jquery-banner-768x256.png";                $(".box").css("background-image", "url(" + imageUrl + ")");            });        });    </script></head>  <body>    <center>    <h1>GeeksforGeeks</h1>    <h3>    jQuery Changing background-image CSS Property    </h3>    <div class="box"></div>    <p>        <button type="button">            Change Background Image        </button>    </p>    </center></body>  </html>                    
Output:
Before Clicking on the button:
After Clicking on the button:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
nidhi_biet
jQuery-Misc
Picked
JQuery
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.assign() Method

13 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.assign() method is used to assign the enumerable string keyed properties of the given source objects to the destination objects. The source objects are applied from left to right and any subsequent sources overwrite the property assignments of the previous sources.
Syntax:
_.assign( dest_object, src_obj )

Parameters: This method accepts two parameters as mentioned above and described below:
dest_object: This is the destination object.
src_obj: These are the source objects.
Return Value: This method returns an object.
Example 1:
Javascript
// Defining Lodash variable const _ = require('lodash');   // Using the ._assign() methodconsole.log(  _.assign({ a: 1, c: 3 }, { a: 0 }));
Output:
{ a: 0, c: 3 }

Example 2: 
Javascript
// Defining Lodash variable const _ = require('lodash');   // Using the ._assign() methodconsole.log(  _.assign({ a: 0 }, { a: 1, c: 3 }, { d: 4 }));
Output:
{ a: 1, c: 3, d: 4 }

JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Angular 4 - Module

Module in Angular refers to a place where you can group the components, directives, pipes, and services, which are related to the application.
In case you are developing a website, the header, footer, left, center and the right section become part of a module.
To define module, we can use the NgModule. When you create a new project using the Angular –cli command, the ngmodule is created in the app.module.ts file by default and it looks as follows −
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})

export class AppModule { }
The NgModule needs to be imported as follows −
import { NgModule } from '@angular/core';

The structure for the ngmodule is as shown below −
@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
It starts with @NgModule and contains an object which has declarations, import s, providers and bootstrap.
It is an array of components created. If any new component gets created, it will be imported first and the reference will be included in declarations as shown below −
declarations: [
   AppComponent,
   NewCmpComponent
]

It is an array of modules required to be used in the application. It can also be used by the components in the Declaration array. For example, right now in the @NgModule we see the Browser Module imported. In case your application needs forms, you can include the module as follows −
import { FormsModule } from '@angular/forms';

The import in the @NgModule will be like the following −
imports: [
   BrowserModule,
   FormsModule
]

This will include the services created.
This includes the main app component for starting the execution.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
a.sort, sorted(a), np_argsort(a) and np.lexsort(b, a) in Python

Ordering of data elements in a specific order is a frequently needed operation. To sort elements in an array, python uses the functions named sorted() and array.sort().
This function returns a sorted array without modifying the original array.
a = [9,5,3,1,12,6]
b = sorted([9,5,3,1,12,6])
print "Sorted Array :\n",
print (b)
print "Original Array :\n",
print (a)
Running the above code gives us the following result −
Sorted Array :
[1, 3, 5, 6, 9, 12]
Original Array :
[9, 5, 3, 1, 12, 6]
The sort function returns a sorted array by doing in-place modification to the array supplied. Hence the original array gets modified as shown in the example below.
a = [9,5,3,1,12,6]
print "Original Array :\n",
print (a)
print "Sorted Array :\n",
a.sort()
print (a)
Running the above code gives us the following result −
Original Array :
[9, 5, 3, 1, 12, 6]
Sorted Array :
[1, 3, 5, 6, 9, 12]
So sorted() function is slower than sort() as it creates a copy of the original array and then modifies it.
More complex sorting requirements are done using Numpy. Numpy is a python library which is extensively used in scientific data processing as it provides lots of advanced features. We will see both pure python sorting methods and Numpy sorting methods in the below examples.
This function in numpy returns the indices of the sorted array instead of the array elements. In the below example we take the array, print its elements along with the index for each element. Then we apply the argsort function which gives us the indices of sorted array as a result and the result is also an array.
import numpy as np
x = np.array([9,5,3,1,12,6])
print(x)

#Print the positions of elements
for i in range(len(x)):
print "[",i,"]",x[i],
print "\n"
# Print the indices of sorted elements
s = np.argsort(x)
print(s)
Running the above code gives us the following result −
[ 9 5 3 1 12 6]

[ 0 ] 9 [ 1 ] 5 [ 2 ] 3 [ 3 ] 1 [ 4 ] 12 [ 5 ] 6

[3 2 1 5 0 4]
This function is used for sorting using multiple sort keys involving more than one array. For example, we first sort data in Column A and then sort the values in column B. In the below example we take two arrays representing column A and column B. On applying lexsort() function for sorting first by column A and then by column B we get the result of sorting as an array containing the indices of the elements in column A.
import numpy as np
colA = [2,5,1,8,1] # First column
colB = [9,0,3,2,0] # Second column
# Sort by ColA and then by colB
sorted_index = np.lexsort((colB,colA))
print(sorted_index)
#print the result showing the
#column values as pairs
print [(colA[i],colB[i]) for i in sorted_index]
Running the above code gives us the following result −
[4 2 0 1 3]
[(1, 0), (1, 3), (2, 9), (5, 0), (8, 2)]
As you can see the lowest two values in colA are 1 and 1 at the index position 2 and 4. But the result shows 4 and 2 as the ascending order as the respective values in column B which are 0 and 3 are also sorted as first 0 then 3, making the result as 4 and 2.
Print level order traversal line by line in C++ Programming.

Given the binary tree, the function must find out the level order traversal of a tree line by line.
Level order traversal: Left Root Right, which means firstly print left child of a node than the value of a root and then go to the right child but here we have to do line by line which will start from left and will end at the right node of a given binary tree.
The binary tree given above will generate the following output −
Level 0: 3
Level 1: 2 1
Level 2: 10 20 30
START
Step 1 -> create a structure of a node as
   struct node
      struct node *left, *right
      int data
   End
Step 2 -> function to create a node
   node* newnode(int data)
   node *temp = new node
   temp->data = data
   temp->left = temp->right= NULL
   return temp
step 3 -> function for inorder traversal
   void levelorder(node *root)
   IF root = NULL
      Return
   End
   queue<node *> que
   que.push(root)
   Loop While que.empty() = false
      int count = que.size()
      Loop While count > 0
         node *node = que.front()
         print node->data
         que.pop()
      IF node->left != NULL
         que.push(node->left)
      End
      IF node->right != NULL
         que.push(node->right)
      End
      Decrement count by 1
   End
End
Step 4 -> In main() function
   Create tree using node *root = newnode(3)
   Call levelorder(root)
STOP
 Live Demo
#include <iostream>
#include <queue>
using namespace std;
//it will create a node structure
struct node{
   struct node *left;
   int data;
   struct node *right;
};
void levelorder(node *root){
   if (root == NULL)
      return;
   queue<node *> que;
   que.push(root);
   while (que.empty() == false){
      int count = que.size();
      while (count > 0){
         node *node = que.front();
         cout << node->data << " ";
         que.pop();
         if (node->left != NULL)
            que.push(node->left);
         if (node->right != NULL)
            que.push(node->right);
         count--;
      }
   }
}
//it will create a new node
node* newnode(int data){
   node *temp = new node;
   temp->data = data;
   temp->left = NULL;
   temp->right = NULL;
   return temp;
}
int main(){
   // it will generate the binary tree
   node *root = newnode(3);
   root->left = newnode(2);
   root->right = newnode(1);
   root->left->left = newnode(10);
   root->left->right = newnode(20);
   root->right->right = newnode(30);
   levelorder(root);
   return 0;
}
if we run the above program then it will generate the following output
3 2 1 10 20 30
Google Colab - Saving Your Work

Colab allows you to save your work to Google Drive or even directly to your GitHub repository.
Colab allows you to save your work to your Google Drive. To save your notebook, select the following menu options −
File / Save a copy in Drive...

You will see the following screen −
The action will create a copy of your notebook and save it to your drive. Later on you may rename the copy to your choice of name.
You may also save your work to your GitHub repository by selecting the following menu options −
File / Save a copy in GitHub...

The menu selection is shown in the following screenshot for your quick reference −
You will have to wait until you see the login screen to GitHub.
Now, enter your credentials. If you do not have a repository, create a new one and save your project as shown in the screenshot below −
In the next chapter, we will learn how to share your work with others.

    20 Lectures 
     2.5 hours 

 Asif Hussain

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    33 Lectures 
     2.5 hours 

 Sasha Miller

    22 Lectures 
     1.5 hours 

 Zach Miller

    16 Lectures 
     1.5 hours 

 Sasha Miller

    23 Lectures 
     2.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Python | Convert list of string into sorted list of integer - GeeksforGeeks

18 Feb, 2019
Given a list of string, write a Python program to convert it into sorted list of integer.
Examples:
Input: ['21', '1', '131', '12', '15']
Output: [1, 12, 15, 21, 131]

Input: ['11', '1', '58', '15', '0']
Output: [0, 1, 11, 15, 58]

 Let’s discuss different methods we can achieve this task.
Method #1: Using map and sorted()
# Python code to convert list of# string into sorted list of integer  # List initializationlist_string = ['21', '1', '131', '12', '15']  # mappinglist_map = map(int, list_string)  # sorting listlist_sorted = sorted(list_map)  # Printing sorted list of integersprint(list_sorted)
[1, 12, 15, 21, 131]

 Method #2: Using list comprehension
# Python code to convert list of # string into sorted list of integer  # List initializationlist_string = ['11', '1', '58', '15', '0']  # Using list comprehensionoutput = [int(x) for x in list_string]  # using sort functionoutput.sort()  # Printing outputprint(output)
[0, 1, 11, 15, 58]

 Method #3: Using iteration
# Python code to convert list of# string into sorted list of integer  # List initializationlist_string = ['11', '1', '58', '15', '0']  # using iteration and sorted()list_sorted = sorted(int(x) for x in list_string)  # printing outputprint(list_sorted)
[0, 1, 11, 15, 58]

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Convert a list to dictionary
How to use Icon Component in ReactJS?

05 Mar, 2021
Icons are required for every application for UI purposes. Material UI for React has this component available for us, and it is very easy to integrate. We can use the Icon Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.
npm install @material-ui/icons
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 DeleteIcon from "@material-ui/icons/Delete";import Home from "@material-ui/icons/Home";import Person from "@material-ui/icons/Person";  export default function App() {  return (    <div style={{ display: "block", padding: 30 }}>      <h4>How to use Icon Component in ReactJS?</h4>      <pre>        Sample Delete Icon: <DeleteIcon /> <br></br>        Sample Home Icon: <Home /> <br></br>        Sample Person Icon: <Person /> <br></br>      </pre>    </div>  );}
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.
Reference: https://material-ui.com/components/icons/
Material-UI
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Axios in React: A Guide for Beginners
ReactJS useNavigate() Hook
How to do crud operations in ReactJS ?
How to install bootstrap in React.js ?
How to navigate on path by button click in react router ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Remove elements from a JavaScript Array
Difference between Ping and Traceroute

18 Apr, 2022
In computer networks, data is sent in small blocks known as packets. Each packet is transmitted individually and may also follow a different route to reach the destination. Once all these packets of the original message reach the destination, they are re-assembled to form the original message. But, sometimes, it may happen that the webserver is down, network congestion or some other technical glitch is there, that may prevent the message from reaching the destination. To diagnose such congestions and network failures, we use two common programs namely Ping and Traceroute.
Ping: It is a utility that helps one to check if a particular IP address is accessible or not. Ping works by sending a packet to the specified address and waits for a reply. It also measures round trip time and reports errors.
Ping is also used in checking if the computers on a local network are active. For this, the user has to go to the command prompt and type: ping 127.0.0.1, and if the address is active, the ping would return a message like this :
Pinging 127.0.0.1 with 32 bytes of data
Reply from 127.0.0.1: bytes=32 time<10ms TTL=32
Reply from 127.0.0.1: bytes=32 time<10ms TTL=32
Reply from 127.0.0.1: bytes=32 time<10ms TTL=32
Reply from 127.0.0.1: bytes=32 time<10ms TTL=32
The IP address 127.0.0.1 is the address of the local host and would receive a ping reply even if the sender is not connected to the internet.
Traceroute: It is a utility that traces a packet from your computer to the host, and will also show the number of steps (hops) required to reach there, along with the time by each step. Traceroute works by sending the packets of data with a low survival time (Time to Live – TTL) which specifies how many steps (hops) can the packet survive before it is returned. When a packet can’t reach the final destination and expires at an intermediate step, that node returns the packet and identifies itself. So, by increasing the TTL gradually, Traceroute is able to identify the intermediate hosts. If any of the hops come back with  “Request timed out”, it denotes network congestion and a reason for slow loading Web pages and dropped connections.
The main difference between Ping and Traceroute is that Ping is a quick and easy utility to tell if the specified server is reachable and how long will it take to send and receive data from the server whereas Traceroute finds the exact route taken to reach the server and time taken by each step (hop).
pall58183
mayank007rawa
Network Layer
Computer Networks
Difference Between
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.