code-rag-bench/online-tutorials huggingface dataset:
Kotlin Variables

09 May, 2019
In Kotlin, every variable should be declared before it’s used. Without declaring a variable, an attempt to use the variable gives a syntax error. Declaration of the variable type also decides the kind of data you are allowed to store in the memory location.
In case of local variables, the type of variable can be inferred from the initialized value.
var rollno = 55
var name = "Praveen"
println(rollno)
println(name)

Above we have the local variable rollno whose value is 55 and it’s type is Integer because the literal type is Int and another variable is name whose type is String.
In Kotlin, variables are declared using two types –
Immutable using val keywordMutable using var keyword
Immutable using val keyword
Mutable using var keyword
Immutable is also called read-only variables. Hence, we can not change the value of the variable declared using val keyword.
val myName = "Gaurav"
myName = "Praveen"    // compile time error

// It gives error Kotlin Val cannot be reassigned

Note: Immutable variable is not a constant because it can be initialized with the value of a variable. It means the value of immutable variable doesn’t need to be known at compile-time, and if it is declared inside a construct that is called repeatedly, it can take on a different value on each function call.
var myBirthDate = "02/12/1993"
val myNewBirthDate = myBirthDate
println(myNewBirthDate)

In Mutable variable we can change the value of the variable.
var myAge = 25
myAge = 26            // compiles successfully
println("My new Age is ${myAge}")

Output:
My new Age is 26
 Scope of a variable –A variable exists only inside the block of code( {.............} ) where it has been declared. You can not access the variable outside the loop. Same variable can be declared inside the nested loop – so if a function contains an argument x and we declare a new variable x inside the same loop, then x inside the loop is different then the argument.
Naming Convention –Every variable should be named using lowerCamelCase.
val myBirthDate = "02/12/1994"

Kotlin
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Android RecyclerView in Kotlin
How to Add Views Dynamically and Store Data in Arraylist in Android?
Broadcast Receiver in Android With Example
Content Providers in Android with Example
Retrofit with Kotlin Coroutine in Android
Kotlin constructor
Kotlin Setters and Getters
How to Add and Customize Back Button of Action Bar in Android?
How to Communicate Between Fragments in Android?
Suspend Function In Kotlin Coroutines
How to get the text without HTML element using JavaScript ?

27 Apr, 2020
Given an HTML document containing some elements and the task is to get the text inside an HTML element using JavaScript. There are two methods to get the text without HTML element which are listed below:
Using innerText propertyUsing textContent property
Using innerText property
Using textContent property
Using innerText property: We can use innerText property to get the text from HTML element.
Example:
<!DOCTYPE html> <html>   <head>     <title>         Get the text inside HTML        element using JavaScript    </title> </head>  <body>    <div class="main">        Welcome to GeeksforGeeks    </div>      <script>        const div = document.querySelector('.main');          alert(div.innerText);    </script></body>  </html>
Output:
Using textContent property: We can also use textContent property to get the text from HTML element.
Example:
<!DOCTYPE html> <html>   <head>     <title>         Get the text inside HTML        element using JavaScript    </title> </head>  <body>    <div class="main">        Welcome to GeeksforGeeks    </div>       <script>        const div = document.querySelector('.main');           alert(div.textContent);    </script></body>  </html>
Output:
Difference between innerText and textContent:
The innerText property returns only human-readable text while the textContent property returns all the text including <script> and <style> tag.The innerText property take care of styling of elements and did not return any hidden elements while textContent property returns all the elements including the hidden ones.The innerText property is defined only for HTMLElement objects, whereas textContent property is defined for all Node objects.
The innerText property returns only human-readable text while the textContent property returns all the text including <script> and <style> tag.
The innerText property take care of styling of elements and did not return any hidden elements while textContent property returns all the elements including the hidden ones.
The innerText property is defined only for HTMLElement objects, whereas textContent property is defined for all Node objects.
HTML-Misc
JavaScript-Misc
Picked
HTML
JavaScript
Web Technologies
Web technologies Questions
Write From Home
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Int32 and UInt32 in C#

26 May, 2020
Int32: This Struct is used to represents 32-bit signed integer. The Int32 can store both types of values including negative and positive between the ranges of -2147483648 to +2147483647.
Example :
C#
// C# program to show the// difference between Int32// and UInt32  using System;using System.Text;  publicclass GFG {    // Main Method  static void Main(string[] args) {      // printing minimum & maximum values    Console.WriteLine("Minimum value of Int32: "                       + Int32.MinValue);    Console.WriteLine("Maximum value of Int32: "                       + Int32.MaxValue);    Console.WriteLine();      // Int32 array    Int32[] arr1 = {-3, 0, 1, 3, 7};      foreach (Int32 i in arr1)    {       Console.WriteLine(i);    }  }}
Output:
Minimum value of Int32: -2147483648
Maximum value of Int32: 2147483647

