code-rag-bench/online-tutorials huggingface dataset:
Understanding clientHeight, offsetHeight & scrollHeight Properties in CSS

clientHeight gives the measure of the height of an element including the padding. Note that border, margin, and scrollbar height (if renedered) are not included in this.
offsetHeight gives the measure of the height of an element including the vertical padding, top and bottom borders. Margin is not including here.
scrollHeight gives the measure of the height of an element including the vertical padding and the content which is not visible on the screen because of its overflow property.
The following examples illustrate clientHeight, offsetHeight, and scrollHeight.
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
#parent {
   margin-top: 10px;
   height: 200px;
   width: 200px;
   overflow: auto;
   margin: 20px;
}
#demo {
   height: 250px;
   padding: 20px;
   background-color: beige;
   border: 2px ridge red;
}
</style>
</head>
<body>
<button onclick="getHeight()">Get Client Height</button>
<div id="parent">
<div id="demo">
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</div>
</div>
<article id="display"></article>
<script>
function getHeight() {
   let myItem = document.getElementById("demo");
   let y = myItem.clientHeight;
   document.getElementById ("display").innerHTML = "Client Height is " + y + "px";
}
</script>
</body>
</html>
This will produce the following result −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
#parent {
   height: 180px;
   width: 180px;
   overflow: auto;
   margin: 20px;
}
#demo {
   height: 220px;
   padding: 20px;
   background-color: cornflowerblue;
   border: 10px ridge red;
   color: white;
}
</style>
</head>
<body>
<button onclick="getHeight()">Get Offset Height</button>
<div id="parent">
<div id="demo">
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
</ul>
</div>
</div>
<article id="display"></article>
<script>
function getHeight() {
   let myItem = document.getElementById("demo");
   let y = myItem.offsetHeight;
   document.getElementById ("display").innerHTML = "Offset Height is " + y + "px";
}
</script>
</body>
</html>
This will produce the following result −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
#parent {
   margin-top: 10px;
   height: 200px;
   width: 200px;
   overflow: auto;
   margin: 20px;
}
#demo {
   height: 400px;
   padding: 20px;
   background-color: bisque;
   border: 1px solid green;
}
</style>
</head>
<body>
<button onclick="getHeight()">Get Scroll Height</button>
<div id="parent">
<div id="demo">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
<article id="display"></article>
<script>
function getHeight() {
   let myItem = document.getElementById("demo");
   let y = myItem.scrollHeight;
   document.getElementById ("display").innerHTML = "Scroll Height is " + y + "px";
}
</script>
</body>
</html>
This will produce the following result −
How to get the first and last record of the table in MySQL?