-3
0
1
3
7


UInt32: This Struct is used to represents 32-bit unsigned integer. The UInt32 can store only positive value only which ranges from 0 to 4294967295.
Example :
C#
// C# program to show the // difference between Int32 // and UInt32  using System;using System.Text;  public class GFG{          // Main Method    static void Main(string[] args)    {          // printing minimum & maximum values        Console.WriteLine("Minimum value of UInt32: "                          + UInt32.MinValue);        Console.WriteLine("Maximum value of UInt32: "                          + UInt32.MaxValue);        Console.WriteLine();                  // Int32 array        UInt32[] arr1 = { 13, 0, 1, 3, 7};                  foreach (UInt32 i in arr1)        {            Console.WriteLine(i);        }    }}
Output:
Minimum value of UInt32: 0
Maximum value of UInt32: 4294967295

13
0
1
3
7


Differences between Int32 and UInt32 in C#
Sr.No
INT32
UINT32
1.
2.
3.
4.
5.
 6.
 Syntax to declare the Int32 :
Int32 variable_name;

  Syntax to declare the UInt32:
UInt32 variable_name;

CSharp-Int32-Struct
CSharp-UInt32-Struct
C#
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to .NET Framework
C# | Delegates
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Data Types
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
A scale transform the element by using x-axis with CSS3

The scaleX(x) method is used to scale transform the element using x-axis.
Let us see the syntax −
scaleX(x)
Here, x is a number representing the scaling factor to apply on the abscissa of each point of the element.
Let us see an example −
div {
   width: 60px;
   height: 60px;
   background-color: yellow;
}
.scaled {
   transform: scaleX(0.5);
   background-color: black;
}
Python | Join tuple elements in a list - GeeksforGeeks

21 Feb, 2019
Now days, data is something that is backbone of any Machine Learning technique. The data can come in any form and its sometimes required to be extracted out to be processed. This article deals with the issue of extracting information which is present in tuples in list. Let’s discuss certain ways in which this can be performed.
Method #1 : Using join() + list comprehensionThe join function can be used to join each tuple elements with each other and list comprehension handles the task of iterating through the tuples.
# Python3 code to demonstrate # joining tuple elements# using join() + list comprehension  # initializing tuple list test_list = [('geeks', 'for', 'geeks'),             ('computer', 'science', 'portal')]  # printing original listprint ("The original list is : " + str(test_list))  # using join() + list comprehension# joining tuple elements res = [' '.join(tups) for tups in test_list]  # printing result print ("The joined data is : " +  str(res))
The original list is : [(‘geeks’, ‘for’, ‘geeks’), (‘computer’, ‘science’, ‘portal’)]The joined data is : [‘geeks for geeks’, ‘computer science portal’]
Output :
 Method #2 : Using map() + join()The functionality of list comprehension in the above method can also be done using the map function. This reduces the size of the code increasing its readability.
# Python3 code to demonstrate # joining tuple elements# using join() + map()  # initializing tuple list test_list = [('geeks', 'for', 'geeks'),             ('computer', 'science', 'portal')]  # printing original listprint ("The original list is : " + str(test_list))  # using join() + map()# joining tuple elements res = list(map(" ".join, test_list))  # printing result print ("The joined data is : " +  str(res))
The original list is : [(‘geeks’, ‘for’, ‘geeks’), (‘computer’, ‘science’, ‘portal’)]The joined data is : [‘geeks for geeks’, ‘computer science portal’]
Python list-programs
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
How to print without newline in Python?
Python program to check whether a number is Prime or not
Python MySQL - Update Query - GeeksforGeeks

09 Mar, 2020
A connector is employed when we have to use MySQL with other programming languages. The work of MySQL-connector is to provide access to MySQL Driver to the required language. Thus, it generates a connection between the programming language and the MySQL Server.
The update is used to change the existing values in a database. By using update a specific value can be corrected or updated. It only affects the data and not the structure of the table.The basic advantage provided by this command is that it keeps the table accurate.
Syntax:
UPDATE tablename
SET ="new value"
WHERE ="old value";

The following programs will help you understand this better.DATABASE IN USE:
Example 1: Program to update the age of student named Rishi Kumar.
# Python program to demonstrate# update clause    import mysql.connector  # Connecting to the Databasemydb = mysql.connector.connect(  host ='localhost',  database ='College',  user ='root',)  cs = mydb.cursor()  # drop clausestatement ="UPDATE STUDENT SET AGE = 23 WHERE Name ='Rishi Kumar'"  cs.execute(statement)mydb.commit()  # Disconnecting from the databasemydb.close()
Output:
Example 2: Program to correct the spelling of an Student named SK
# Python program to demonstrate# update clause    import mysql.connector  # Connecting to the Databasemydb = mysql.connector.connect(  host ='localhost',  database ='College',  user ='root',)  cs = mydb.cursor()  # drop clausestatement ="UPDATE STUDENT SET Name = 'S.K. Anirban' WHERE Name ='SK Anirban'"  cs.execute(statement)mydb.commit()  # Disconnecting from the databasemydb.close()
Output:
Python-mySQL
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Enumerate() in Python
Iterate over a list in Python
Python String | replace()
How to delete all records from a table in Oracle using JDBC API?

The SQL TRUNCATE statement is used to delete all the records from a table.
TRUNCATE TABLE table_name;
To delete all the records from a table from using JDBC API you need to −
Register the Driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.
Establish a connection: Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) as parameters to it.
Create Statement: Create a Statement object using the createStatement() method of the Connection interface.
Execute the Query: Execute the query using the execute() method of the Statement interface.
Following JDBC program establishes connection with oracle database and deletes all the records in the table named dispatches −
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DeletingAllRows_Oracle {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      //Getting the connection
      String oracleUrl = "jdbc:oracle:thin:@localhost:1521/xe";
      Connection con = DriverManager.getConnection(oracleUrl, "system", "password");
      System.out.println("Connection established......");
      //Creating the Statement
      Statement stmt = con.createStatement();
      //Query to delete all records in a table
      String query = "Truncate table DISPATCHES";
      //Executing the query
      stmt.execute(query);
      System.out.println("Table truncated....");
   }
}
Connection established......
Table truncated....
After deleting, if you verify the contents of the Dispatches table using select statement, you will get the output as −
SQL> select * from dispatches;
no rows selected
C++ Program to Find Fibonacci Numbers using Iteration

The following is an example to find fibonacci series using iteration.
 Live Demo
#include <iostream>
using namespace std;
void fib(int num) {
   int x = 0, y = 1, z = 0;
   for (int i = 0; i < num; i++) {
      cout << x << " ";
      z = x + y;
      x = y;
      y = z;
   }
}
int main() {
   int num;
   cout << "Enter the number : ";
   cin >> num;
   cout << "\nThe fibonacci series : " ;
   fib(num);
   return 0;
}
Enter the number : 10
The fibonacci series : 0 1 1 2 3 5 8 13 21 34
In the above program, the actual code is present in function fib() to calculate the fibonacci series.
void fib(int num) {
   int x = 0, y = 1, z = 0;
   for (int i = 0; i < num; i++) {
      cout << x << " ";
      z = x + y;
      x = y;
      y = z;
   }
}
In the main() function, a number is entered by the user. The function fib() is called and fibonacci series is printed as follows −
cout << "Enter the number : ";
cin >> num;
cout << "\nThe fibonacci series : " ;
fib(num);
Send CSV payload to API with Data Factory | by Miia Rämö | Towards Data Science

One might think that there is a straight forward way to read data from SQL table/CSV Blob with Data Factory and send it to an API expecting a text body with CSV format. Well, to my knowledge there is not, and we need to create a Function app to achieve this.
One example use case, where I’ve come across this problem is when uploading data to Salesforce Bulk API 2.0.
In this article, I’ll show you a solution where
I read data from an SQL Database and write it to Blob storage as a CSV file,I fetch the Blob content as bytes with an Azure Function app, andI send the Function response to an example API I created.
I read data from an SQL Database and write it to Blob storage as a CSV file,
I fetch the Blob content as bytes with an Azure Function app, and
I send the Function response to an example API I created.
If you want to preserve history of files sent, I recommend setting the Blob name as a pipeline variable. If preserving the history is not necessary, you may use a hardcoded Blob name.
My Blob name includes the current timestamp and a file name:
@concat(substring(utcnow(), 0, 19), 'canada_climate_data.csv')
We’ll use Data Factory Copy Activity to create our Blob. In this example, my source is a table in my SQL DB. Both the source and sink datasets are created as generic datasets. See my article Keep your Data Factory clean with generic datasets for explanation.
To create my Python Function app, I followed these instructions by Microsoft. My __init__.py file is as follows:
The dynamic content for JSON body is as follows (replace ‘yourstorage’ and ‘container’ with your storage account name and the correct container name):
@concat('{"blob_location":"https://yourstorage.blob.core.windows.net/container/',variables('blob_name'),'"}')
The dynamic content for body is the response from my function:
@activity('Blob to bytes').output.Response
And that’s it!
Thank you for reading! If you learned something new or enjoyed this article, follow me on Medium. I publish articles about data engineering and data science. You can learn more about me from be web page.
Have you found a better way to achieve this, or was something unclear? Let me know in the comments 😊
How to Format date using strftime() in Python ? - GeeksforGeeks