To get the first and last record, use UNION. LIMIT is also used to get the number of records you want.
Let us first create a table −
mysql> create table DemoTable694 (
   EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   EmployeeName varchar(100),
   EmployeeSalary int
);
Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable694(EmployeeName,EmployeeSalary) values('Chris',457647);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable694(EmployeeName,EmployeeSalary) values('Robert',90883);
Query OK, 1 row affected (0.25 sec)
mysql> insert into DemoTable694(EmployeeName,EmployeeSalary) values('David',123532);
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable694(EmployeeName,EmployeeSalary) values('Mike',989322);
Query OK, 1 row affected (0.22 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable694;
This will produce the following output -
+------------+--------------+----------------+
| EmployeeId | EmployeeName | EmployeeSalary |
+------------+--------------+----------------+
| 1          | Chris        | 457647         |
| 2          | Robert       | 90883          |
| 3          | David        | 123532         |
| 4          | Mike         | 989322         |
+------------+--------------+----------------+
4 rows in set (0.00 sec)
Following is the query to get first and last record −
mysql> (select *from DemoTable694 order by EmployeeId ASC LIMIT 1)
UNION
(select *from DemoTable694 order by EmployeeId DESC LIMIT 1);
This will produce the following output -
+------------+--------------+----------------+
| EmployeeId | EmployeeName | EmployeeSalary |
+------------+--------------+----------------+
| 1          | Chris        | 457647         |
| 4          | Mike         | 989322         |
+------------+--------------+----------------+
2 rows in set (0.00 sec)
Compiler Design - Phases of Compiler

The compilation process is a sequence of various phases. Each phase takes input from its previous stage, has its own representation of source program, and feeds its output to the next phase of the compiler. Let us understand the phases of a compiler.
The first phase of scanner works as a text scanner. This phase scans the source code as a stream of characters and converts it into meaningful lexemes. Lexical analyzer represents these lexemes in the form of tokens as:
<token-name, attribute-value>
The next phase is called the syntax analysis or parsing. It takes the token produced by lexical analysis as input and generates a parse tree (or syntax tree). In this phase, token arrangements are checked against the source code grammar, i.e. the parser checks if the expression made by the tokens is syntactically correct.
Semantic analysis checks whether the parse tree constructed follows the rules of language. For example, assignment of values is between compatible data types, and adding string to an integer. Also, the semantic analyzer keeps track of identifiers, their types and expressions; whether identifiers are declared before use or not etc. The semantic analyzer produces an annotated syntax tree as an output.
After semantic analysis the compiler generates an intermediate code of the source code for the target machine. It represents a program for some abstract machine. It is in between the high-level language and the machine language. This intermediate code should be generated in such a way that it makes it easier to be translated into the target machine code.
The next phase does code optimization of the intermediate code. Optimization can be assumed as something that removes unnecessary code lines, and arranges the sequence of statements in order to speed up the program execution without wasting resources (CPU, memory).
In this phase, the code generator takes the optimized representation of the intermediate code and maps it to the target machine language. The code generator translates the intermediate code into a sequence of (generally) re-locatable machine code. Sequence of instructions of machine code performs the task as the intermediate code would do.
It is a data-structure maintained throughout all the phases of a compiler. All the identifier's names along with their types are stored here. The symbol table makes it easier for the compiler to quickly search the identifier record and retrieve it. The symbol table is also used for scope management.

    102 Lectures 
     10 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to assign specific colors to specific cells in a Matplotlib table?

To assign specific colors to specific cells in a Matplotlib table, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a tuple for columns attribute.
Make a list of lists, i.e., list of records.
Make a list of lists, i.e., color of each cell.
Create a figure and a set of subplots.
Add a table to an axes ax.
Turn off the axes.
To display the figure, use show() method.
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

columns = ('name', 'age', 'marks', 'salary')

cell_text = [["John", "23", "98", "234"],
["James", "24", "90", "239"]]

colors = [["red", "yellow", "blue", "green"],
["blue", "green", "yellow", "red"]]

fig, ax = plt.subplots()

the_table = ax.table(cellText=cell_text, cellColours=colors,
                     colLabels=columns, loc='center')
ax.axis('off')

plt.show()
Precedence of postfix ++ and prefix ++ in C/C++ - GeeksforGeeks

15 Jul, 2021
In C/C++, precedence of Prefix ++ (or Prefix –) has same priority than dereference (*) operator, and precedence of Postfix ++ (or Postfix –) is higher than both Prefix ++ and *. If p is a pointer then *p++ is equivalent to *(p++) and ++*p is equivalent to ++(*p) (both Prefix ++ and * are right associative).For example, program 1 prints ‘h’ and program 2 prints ‘e’. 
C
// Program 1#include<stdio.h>int main(){  char arr[] = "geeksforgeeks";  char *p = arr;  ++*p;  printf(" %c", *p);  getchar();  return 0;}
Output:
  h
 
C
// Program 2#include<stdio.h>int main(){  char arr[] = "geeksforgeeks";  char *p = arr;  *p++;  printf(" %c", *p);  getchar();  return 0;}
Output:
  e
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
sourabh571993
dpatwal8
C-Operators
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
C++ Program to Represent Graph Using Adjacency Matrix

The adjacency matrix of a graph is a square matrix of size V x V. The V is the number of vertices of the graph G. In this matrix in each side V vertices are marked. If the graph has some edges from i to j vertices, then in the adjacency matrix at ith row and jth column it will be 1 (or some non-zero value for weighted graph), otherwise that place will hold 0.
The adjacency matrix representation takes O(V2) amount of space while it is computed. When graph has maximum number of edges and minimum number of edges, in both cases the required space will be same.
The adjacency matrix representation takes O(V2) amount of space while it is computed. When graph has maximum number of edges and minimum number of edges, in both cases the required space will be same.
Input
Output
Input − The u and v of an edge {u,v}
Output − Adjacency matrix of the graph G
Begin
adj_matrix[u, v] := 1
adj_matrix[v, u] := 1
End
#include<iostream>
using namespace std;
int vertArr[20][20]; //the adjacency matrix initially 0
int count = 0;
void displayMatrix(int v) {
   int i, j;
   for(i = 0; i < v; i++) {
      for(j = 0; j < v; j++) {
         cout << vertArr[i][j] << " ";
      }
      cout << endl;
   }
}
void add_edge(int u, int v) { //function to add edge into the matrix
   vertArr[u][v] = 1;
   vertArr[v][u] = 1;
}
main(int argc, char* argv[]) {
int v = 6; //there are 6 vertices in the graph
add_edge(0, 4);
add_edge(0, 3);
add_edge(1, 2);
add_edge(1, 4);
add_edge(1, 5);
add_edge(2, 3);
add_edge(2, 5);
add_edge(5, 3);
add_edge(5, 4);
displayMatrix(v);
}
0 0 0 1 1 0
0 0 1 0 1 1
0 1 0 1 0 1
1 0 1 0 0 1
1 1 0 0 0 1
0 1 1 1 1 0
Getting MongoDB results from the previous month


At first, get the current month and subtract by 1 to fetch previous month records. Let us first create a collection with documents −
> db.findOneMonthAgoData.insertOne({"CustomerName":"Chris","PurchaseDate":new ISODate("2019-12-26")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04e16c150ee0e76c06a04f")
}
> db.findOneMonthAgoData.insertOne({"CustomerName":"David","PurchaseDate":new ISODate("2019-11-26")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04e178150ee0e76c06a050")
}
> db.findOneMonthAgoData.insertOne({"CustomerName":"Bob","PurchaseDate":new ISODate("2020-11-26")});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04e186150ee0e76c06a051")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.findOneMonthAgoData.find();
This will produce the following output −
{ "_id" : ObjectId("5e04e16c150ee0e76c06a04f"), "CustomerName" : "Chris", "PurchaseDate" : ISODate("2019-12-26T00:00:00Z") }
{ "_id" : ObjectId("5e04e178150ee0e76c06a050"), "CustomerName" : "David", "PurchaseDate" : ISODate("2019-11-26T00:00:00Z") }
{ "_id" : ObjectId("5e04e186150ee0e76c06a051"), "CustomerName" : "Bob", "PurchaseDate" : ISODate("2020-11-26T00:00:00Z") }
Here is the query to get result from previous month −
> monthData=new Date();
ISODate("2019-12-26T16:43:04.283Z")
> monthData.setMonth(monthData.getMonth() - 1);
1574786584283
> db.findOneMonthAgoData.find({PurchaseDate:{$gte:monthData}});
This will produce the following output −
{ "_id" : ObjectId("5e04e16c150ee0e76c06a04f"), "CustomerName" : "Chris", "PurchaseDate" : ISODate("2019-12-26T00:00:00Z") }
{ "_id" : ObjectId("5e04e186150ee0e76c06a051"), "CustomerName" : "Bob", "PurchaseDate" : ISODate("2020-11-26T00:00:00Z") }
PHP | ctype_upper() Function

04 Jun, 2018
The ctype_upper() function in PHP used to check each and every character of a given string is in uppercase or not. If the string in upper case then it returns TRUE otherwise returns False.
Syntax:
ctype_upper (string text)

Parameter Used:-
$text : The tested string.
Return Value:Function returns True if each character of text in Upper Case or False if text is not in upper case.
Examples:
Input  : GEEKSFORGEEKS
Output : Yes
Explanation: All characters of  "GEEKSFORGEEKS" 
             in UPPERCASE.

Input  : GFG2018
Output : No
Explanation : In text "GFG2018",  '2', '0', '1', '8'
              are not in UPPERCASE.

Input : GFG INDIA
Output : No
Explanation : In String "GFG INDIA" a special character [space] 
              between GFG and INDIA. so answer will be No.
                   

Note: Except string, if we input anything then it will return FALSE.
Below program illustrates the ctype_upper() function in PHP:
Program: 1
<?php// PHP program to check given string is // all characters -Uppercase characters  $string1 = 'GEEKSFORGEEKS';     if (ctype_upper($string1)) {                 // if true then return Yes        echo "Yes\n";    } else {                  // if False then return No        echo "No\n";    }?>
Yes

Program: 2 passing array of string as text and print result for individual values.
<?php  // PHP program to check given string is // all characters -Uppercase characters  $strings = array('GEEKSFORGEEKS', 'First',                 'PROGRAMAT2018', 'ARTICLE');  // Checking above given four strings //by used of ctype_upper() function .  foreach ($strings as $test) {          if (ctype_upper($test)) {        // if true then return Yes        echo "Yes\n";    } else {        // if False then return No        echo "No\n";    }}  ?>
Yes
No
No
Yes

Program: 3 Drive a code ctype_upper() function where input will be space, special symbol, returns False.
     <?php// PHP program to check given string is // all characters -Uppercase characters  $strings = array('GEEK @ . com');  // Checking above given four strings //by used of ctype_upper() function .  foreach ($strings as $test) {          if (ctype_upper($test)) {        // if true then return Yes        echo "Yes\n";    } else {        // if False then return No        echo "No\n";    }}  ?>
No

References : http://php.net/manual/en/function.ctype-upper.php
PHP-function
PHP-string
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – API.user_timeline() in Tweepy

05 Jun, 2020
Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from twitter developer available easily for each user. These keys will help the API for authentication.
The user_timeline() method of the API class in Tweepy module is used to get the 20 most recent statuses posted from the authenticating user or the user specified.
Syntax : API.user_timeline(parameters)
Parameters :
id : specifies the ID or the screen name of the user.
user_id : specifies the ID of the user, useful to differentiate accounts when a valid user ID is also a valid screen name.
screen_name : specifies the screen name of the user, useful to differentiate accounts when a valid screen name is also a user ID.
since_ids : Fetch only the statuses newer than the specified ID.
max_ids : Fetch only the statuses older than or equal to the specified ID.
count : The number of statuses to be fetched, the default value is 20.
Returns : a list of objects of the class Status
Example 1 :
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # screen name of the account to be fetchedscreen_name = "geeksforgeeks"  # fetching the statusesstatuses = api.user_timeline(screen_name)  print(str(len(statuses)) + " number of statuses have been fetched.")
Output :
20 number of statuses have been fetched.

Example 2: Using the user_timeline() method with the count parameter to fetch only a specified number of statuses.
# screen name of the account to be fetchedscreen_name = "geeksforgeeks"  # number of statuses to be fetchedcount = 3  # fetching the statusesstatuses = api.user_timeline(screen_name, count = count)  # printing the statusesfor status in statuses:    print(status.text, end = "\n\n")
Output :
Hola Geeks!
.
Tell us what did you learned during this lockdown?
.
#MondayMotivation #mondaythoughts #codinglife... https://t.co/1mVLOKdaIL

@ZomatoIN Avoid Errors, not Client calls
#sundayvibes #programmingmemes

Avoid errors, not client calls
.
Geeks, Keep this going...
.
#sundayvibes #programming #programmingmemes #coding https://t.co/JkA5iStofZ

Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-1) | Question 65

04 Aug, 2021
Consider a selective repeat sliding window protocol that uses a frame size of 1 KB to send data on a 1.5 Mbps link with a one-way latency of 50 msec. To achieve a link utilization of 60%, the minimum number of bits required to represent the sequence number field is ________.(A) 3(B) 4(C) 5(D) 6Answer: (C)Explanation:
Transmission delay = Frame Size/bandwidth
                   = (1*8*1024)/(1.5 * 10^6)=5.33ms
Propagation delay = 50ms
Efficiency = Window Size/(1+2a) = .6

a = Propagation delay/Transmission delay
So, window size = 11.856(approx)
min sequence number = 2*window size = 23.712
bits required in Min sequence number = log2(23.712)
Answer is 4.56

Ceil(4.56) = 5 
Quiz of this Question
GATE-CS-2014-(Set-1)
GATE-GATE-CS-2014-(Set-1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
autoconf command in Linux with examples

27 Jan, 2022
autoconf command is used in Linux to generate configuration scripts. Generate a configuration script from a TEMPLATE-FILE if given, or from ‘configure.ac’ if present, or ‘configure.in’. The output is sent to the standard output if TEMPLATE-FILE is given, otherwise, it is sent into ‘configure’. To use autoconf we must install the this on the Linux terminal as follows:
sudo apt-get install autoconf
Synopsis:
user/bin/autoconf [OPTION] ... [TEMPLATE-FILE]
Options:
-h, –help: Display the help message and then exits.autoconf -h or autoconf --help
autoconf -h or autoconf --help
-V, –version: Shows the version number and then exits.autoconf -V or autoconf --version
autoconf -V or autoconf --version
-v, –verbose: Gives the verbosely report processing.autoconf -v filename or autoconf --verbose filename
autoconf -v filename or autoconf --verbose filename
-d, –debug: Makes sure to not remove any files that are temporary.autoconf -d filename or autoconf --debug filename
autoconf -d filename or autoconf --debug filename
-o, –option: Saves the output in the FILE(stdout is default).autoconf -o filename or autoconf --option filename
autoconf -o filename or autoconf --option filename
-w, –warnings: Reports the warnings falling in the categoriesautoconf -w category or autoconf --warnings categoryThe other warning categories are:
autoconf -w category or autoconf --warnings category
The other warning categories are:
andreaskaratzas8
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Index.get_loc()

17 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Index.get_loc() function return integer location, slice or boolean mask for requested label. The function works with both sorted as well as unsorted Indexes. It provides various options if the passed value is not present in the Index. you may choose to return the previous value or the next value to the passed value only if the Index labels are sorted.
Syntax: Index.get_loc(key, method=None, tolerance=None)
Parameters:key : labelmethod : {None, ‘pad’/’ffill’, ‘backfill’/’bfill’, ‘nearest’}, optional-> default: exact matches only.-> pad / ffill: find the PREVIOUS index value if no exact match.-> backfill / bfill: use NEXT index value if no exact match-> nearest: use the NEAREST index value if no exact match. Tied distances are broken by preferring the larger index value.
Returns : loc : int if unique index, slice if monotonic index, else mask
Example #1: Use Index.get_loc() function to find the location of the passed value.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index(['Labrador', 'Beagle', 'Labrador',                     'Lhasa', 'Husky', 'Beagle'])  # Print the Indexidx
Output :
let’s find out the location of ‘Lhasa’ in the Index.
# Print the location of the passed value..idx.get_loc('Lhasa)
Output :As we can see in the output, the Index.get_loc() function has returned 3 indicating that the passed value is present at this location in the Index. Example #2: Use Index.get_loc() function to find the location of the passed value. If the passed value is not present in the Index then return the location of previous value that is just smaller than the passed value.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index([1, 2, 3, 14, 25, 37, 48, 69, 100])  # Print the Indexidx
Output :
Let’s find the position of the value 33 in the Index.
# Find the position of 33 in the index.# If it is not present then we forward # fill and return the position of previous value.idx.get_loc(33, method ='ffill')
Output :
As we can see the function has returned the output 3. As 33 is not present in the Index but in the sorted order the value that is just smaller than 33 is 25 and its location is 4. So, the output is 4. we do not set method parameter then it will result into error if the value is not present.
Python pandas-indexing
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Find pair with maximum GCD in an array in C++

Suppose we have an array of positive integers. Our task is to find pair of integers from the array, where the GCD value is maximum. Let A = {1, 2, 3, 4, 5}, then the output is 2. The pair (2, 4) has GCD 2, other GCD values are less than 2.
To solve this problem, we will maintain a count array to store the count of divisors of each element. The process of counting divisors will take O(sqrt(arr[i])) amount of time. After whole traversal, we can traverse the count array from last index to first index, then if we find some value where the element is greater than 1, then, this means that it is the divisor of 2 elements and also the max GCD.
 Live Demo
#include <iostream>
#include <cmath>
using namespace std;
int getMaxGCD(int arr[], int n) {
   int high = 0;
   for (int i = 0; i < n; i++)
   high = max(high, arr[i]);
   int divisors[high + 1] = { 0 }; //array to store all gcd values
   for (int i = 0; i < n; i++) {
      for (int j = 1; j <= sqrt(arr[i]); j++) {
         if (arr[i] % j == 0) {
            divisors[j]++;
         if (j != arr[i] / j)
            divisors[arr[i] / j]++;
         }
      }
   }
   for (int i = high; i >= 1; i--)
   if (divisors[i] > 1)
   return i;
}
int main() {
   int arr[] = { 1, 2, 4, 8, 12 };
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "Max GCD: " << getMaxGCD(arr,n);
}
Max GCD: 4
C# Program to Convert Fahrenheit to Celsius

Firstly, set the Fahrenheit temperature −
double fahrenheit = 97;
Console.WriteLine("Fahrenheit: " + fahrenheit);
Now convert it into Celsius −
celsius = (fahrenheit - 32) * 5 / 9;
You can try to run the following code to convert Fahrenheit to Celsius.
Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         double celsius;
         double fahrenheit = 97;
         Console.WriteLine("Fahrenheit: " + fahrenheit);
         celsius = (fahrenheit - 32) * 5 / 9;
         Console.WriteLine("Celsius: " + celsius);
         Console.ReadLine();
      }
   }
}
Fahrenheit: 97
Celsius: 36.1111111111111
Python Pandas - Plot multiple data columns in a DataFrame?