17 Apr, 2021
In this article, we will see how to format date using strftime() in Python. localtime() and gmtime() returns a tuple representing a time and this tuple is converted into a string as specified by the format argument using python time method strftime().
Syntax:
time.strftime(format[, sec])
sec: This is the time in number of seconds to be formatted.
format: This is the directive or format code which would be used to format.
Below are some examples for better understanding.
Example 1: 
Python3
from datetime import datetime  # current time and date# datetime objecttime = datetime.now()print("Without formating:", time)  # formating date using strftimeprint("After formating:", time.strftime("%b %d, %Y"))
Output:
Example 2: 
Python3
from datetime import datetime  # current time and date# datetime objecttime = datetime.now()print("Without formating:", time)  # formating date using strftimeprint("Year", time.strftime("%Y"))print("Month name", time.strftime("%B"))print("Day", time.strftime("%d"))
Output:
Example 3: 
Python3
from datetime import datetime  # current time and date# datetime objecttime = datetime.now()  # formating date using strftime# format = MM/DD/YYprint(time.strftime("%m/%d/%y"))  # format = Month D, Yrprint(time.strftime("%B %d, %Y"))  # time formating# HH:MM:SSprint(time.strftime("%H:%M:%S"))
Output:
Picked
Python-datetime
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
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
Reading and Writing to text files in Python
*args and **kwargs in Python
How To Convert Python Dictionary To JSON?
HTML | <frameset> cols Attribute - GeeksforGeeks

17 Dec, 2021
The HTML <frameset> cols Attribute is used to specify the size and the number of columns in a frameset. The width of each frame is separated by a comma.
Note: It is not supported in HTML5.
Syntax:
<frameset cols="pixels | % | *">
Attribute Values:
pixels: The width of column is set in terms of pixels. Example: “50px” or “50”.
%: The width of columns is set in terms of percentage. Example “70%”.
*: The width of columns is set to all available space.
Example:
<!DOCTYPE html> <html>         <head>         <title>HTML frameset cols Attribute</title>     </head>               <frameset cols = "30%, 40%, 30%">         <frame name = "top" src = "attr1.png" />         <frame name = "main" src = "gradient3.png" />         <frame name = "bottom" src = "col_last.png" />             </frameset> </html>
Output:
Supported Browsers: The browser supported by HTML <frameset> cols Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Find distance between two nodes of a Binary Tree in C++ Program

In this problem, we are given a binary tree and two nodes. Our task is to create a program to Find distance between two nodes of a Binary Tree.
We need to find the distance between two nodes which is the minimum number of edges that will be traversed when we go from one node to another node.
Let’s take an example to understand the problem,
Input: binary tree
Node1 = 3 ,Node2 = 5
Output: 3
The path from node 3 to node 5 is 3 -> 1 -> 2 -> 5. There are 3 edges traversed that make distance 3.
A simple solution to the problem is using the lowest common ancestor node for the given nodes and then apply the below formula,
distance(node1, node2) = distance(root, node1) + distance(root, node2) + distance(root, LCA)
 Live Demo
#include <iostream>
using namespace std;
struct Node{
   struct Node *left, *right;
   int key;
};
Node* insertNode(int key){
   Node *temp = new Node;
   temp->key = key;
   temp->left = temp->right = NULL;
   return temp;
}
int calcNodeLevel(Node *root, int val, int level) {
   if (root == NULL)
      return -1;
   if (root->key == val)
      return level;
   int lvl = calcNodeLevel(root->left, val, level+1);
   return (lvl != -1)? lvl : calcNodeLevel(root->right, val, level+1);
}
Node *findDistanceRec(Node* root, int node1, int node2, int &dist1, int &dist2, int &dist, int lvl){
   if (root == NULL) return NULL;
   if (root->key == node1){
      dist1 = lvl;
      return root;
   }
   if (root->key == node2){
      dist2 = lvl;
      return root;
   }
   Node *leftLCA = findDistanceRec(root->left, node1, node2, dist1,dist2, dist, lvl+1);
   Node *rightLCA = findDistanceRec(root->right, node1, node2, dist1,dist2, dist, lvl+1);
   if (leftLCA && rightLCA){
      dist = dist1 + dist2 - 2*lvl;
      return root;
   }
   return (leftLCA != NULL)? leftLCA: rightLCA;
}
int CalcNodeDistance(Node *root, int node1, int node2) {
   int dist1 = -1, dist2 = -1, dist;
   Node *lca = findDistanceRec(root, node1, node2, dist1, dist2, dist, 1);
   if (dist1 != -1 && dist2 != -1)
      return dist;
   if (dist1 != -1){
      dist = calcNodeLevel(lca, node2, 0);
      return dist;
   }
   if (dist2 != -1){
      dist = calcNodeLevel(lca, node1, 0);
      return dist;
   }
   return -1;
}
int main(){
   Node * root = insertNode(1);
   root->left = insertNode(2);
   root->right = insertNode(3);
   root->left->left = insertNode(4);
   root->left->right = insertNode(5);
   root->right->left = insertNode(6);
   cout<<"Distance between node with value 5 and node with value 3 is"<<CalcNodeDistance(root, 3, 5);
   return 0;
}
Distance between node with value 5 and node with value 3 is 3
Array of Arrays Representation in Data Structure

In this section we will see another representation of multidimensional arrays. Here we will see the Array of Arrays representation. In this form, we have an array, that is holding the starting addresses of multiple arrays. The representation will be look like this.
This is a two-dimensional array x of size [7 x 8]. Each row is represented as a single onedimensional array. The initial array is holding the addresses of these single arrays. They are array of addresses, so we can say that, it is an array of pointers. Each pointer is holding addresses of another arrays.
create this kind of array, we can use the new keyword like below −
int [][] x = new int[7][8];
To retrieve an element present at position x[i, j], it will find the address using x[i] at first, then move to jth index in that array.
Finding the sum of integers from multiple MySQL rows in same column?

Let us first create a table −
mysql> create table DemoTable739 (Price int);
Query OK, 0 rows affected (0.65 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable739 values(100);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable739 values(50);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable739 values(1200);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable739 values(500);
Query OK, 1 row affected (0.37 sec)
mysql> insert into DemoTable739 values(800);
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable739;
This will produce the following output -
+-------+
| Price |
+-------+
| 100   |
| 50    |
| 1200  |
| 500   |
| 800   |
+-------+
5 rows in set (0.00 sec)
Following is the query to find the sum of integers from multiple MySQL rows in same column −
mysql> select sum(Price) as Total_Price from DemoTable739;
This will produce the following output -
+-------------+
| Total_Price |
+-------------+
| 2650        |
+-------------+
1 row in set (0.00 sec)
Applying a Function over an Object in R Programming - sapply() Function - GeeksforGeeks

19 Jun, 2020
sapply() function in R Language takes list, vector or data frame as input and gives output in vector or matrix. It is useful for operations on list objects and returns a list object of same length of original set.
Syntax: sapply(X, FUN)
Parameters:X: A vector or an objectFUN: Function applied to each element of x
Example 1:
# R program to illustrate# sapply function  # Getting the value of Biochemical oxygen# demand data setBOD  # Calling sapply() function which# will sum the data of each columns# of BODsapply(BOD, sum)
Output:
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
  Time demand 
    22     89

Example 2:
# R program to illustrate# sapply function  # Initializing a listmylist <- list(c(1, 2, 3, 4), c(2, 4, 6, 8), c(1, 3, 5, 7))  # Calling the sapply() function which# will calculate mean of each vector elementssapply(mylist, mean)
Output:
[1] 2.5 5.0 4.0

R DataFrame-Function
R List-Function
R Matrix-Function
R Object-Function
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
Filter data by multiple conditions in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
Loops in R (for, while, repeat)
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
How we can copy Python modules from one system to another?

If you have your own Python modules you want to copy, you can simply copy them and run on other systems with Python installed. If you want to copy installed modules, the best way is to install the same version of Python on the second system. Then run
$ pip freeze > installed_modules.txt
on the first system to get a list of the installed modules in the installed_modules.txt file. Now copy this file over to second system. Now use pip to install these modules using:
$ pip install -r installed_modules.txt
This will install all modules that were installed on the first system. It is the best way as simply copy pasting from one system to the other can cause problems due to differences in OS, Architecture, versions, etc.
C# Switch

Use the switch statement to select one of many code blocks to be executed.
switch(expression) 
{
  case x:
    // code block
    break;
  case y:
    // code block
    break;
  default:
    // code block
    break;
}

This is how it works:
The switch expression is evaluated once
The value of the expression is compared with the values of each case
If there is a match, the associated block of code is executed
The break and default keywords will be described later in this chapter
The example below uses the weekday number to calculate the weekday name:
int day = 4;
switch (day) 
{
  case 1:
    Console.WriteLine("Monday");
    break;
  case 2:
    Console.WriteLine("Tuesday");
    break;
  case 3:
    Console.WriteLine("Wednesday");
    break;
  case 4:
    Console.WriteLine("Thursday");
    break;
  case 5:
    Console.WriteLine("Friday");
    break;
  case 6:
    Console.WriteLine("Saturday");
    break;
  case 7:
    Console.WriteLine("Sunday");
    break;
}
// Outputs "Thursday" (day 4)


Try it Yourself »

When C# reaches a break 
keyword, it breaks out of the switch block.
This will stop the execution of more code and case testing inside 
the block.
When a match is found, and the job is done, it's time for a break. There is no need for more testing.
A break can save a lot of execution time because it "ignores" the execution 
of all the rest of the code in the switch block.
The default keyword is optional and specifies some code to run if there is no 
case match:
int day = 4;
switch (day) 
{
  case 6:
    Console.WriteLine("Today is Saturday.");
    break;
  case 7:
    Console.WriteLine("Today is Sunday.");
    break;
  default:
    Console.WriteLine("Looking forward to the Weekend.");
    break;
}
// Outputs "Looking forward to the Weekend."
 


Try it Yourself »

Insert the missing parts to complete the following switch statement.
int day = 2;
switch () 
{
   1:
    Console.WriteLine("Monday");
    break;
   2:
    Console.WriteLine("Tuesday");
    ;
}

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.
Powershell - Read-Host Cmdlet

Read-Host cmdlet is used to read from the console.
In these example, we're see the Read-Host cmdlet in action.
In this example, we'll ask the user to pass an input and read the input into a variable.
$choice = Read-Host "Please put your choice"
Powershell will show a popup to enter the value. Once you enter the value, it is saved in $choice variable. Now print the variable.
$choice
You can see the value of variable.
1


    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
Java Examples - Matching Phone Numbers

How to match phone numbers in a list?
Following example shows how to match phone numbers in a list to a particle pattern by using phone.matches(phoneNumberPattern) method.
public class MatchPhoneNumber {
   public static void main(String args[]) {
      isPhoneValid("1-999-585-4009");
      isPhoneValid("999-585-4009");
      isPhoneValid("1-585-4009");
      isPhoneValid("585-4009");
      isPhoneValid("1.999-585-4009");
      isPhoneValid("999 585-4009");
      isPhoneValid("1 585 4009");
      isPhoneValid("111-Java2s");
   }
   public static boolean isPhoneValid(String phone) {
      boolean retval = false;
      String phoneNumberPattern = "(\\d-)?(\\d{3}-)?\\d{3}-\\d{4}";
      retval = phone.matches(phoneNumberPattern);
      String msg = "NO MATCH: pattern:" + phone + "\r\n regex: " + phoneNumberPattern;
      
      if (retval) {
         msg = " MATCH: pattern:" + phone + "\r\n regex: " + phoneNumberPattern;
      }
      System.out.println(msg + "\r\n");
      return retval;
   }
}
The above code sample will produce the following result.
MATCH: pattern:1-999-585-4009
	    regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
MATCH: pattern:999-585-4009
	    regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
MATCH: pattern:1-585-4009
	    regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
NOMATCH: pattern:1.999-585-4009
 regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
NOMATCH: pattern:999 585-4009
 regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
NOMATCH: pattern:1 585 4009
 regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}