To plot multiple columns, we will be plotting a Bar Graph. Use the plot() method and set the kind parameter to bar for Bar Graph. Let us first import the required libraries −
import pandas as pd
import matplotlib.pyplot as mp
Following is our data with Team Records −
data = [["Australia", 2500, 2021],["Bangladesh", 1000, 2021],["England", 2000, 2021],["India", 3000, 2021],["Srilanka", 1500, 2021]]
Set the data as Pandas DataFrame and add columns −
dataFrame = pd.DataFrame(data, columns=["Team","Rank_Points", "Year"])

Plot multiple columns in a bar graph. We have set the “kind” parameter as “bar” for this −
dataFrame.plot(x="Team", y=["Rank_Points","Year" ], kind="bar", figsize=(10, 9))
Following is the code −
import pandas as pd
import matplotlib.pyplot as mp

# our data
data = [["Australia", 2500, 2021],["Bangladesh", 1000, 2021],["England", 2000, 2021],["India", 3000, 2021],["Srilanka", 1500, 2021]]

# dataframe
dataFrame = pd.DataFrame(data, columns=["Team","Rank_Points", "Year"])

# plotting multiple columns in a bar Graph
dataFrame.plot(x="Team", y=["Rank_Points","Year" ], kind="bar", figsize=(10, 9))