NOMATCH: pattern:111-Java2s
 regex: (\\d-)?(\\d{3}-)?\\d{3}-\\d{4}

The following is an example to verify phone number.
public class Main { 
   private static boolean isValid(String s) {
      String regex = "\\d{2}-\\d{4}-\\d{6}"; 
      return s.matches(regex);
   } 
   public static void main(String[] args) {
      System.out.println(isValid("91-9652-018244"));
   } 
}
The above code sample will produce the following result.
true

 Print
 Add Notes
 Bookmark this page
Precision Handling in Java

Let us see how precisions are handled in Java −
 Live Demo
import java.io.*;
import java.lang.*;
public class Demo{
   public static void main(String[] args){
      double my_val = 34.909;
      System.out.println("The formatted value of 34.909 is ");
      System.out.println(String.format("%.7f", my_val));
      double my_val_2 = 12.56;
      System.out.println("The formatted value of 12.56 is ");
      System.out.println(String.format("%.9f", my_val_2));
   }
}
The formatted value of 34.909 is
34.9090000
The formatted value of 12.56 is
12.560000000
A class named Demo contains the main function, where a double valued integer is declared, and it is
formatted by specifying the number that it should be formatted to. Similarly, another double
variable is defined, and formatted and printed on the screen.
Unit Testing for C# Code

Unit testing is a key for C# code since it can help in maintaining code in the development process. It lets you know about the problems in the development cycle.
With Unit Testing, you can make the code reliable and reusable.
One of the fundamental principles of adopting unit testing is to follow a TDD (Test Driven Development) approach where we have to write tests case first, and then write the simple code that will make the test pass
For Unit testing, you need to work with Microsoft Testing tools, which is what we call MS Unit Test.
To create a Unit Test, go to Solution Explorer, right-click, go to New and click “New Project”.
Now select “Unit Test Project” − 
Set a name for the Test and click Ok.
New Unit Test project is created.
Now right click on the new unit test and add the following reference − 
Microsoft.VisualStudio.QualityTools.UnitTestFramework
Wand splice() function - Python - GeeksforGeeks

10 Aug, 2021
The splice() function is an inbuilt function in the Python Wand ImageMagick library which is used to partition the image by splicing a width x height rectangle at (x, y) offset coordinate. The space inserted will be replaced by the available background color. 
Syntax:
splice(width, height, x, y)
Parameters: This function accepts four parameters as mentioned above and defined below:  
width: This parameter stores the width of the rectangle.
height: This parameter stores the height of the rectangle.
x: This parameter stores the offset on the x-axis.
y: This parameter stores the offset on the y-axis.
Return Value: This function returns the Wand ImageMagick object.
Original Image:
Example 1:  
Python3
# Import library from Image from wand.image import Image  # Import the imagewith Image(filename ='../geeksforgeeks.png') as image:    # Clone the image in order to process    with image.clone() as splice:        # Invoke splice function with height as 20, width as 20, x as 10, y as 10        splice.splice(20, 20, 10, 10)        # Save the image        splice.save(filename ='splice1.jpg')
Output:  
Example 2:  
Python3
# Import libraries from the wand  from wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color  with Drawing() as draw:    # Set Stroke color the circle to black    draw.stroke_color = Color('black')    # Set Width of the circle to 2     draw.stroke_width = 1    # Set the fill color to 'White (# FFFFFF)'    draw.fill_color = Color('white')      # Invoke Circle function with center at 50, 50 and radius 25    draw.circle((200, 200), # Center point                (100, 100)) # Perimeter point    # Set the font style    draw.font = '../Helvetica.ttf'    # Set the font size     draw.font_size = 30          with Image(width = 400, height = 400, background = Color('# 45ff33')) as pic:        # Set the text and its location        draw.text(int(pic.width / 3), int(pic.height / 2), 'GeeksForGeeks !')        # Draw the picture        draw(pic)        # Invoke splice function with height as 10, width as 10, x as 15, y as 20        pic.splice(10, 10, 15, 20)        # Save the image         pic.save(filename ='splice2.jpg')
Output:  
 
sagar0719kumar
sagartomar9927
Image-Processing
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Create a Pandas DataFrame from Lists
Box Plot in Python using Matplotlib
Python Dictionary
Bar Plot in Matplotlib
Enumerate() in Python
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Graph Plotting in Python | Set 1
Python - Call function from another file
GATE | GATE-CS-2007 | Question 64 - GeeksforGeeks

28 Jun, 2021
Consider the following schedules involving two transactions. Which one of the following statements is TRUE?
(A) Both S1 and S2 are conflict serializable.(B) S1 is conflict serializable and S2 is not conflict serializable.(C) S1 is not conflict serializable and S2 is conflict serializable.(D) Both S1 and S2 are not conflict serializable.Answer: (C)Explanation:
S1 is not conflict serializable, but S2 is conflict serializable 

Schedule S1
   T1            T2
---------------------
  r1(X)
  r1(Y)
                r2(X)
                r2(Y)
                w2(Y)
  w1(X)
The schedule is neither conflict equivalent to T1T2, nor T2T1.

Schedule S2
   T1            T2
---------------------
  r1(X)
                r2(X)
                r2(Y)
                w2(Y)
  r1(Y)
  w1(X)
The schedule is conflict equivalent to T2T1.

Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-IT-2004 | Question 66
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2010 | Question 24
GATE | GATE CS 2011 | Question 7
GATE | GATE-IT-2004 | Question 71
GATE | GATE-CS-2004 | Question 3
GATE | GATE CS 2019 | Question 27
GATE | GATE CS 2012 | Question 54
GATE | GATE-CS-2016 (Set 1) | Question 65
What is a reentrant function in C/C++?