# displaying bar graph
mp.show()
This will produce the following output −
cp - Unix, Linux Command

cp - To copy one or more files to another location.
cp [options]... Source Dest
cp [options]... Source... Directory
By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files.
The backup suffix is >, unless set with SIMPLE_BACKUP_SUFFIX. The version control can be set with VERSION_CONTROL, values are: t, numbered make numbered backups nil, existing numbered if numbered backups exist, simple otherwise never, simple always make simple backups. As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an existing, regular file.
Copy sample.txt to sample.bak.
$ cat sample.txt
This is a sample file
$ cp sample.txt sample.bak
$ cat sample.bak
This is a sample file

Copy sample directory to home directory
$ cp -f /user/sample/* >


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Add new Variables to a Data Frame using Existing Variables in R Programming - mutate() Function - GeeksforGeeks

19 Jun, 2020
mutate() function in R Language is used to add new variables in a data frame which are formed by performing operation on existing variables.
Syntax: mutate(x, expr)
Parameters:x: Data Frameexpr: operation on variables
Example 1:
# R program to add new variables# in a data frame  # Loading library library(dplyr)    # Create a data framed <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"),                   age = c(7, 5, 9, 16),                   ht = c(46, NA, NA, 69),                  school = c("yes", "yes", "no", "no") )     # Calculating a variable x3 which is sum of height # and age printing with ht and age mutate(d, x3 = ht + age)  
Output:
     name age ht school x3
1    Abhi   7 46    yes 53
2 Bhavesh   5 NA    yes NA
3  Chaman   9 NA     no NA
4   Dimri  16 69     no 85

Example 2:
# R program to add new variables# in a data frame  # Loading library library(dplyr)    # Create a data framed <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"),                   age = c(7, 5, 9, 16),                   ht = c(46, NA, NA, 69),                  school = c("yes", "yes", "no", "no") )     # Calculating a variable x3 which is product of height # and age printing with ht and age mutate(d, x3 = ht * age)  
Output:
     name age ht school   x3
1    Abhi   7 46    yes  322
2 Bhavesh   5 NA    yes   NA
3  Chaman   9 NA     no   NA
4   Dimri  16 69     no 1104

R DataFrame-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
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?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
Find the profit and loss in the given Excel sheet using Pandas - GeeksforGeeks

05 Sep, 2020
In these articles, we will discuss how to extract data from the Excel file and find the profit and loss at the given data. Suppose our Excel file looks like then we have to extract the Selling Price and Cost Price from the column and find the profit and loss and store it into a new DataFrame column.
To get the excel file used click here.
So, Let’s discuss the approach:
Step 1: Import the required module and read data from excel.
Python3
# importing module  import pandas as pd;  # Creating df# Reading data from Exceldata = pd.read_excel("excel_work/book_sample.xlsx");  print("Original DataFrame")data
Output :
Step 2: Create a new column in DataFrame for store Profit and Loss
Python3
# Create column for profit and lossdata['Profit']= Nonedata['Loss']= None  data
Output :
Step 3: Set Index for Selling price, Cost price, Profit, and loss for accessing the DataFrame columns
Python3
# set indexindex_selling = data.columns.get_loc('Selling Price')index_cost = data.columns.get_loc('Cost price')index_profit = data.columns.get_loc('Profit')index_loss = data.columns.get_loc('Loss')  print(index_selling, index_cost, index_profit, index_loss)
Output :
2 3 4 5

Step 4: Compute profit and loss according to there each column index.
Profit = Selling price - Cost price
Loss = Cost price - Selling price
Python3
# Loop for accessing every index in DataFrame# and compute Profit and loss# and store into new column in DataFramefor row in range(0, len(data)):    if data.iat[row, index_selling] > data.iat[row, index_cost]:        data.iat[row, index_profit] = data.iat[row,                                               index_selling] - data.iat[row, index_cost]    else:        data.iat[row, index_loss] = data.iat[row,                                             index_cost]-data.iat[row, index_selling]data
Output :
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Selecting rows in pandas DataFrame based on conditions
Python | Get unique values from a list
Create a directory in Python
Python | Pandas dataframe.groupby()
How to read a text file with C++?

This is a C++ program to read a text file.
tpoint.txt is having initial content as
“Tutorials point.”
Tutorials point.
Begin
   Create an object newfile against the class fstream.
   Call open() method to open a file “tpoint.txt” to perform write operation using object newfile.
   If file is open then
      Input a string “Tutorials point" in the tpoint.txt file.
      Close the file object newfile using close() method.
   Call open() method to open a file “tpoint.txt” to perform read operation using object newfile.
   If file is open then
      Declare a string “tp”.
      Read all data of file object newfile using getline() method and put it into the string tp.
      Print the data of string tp.
   Close the file object newfile using close() method.
End.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
   fstream newfile;
   newfile.open("tpoint.txt",ios::out);  // open a file to perform write operation using file object
   if(newfile.is_open()) //checking whether the file is open {
      newfile<<"Tutorials point \n"; //inserting text
      newfile.close(); //close the file object
   }
   newfile.open("tpoint.txt",ios::in); //open a file to perform read operation using file object
   if (newfile.is_open()){ //checking whether the file is open
      string tp;
      while(getline(newfile, tp)){ //read data from file object and put it into string.
         cout << tp << "\n"; //print the data of the string
      }
      newfile.close(); //close the file object.
   }
}
Tutorials point
CSS font-variant-ligatures Property - GeeksforGeeks

18 Sep, 2020
The CSS font-variant-ligatures property is used for controlling ligatures on a text’s font. A ligature is a special character that combines two or more characters into one. Ligatures are commonly used to give certain style or look to the text.
Syntax:
font-variant-ligatures: Keyword_values
Or
 font-variant-ligatures: Global_values 
Property values: This property accepts property values mentioned above and described below.
Keyword_values: This property value refers to the values defined by “normal”, “none”, “common-ligatures”, “no-common-ligatures”, “discretionary-ligatures”, “no-discretionary-ligatures”, “historical-ligatures”, “no-historical-ligatures”, “contextual”, “no-contextual”.
Global_values: This property value refers to the values defined by “inherit”, “initial”, “unset”.
Example 1: Below is the example that illustrates the use of font-variant-ligatures property using common-ligatures and no-common-ligatures.
HTML
<!DOCTYPE html><html lang="en">  <head>    <style>        div {            font-size: 5vw;        }          .off {            font-variant-ligatures: no-common-ligatures;            color: rgb(83, 241, 21);        }          .on {            font-variant-ligatures: common-ligatures;            color: rgb(96, 153, 4);        }    </style></head>  <body>    <h1 style="color: green;">GeeksforGeeks</h1>    <div>        <span class="off">wifi</span>        <span class="on">wifi</span>    </div></body>  </html>
Output:
Supported Browsers:
Chrome
Firefox
Safari
Opera
Edge
Internet Explorer (Not Supported).
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
Roadmap to Become a Web Developer in 2022
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?
Difference between var, let and const keywords in JavaScript
D3.js voronoi() Function - GeeksforGeeks

01 Oct, 2020
The d3.voronoi() function in D3.js is used to create a new Voronoi diagram layout with the default x and y accessors and a null extent. The Voronoi diagram is drawn using a set of data points that can be specified later.
Syntax:
d3.voronoi()

Parameters: This function does not accept any parameters.
The example below demonstrates the d3.voronoi() function:
Example:
HTML
<!DOCTYPE html><html><head>  <script src="https://d3js.org/d3.v4.min.js">  </script>  <script src="https://d3js.org/d3-voronoi.v1.min.js">  </script></head><body>  <h1 style="color:green">    GeeksforGeeks  </h1>    <script>          // Import the CSV data for    // specifying the Voronoi    d3.csv("data.csv",            function (error, data) {      var svg = d3.select("body")        .append("svg")        .attr("height", 400)        .attr("width", 400)        .append("g")        .attr("transform",              "translate(" + 20 +              "," + -20 + ")");        var y = d3.scaleLinear()        .domain([2, 20])        .range([400, 0]);      var x = d3.scaleLinear()        .domain([2, 15])        .range([0, 400]);      svg.append("g")        .call(d3.axisLeft(y));        svg.append("g")        .attr("transform",              "translate(0," + 400 + ")")        .call(d3.axisBottom(x));        // Using the d3.voronoi() function      // to create a Voronoi diagram      var voronoi = d3.voronoi()        .x(function (d) { return x(d.x); })        .y(function (d) { return y(d.y); })        .extent([[0, 0], [400, 400]]);        // Adding data to represent the Voronoi      // and displaying it      svg.append("g").selectAll("path")        .data(voronoi(data).polygons())        .enter()        .append("path")        .attr("d", (d) =>               { return d ?                 ("M" + d.join("L") +                 "Z") : null; })        .attr("fill", "green")        .attr("stroke", "black");    });  </script></body></html>
Output:
D3.js
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
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
What is Dynamic Polymorphism in C#?

Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.
Dynamic polymorphism is implemented by abstract classes and virtual functions. The following is an example showing an example of dynamic polymorphism −
 Live Demo
using System;

namespace PolymorphismApplication {
   class Shape {
      protected int width, height;

      public Shape( int a = 0, int b = 0) {
         width = a;
         height = b;
      }

      public virtual int area() {
         Console.WriteLine("Parent class area :");
         return 0;
      }
   }

   class Rectangle: Shape {
      public Rectangle( int a = 0, int b = 0): base(a, b) {}

      public override int area () {
         Console.WriteLine("Rectangle class area :");
         return (width * height);
      }
   }

   class Triangle: Shape {
      public Triangle(int a = 0, int b = 0): base(a, b) {}
      public override int area() {
         Console.WriteLine("Triangle class area :");
         return (width * height / 2);
      }
   }

   class Caller {
      public void CallArea(Shape sh) {
         int a;
         a = sh.area();
         Console.WriteLine("Area: {0}", a);
      }
   }

   class Tester {
      static void Main(string[] args) {
         Caller c = new Caller();
         Rectangle r = new Rectangle(10, 7);
         Triangle t = new Triangle(10, 5);

         c.CallArea(r);
         c.CallArea(t);
         Console.ReadKey();
      }
   }
}
Rectangle class area :
Area: 70
Triangle class area :
Area: 25
How to give dynamic height to UIlabel programmatically in swift?

To give a dynamic height to an UIlabel in swift we can use the frame property of UILabel. We can create a frame using the CGRect which allows us to give different variables like x position, y position, width, and height.
Let’s create a label and add it as a subview to our view.
let label = UILabel()
label.frame = CGRect(x: 10, y: 40, width: 200, height: 50)
label.backgroundColor = colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
label.textColor = colorLiteral(red: 0.05882352963, green: 0.180392161, blue: 0.2470588237, alpha: 1)
label.text = "Custom label"
self.view.addSubview(label)
We can embed this in a function as well, and create an extension too.
func makeLabel(atX x: Double, andY y: Double,width: Double, height: Double) -> UILabel {
   let label = UILabel()
   label.frame = CGRect(x: x, y: y, width: width, height: height)
   label.backgroundColor = colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
   label.textColor = colorLiteral(red: 0.05882352963, green: 0.180392161, blue: 0.2470588237, alpha: 1)
   label.text = "Custom label"
   return label
}
We can use it inside the view controller along with the previous code, and this is how it looks on the device.
self.view.addSubview(makeLabel(atX: 10, andY: 100, width: 250, height: 100))
Chrono in C++

In this section we will see what is the Chrono library in C++. This Chrono library is used for date and time. Timers and clocks are different in different systems. So if we want to improve time over precision we can use this library.
In this library, it provides precision-neutral concept, by separating the durations and point of time.
The duration objects are used to express time span by means of a count like minute, two hours or ten minutes. For example, 30 seconds is represented by a duration consisting of 30 ticks of unit of 1 seconds.
 Live Demo
#include <iostream>
#include <chrono>
using namespace std;
int main () {
   using namespace std::chrono;
   // chrono::milliseconds is an instantiation of std::chrono::duration
   milliseconds mili(1000);
   mili = mili*60;
   cout << "Duration : ";
   cout << mili.count() << " milliseconds.\n";
   cout << "Duration : ";
   cout << (mili.count() * milliseconds::period::num / milliseconds::period::den);
   cout << " seconds.\n";
}
Duration : 60000 milliseconds.
Duration : 60 seconds.
Class getTypeParameters() method in Java with Examples - GeeksforGeeks

27 Jan, 2022
The getTypeParameters() method of java.lang.Class class is used to get the type parameters of this entity. This entity can be a class, an array, an interface, etc. The method returns an array of TypeVariable objects representing the type variables.Syntax:  
public TypeVariable<Class<T>> getTypeParameters()
Parameter: This method does not accept any parameter.Return Value: This method returns an array of TypeVariable objects representing the type variables.Below programs demonstrate the getTypeParameters() method.Example 1: 
Java
// Java program to demonstrate getTypeParameters() method import java.util.*; public class Test {    public static void main(String[] args)        throws ClassNotFoundException    {         // returns the Class object for this class        Class myClass = Class.forName("Test");         System.out.println("Class represented by myClass: "                           + myClass.toString());         // Get the type parameters of myClass        // using getTypeParameters() method        System.out.println(            "TypeParameters of myClass: "            + Arrays.toString(                  myClass.getTypeParameters()));    }}
Class represented by myClass: class Test
TypeParameters of myClass: []
 
Example 2: 
Java
// Java program to demonstrate getTypeParameters() method import java.util.*; public class Test {     public static void main(String[] args)        throws ClassNotFoundException    {        // returns the Class object for this class        Class myClass = Class.forName("java.lang.Integer");         System.out.println("Class represented by myClass: "                           + myClass.toString());         // Get the type parameters of myClass        // using getTypeParameters() method        System.out.println(            "TypeParameters of myClass: "            + Arrays.toString(                  myClass.getTypeParameters()));    }}
Class represented by myClass: class java.lang.Integer
TypeParameters of myClass: []
 
Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#getTypeParameters– 
adnanirshad158
Java-Functions
Java-lang package
Java.lang.Class
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java
Python - turtle.clear() - GeeksforGeeks

17 Aug, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to delete the turtle’s drawings from the screen. Do not move state and position of the turtle as well as drawings of other turtles are not affected. It doesn’t require any argument.
Syntax : turtle.clear()Parameters : NoneReturns : Nothing
Below is the implementation of above method with some examples :
Example 1 :
# import packageimport turtle  # motionturtle.forward(100)turtle.right(90)turtle.forward(100)turtle.right(90)turtle.forward(100)  # clear the drawing# and remain turtle # as it isturtle.clear()
Output :
Example 2 :
# import packageimport turtle  # make a turtle object# and do some drawingt1 = turtle.Turtle()t1.up()t1.setpos(-100, 50)t1.down()t1.circle(50)  # make a turtle object# and do some drawingt2 = turtle.Turtle()t2.up()t2.setpos(50, 50)t2.down()t2.circle(50)  # make a turtle object# and do some drawingt3 = turtle.Turtle()t3.up()t3.setpos(50, -100)t3.down()t3.circle(50)  # make a turtle object# and do some drawingt4 = turtle.Turtle()t4.up()t4.setpos(-100, -100)t4.down()t4.circle(50)  # here we clear the work done by turtle # objects : t1 and t3 only but turtle # shape remain as it ist1.clear()t3.clear()
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()