Here we will see what is the reentrant function in C or C++. One function is said to be a reentrant function if there is a provision to interrupt that function in the course of execution, then service the ISR (Interrupt Service Routine) and then resume the task. This type of functions is used in different cases like, recursions, hardware interrupt handling.
For a reentrant function there should be some properties. These are listed below −
This type of function will not use any global or static variable. There are no restrictions, but it is generally not advised. This is because the interrupt may change the values of global variable, so after coming back from ISR the function may get some new value, and results will be different.
This type of function will not use any global or static variable. There are no restrictions, but it is generally not advised. This is because the interrupt may change the values of global variable, so after coming back from ISR the function may get some new value, and results will be different.
The reentrant function should not modify its own code. We need the action of the function should remain same throughout the code.
The reentrant function should not modify its own code. We need the action of the function should remain same throughout the code.
Another property is the reentrant function should not call any other non-reentrant function.
Another property is the reentrant function should not call any other non-reentrant function.
int x;
int my_function() {
   return x * 10;
}
int my_second_function() {
   return my_function() * 20;
}
Here these two functions are non-reentrant. The first one is using one global variable, so it is non-reentrant. The second one is calling one non-reentrant function, so these also is not reentrant function.
int my_function(int x) {
   return x * 10;
}
int my_second_function(int x) {
   return my_function(x) * 20;
}
Now these two functions are reentrant functions.
GATE | GATE CS 2020 | Question 48 - GeeksforGeeks

26 May, 2021
An organization requires a range of IP address to assign one to each of its 1500 computers. The organization has approached an Internet Service Provider (ISP) for this task. The ISP uses CIDR and serves the requests from the available IP address space 202.61.0.0/17. The ISP wants to assign an address space to the organization which will minimize the number of routing entries in the ISP’s router using route aggregation. Which of the following address spaces are potential candidates from which the ISP can allot any one of the organization ?
I. 202.61.84.0 / 21
II. 202.61.104.0 / 21
III. 202.61.64.0 / 21
IV. 202.61.144.0 / 21 
(A) I and II only(B) II and III only(C) III and IV only(D) I and IV onlyAnswer: (B)Explanation: Subnet Mask for given IP address:
202.61.0.0/17 
⇒ 11111111 11111111 10000000 00000000
⇒ 255.255.128.0 
Now, since we need 1500 hosts, so, bits for host address,
= ceiling (log2 (1500)) 
= ceiling (10.55) 
= 11 bits for host address 
So, last 11 bits will for in host addresses:
00000000.00000000 → 00000111.11111111 (0.0  →  7.255)

00001000.00000000 → 00010000.00000000 (8.0 - 15.255)

00001111.11111111 → 00010111.11111111 (16.0 - 23.255) 
Sequence is 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 96, 104, 112, 120.
Hence 64 and 104 is present in sequence so it is the possible IP addresses.
So option (B) is correct.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE CS 2012 | Question 40
GATE | GATE-CS-2001 | Question 48
Alternative for <blink> tag - GeeksforGeeks

04 Jan, 2022
In this article we will learn about the alternatives of the blink tag of HTML. The blink tag doesn’t have any alternative HTML tag but the same effect can be alternatively created with the help of CSS
Example:
In this example we will be using CSS animations to get the blink-effect
html
<!DOCTYPE html><html>    <head>        <meta http-equiv="content-type"              content="text/html; charset=utf-8" />        <title>Geeksforgeeks</title>        <style type="text/css">                         /* Minor Styling optional */            .blinky{                margin: auto;                width: 200px;                height: 200px;                background: cyan;                text-align: center;                font-size: 24px;                /* for support in Safari 4.0 - 8.0 */                -webkit-animation:                  1.5s linear infinite blinky-effect;                 animation: 1.5s linear infinite blinky-effect;            }                                      /* for support in Safari 4.0 - 8.0 */            @-webkit-keyframes blinky-effect {              0% {                visibility: hidden;              }              50% {                visibility: hidden;              }              100% {                visibility: visible;              }            }                         @keyframes blinky-effect {              0% {                visibility: hidden;              }              50% {                visibility: hidden;              }              100% {                visibility: visible;              }            }        </style>    </head>    <body>        <div class="blinky">            This div is going to blink        </div>    </body></html>
Output:
Blink-Effect using CSS animations.
Advantages of the CSS approach over the blink tag  
 
In general the blink tag should not be used as it is a obsolete feature and can be removed in further updates. In order to learn more about CSS animations refer this article: CSS Animations
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
surindertarika1234
avtarkumar719
HTML-Misc
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Types of CSS (Cascading Style Sheet)
HTML | <img> align Attribute
Form validation using HTML and JavaScript
HTML Introduction
How to Upload Image into Database and Display it using PHP ?
Express.js express.Router() Function
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
Top 10 Angular Libraries For Web Developers
How to create footer to stay at the bottom of a Web page?
Increase or decrease the size of a font with CSS

The font-size property is used to increase or decrease the font size. The font-size property is used to control the size of fonts. Possible values could be xx-small, x-small, small, medium, large, x-large, xx-large, smaller, larger, size in pixels or in %.
<html>
   <head>
   </head>
   <body>
      <p style = "font-size:15px;">This font size is 15 pixels</p>
      <p style = "font-size:small;">This font size is small</p>
      <p style = "font-size:large;">This font size is large</p>
   </body>
</html>