code-rag-bench/online-tutorials huggingface dataset:
C++ Program to Evaluate an Expression using Stacks

For solving mathematical expression, we need prefix or postfix form. After converting infix to postfix, we need postfix evaluation algorithm to find the correct answer.
Here also we have to use the stack data structure to solve the postfix expressions.
From the postfix expression, when some operands are found, pushed them in the stack. When some operator is found, two items are popped from stack and then operation is performed in correct sequence. After that the result is also pushed in the stack for future use. After completing the whole expression, the final result is also stored in the stack top.
Input: Postfix expression: 53+62/*35*+
Output: The result is: 39
Input: Postfix expression to evaluate.
Output: Answer after evaluating postfix form.
Begin
   for each character ch in the postfix expression, do
      if ch is an operator , then
         a := pop first element from stack
         b := pop second element from the stack
         res := b a
         push res into the stack
      else if ch is an operand, then
         add ch into the stack
   done
   return element of stack top
End
#include<iostream>
#include<cmath>
#include<stack>
using namespace std;
float scanNum(char ch) {
   int value;
   value = ch;
   return float(value-'0');   //return float from character
}
int isOperator(char ch) {
   if(ch == '+'|| ch == '-'|| ch == '*'|| ch == '/' || ch == '^')
      return 1;    //character is an operator
   return -1;   //not an operator
}
int isOperand(char ch) {
   if(ch >= '0' && ch <= '9')
      return 1;   //character is an operand
   return -1;   //not an operand
}
float operation(int a, int b, char op) {
   //Perform operation
   if(op == '+')
      return b+a;
   else if(op == '-')
      return b-a;
   else if(op == '*')
      return b*a;
   else if(op == '/')
      return b/a;
   else if(op == '^')
      return pow(b,a); //find b^a
   else
      return INT_MIN; //return negative infinity
}
float postfixEval(string postfix) {
   int a, b;
   stack<float> stk;
   string::iterator it;
   for(it=postfix.begin(); it!=postfix.end(); it++) {
      //read elements and perform postfix evaluation
      if(isOperator(*it) != -1) {
         a = stk.top();
         stk.pop();
         b = stk.top();
         stk.pop();
         stk.push(operation(a, b, *it));
      }else if(isOperand(*it) > 0) {
         stk.push(scanNum(*it));
      }
   }
   return stk.top();
}
main() {
   string post = "53+62/*35*+";
   cout << "The result is: "<<postfixEval(post);
}
The result is: 39
How to create tabs with CSS and JavaScript?

To create tabs with CSS and JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>>
.tab {
   overflow: hidden;
   border: 2px solid gray;
   background-color: #FFE4C4;
}
.tab button {
   background-color: inherit;
   float: left;
   cursor: pointer;
   padding: 14px 16px;
   font-size: 15px;
}
.tab button:hover {
   background-color: gray;
}
.tab button.active {
   background-color: #ccc;
}
.demo2 {
   display: none;
   padding: 3px 12px;
}
</style>
</head>
<body>
<h2>Examination</h2>
<p>Following is the exam information:</p>
<div class="tab">
<button class="demo" onclick="infofunc(event, 'dates')">Exam Dates</button>
<button class="demo" onclick="infofunc(event, 'centre')">Exam Centre</button>
</div>
<div id="dates" class="demo2">
<h3>Dates</h3>
<p>Exam date will be announced on 25th March.</p>
</div>
<div id="centre" class="demo2">
<h3>Centre</h3>
<p>Exam Centre will be announced on 30th March.</p>
</div>
<script>
function infofunc(e, info) {
   var i, content, links;
   content = document.getElementsByClassName("demo2");
   for (i = 0; i < content.length; i++) {
      content[i].style.display = "none";
   }
   links = document.getElementsByClassName("demo");
   for (i = 0; i < links.length; i++) {
      links[i].className = links[i].className.replace(" active", "");
   }
   document.getElementById(info).style.display = "block";
   e.currentTarget.className += " active";
}
</script>
</body>
</html>
This will produce the following output −
Now, click any of the tab to get the following −
Double forking to prevent Zombie process - GeeksforGeeks

30 May, 2017
We have discussed Three methods of Zombie Prevention. This article is about one more method of zombie prevention.
Zombie Process: A process which has finished the execution but still has entry in the process table to report to its parent process is known as a zombie process. A child process always first becomes a zombie before being removed from the process table.
How Creating a Grandchild / Double Forking helps?
The parent calls wait and creates a child. The child creates a grandchild and exits.The grandchild executes its instruction(task) and eventually it terminates. As the child has already exited, the grandchild will be taken care by init process.Init collect the exit status of grandchild. Hence the grandchild is not a zombie.
The parent calls wait and creates a child. The child creates a grandchild and exits.
The grandchild executes its instruction(task) and eventually it terminates. As the child has already exited, the grandchild will be taken care by init process.
Init collect the exit status of grandchild. Hence the grandchild is not a zombie.
Note: Child is not a zombie as the parent called wait. Also in this case, the parent cannot verify the exit status of grandchild.
// C program of zombie prevention by// creating grandchild or double forking#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <sys/wait.h>  int main(){    pid_t pid;      // fork first time    pid = fork();      if (pid == 0)    {        // double fork        pid = fork();        if (pid == 0)            printf("Grandchild pid : %d\n Child"               " pid : %d\n", getpid(), getppid());    }      else    {        wait(NULL);        sleep(10);    }}
This article is contributed by Pramod Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Processes & Threads
system-programming
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to dynamically allocate a 2D array in C?
Double Pointer (Pointer to Pointer) in C
Generating random number in a range in C
fgets() and gets() in C language
Exception Handling in C++
Input-output system calls in C | Create, Open, Close, Read, Write
snprintf() in C library
Arrow operator -> in C/C++ with Examples
Basics of File Handling in C
Wait System Call in C
Java program to find the permutation when the values n and r are given

Permutation refers a number of ways in which set members can be arranged or ordered in some fashion. The formula of permutation of arranging k elements out of n elements is −
nPk = n! / (n - k)!
1. Define values for n and r.
2. Calculate factorial of n and (n-r).
3. Divide factorial(n) by factorial(n-r).
4. Display result as a permutation.
import java.util.Scanner;

public class Permutation {
   static int factorial(int n) {
      int f;

      for(f = 1; n > 1; n--){
         f *= n;
      }
      return f;
   }
   static int npr(int n,int r) {
      return factorial(n)/factorial(n-r);
   }
   public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the value of n :");
      int n = sc.nextInt();
      System.out.println("Enter the value of r :");
      int r = sc.nextInt();
      System.out.println("npr value is ::"+npr(n,r));
   }
}
Enter the value of n :
4
Enter the value of r :
3
npr value is ::24
ASCII NUL, ASCII 0 (‘0’) and Numeric literal 0?

Here we will see the ASCII NUL, ASCII 0 and the Numeric Literal 0. The ASCII null is represented as 0x00, and zero is represented as 0x30. The ASCII NUL character is used to denote the end of the string in C or C++. When programmer used ‘0’ (character 0) it is treated as 0x30. This is a hexadecimal number. The decimal equivalent is 48. To put ASCII NUL we have to mention ‘\0’ instead of ‘0’.
char asciiNul = ‘\0’;
int zero = 0;
char zeroChar = ‘0’;
The first one is ASCII NUL, second one is numeric 0, and the third one is character 0.
Python Pandas - Convert Timestamp to another time zone

Convert Timestamp to another time zone, use the timestamp.tz_convert(). Set the time zone as the parameter. At first, import the required libraries −
import pandas as pd
Create the timestamp object in Pandas. We have also set the timezone
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')

Convert timezone of timestamp
timestamp.tz_convert('Australia/Brisbane'))
Following is the code
import pandas as pd

# set the timestamp object in Pandas
# we have also set the timezone
timestamp = pd.Timestamp('2021-10-14T15:12:34.261811624', tz='US/Eastern')

# display the Timestamp
print("Timestamp...\n", timestamp)

# convert timezone
print("\nConvert the Timestamp timezone...\n",
timestamp.tz_convert('Australia/Brisbane'))
This will produce the following code
Timestamp...
 2021-10-14 15:12:34.261811624-04:00

Convert the Timestamp timezone...
 2021-10-15 05:12:34.261811624+10:00
Finding next prime number to a given number using JavaScript

We are required to write a JavaScript function that takes in a number n. Our function should that smallest number which is just greater than n and is a prime number.
Following is the code −
 Live Demo
const num = 101;
const isPrime = (num) => {
   let sqrtnum = Math.floor(Math.sqrt(num));
   let prime = num !== 1;
   for(let i = 2; i < sqrtnum + 1; i++){
      if(num % i === 0){
         prime = false;
         break;
      };
   };
   return prime;
}
const nextPrime = (num = 1) => {
   while(!isPrime(++num)){
   };
   return num;
};
console.log(nextPrime(num));
103
Convert an Object to Data Frame in R Programming - as.data.frame() Function - GeeksforGeeks

22 Nov, 2021
as.data.frame() function in R Programming Language is used to convert an object to data frame. These objects can be Vectors, Lists, Matrices, and Factors.
Syntax: as.data.frame(object)
Parameters: 
object: Vector, Matrix, factor, or data frame
R
# R program to convert object to data frame # Creating Vectorsx1 <- c(1, 2, 3, 4)x2 <- c("a", "B", "C", "D")x3 <- c("hello", "Geeks", "for", "geeks") # Creating list of vectorsx <- list(col1 = x1, col2 = x2, col2 = x3)x # Converting list to data frameas.data.frame(x)
Output: 
$col1
[1] 1 2 3 4

$col2
[1] "a" "B" "C" "D"

$col2
[1] "hello" "Geeks" "for"   "geeks"

  col1 col2 col2.1
1    1    a  hello
2    2    B  Geeks
3    3    C    for
4    4    D  geeks
Example 2: 
R
# R program to convert object to list # Converting pre-defined dataset to listx < - as.list(BOD)x # Converting list to data frameas.data.frame(x)
Output: 
$Time
[1] 1 2 3 4 5 7

$demand
[1]  8.3 10.3 19.0 16.0 15.6 19.8

attr(, "reference")
[1] "A1.4, p. 270"
  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
kumar_satyam
R DataFrame-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
Remove rows with NA in one column of R DataFrame
K-Means Clustering in R Programming
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Comparing two Pandas series and printing the the difference

In this program, we will compare two Pandas series and will print the differences in the series. By difference, we mean that the index positions at which the elements did not match.
Step 1: Define two Pandas series, s1 and s2.
Step 2: Compare the series using compare() function in the Pandas series.
Step 3: Print their difference.
import pandas as pd

s1 = pd.Series([10,20,30,40,50,60])
s2 = pd.Series([10,30,30,40,55,60])

print("S1:\n", s1)
print("\nS2:\n", s2)

difference = s1.compare(s2)
print("\nDifference between the series: \n",difference)
S1:
0    10
1    20
2    30
3    40
4    50
5    60
dtype: int64

S2:
0    10
1    30
2    30
3    40
4    55
5    60
dtype: int64

Difference between the series:
    self  other
1  20.0   30.0
4  50.0   55.0
In the above output, there are two columns in the difference output. One is 'self' and beside it is 'other'. The self refers to s1 series whereas the 'other' refers to s2 series.
Program to check whether list is strictly increasing or strictly decreasing in Python

Suppose we have a list of numbers; we have to check whether the list is strictly increasing or strictly decreasing.
So, if the input is like nums = [10, 12, 23, 34, 55], then the output will be True, as all elements are distinct and each element is larger than the previous one, so this is strictly increasing.
To solve this, we will follow these steps −
if size of nums <= 2, thenreturn True
return True
if all elements in num is not distinct, thenreturn False
return False
ordered := sort the list nums
return true when nums is same as ordered or nums is same as ordered in reverse way, otherwise false.
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, nums):
      if len(nums) <= 2:
         return True
      if len(set(nums)) != len(nums):
         return False
      ordered = sorted(nums)
      return nums == ordered or nums == ordered[::-1]
ob = Solution()
print(ob.solve([10, 12, 23, 34, 55]))
[10, 12, 23, 34, 55]
True
Kubernetes - Node

A node is a working machine in Kubernetes cluster which is also known as a minion. They are working units which can be physical, VM, or a cloud instance.
Each node has all the required configuration required to run a pod on it such as the proxy service and kubelet service along with the Docker, which is used to run the Docker containers on the pod created on the node.
They are not created by Kubernetes but they are created externally either by the cloud service provider or the Kubernetes cluster manager on physical or VM machines.
The key component of Kubernetes to handle multiple nodes is the controller manager, which runs multiple kind of controllers to manage nodes. To manage nodes, Kubernetes creates an object of kind node which will validate that the object which is created is a valid node.
apiVersion: v1
kind: node
metadata:
   name: < ip address of the node>
   labels:
      name: <lable name>

In JSON format the actual object is created which looks as follows −
{
   Kind: node
   apiVersion: v1
   "metadata": 
   {
      "name": "10.01.1.10",
      "labels"
      {
         "name": "cluster 1 node"
      }
   }
}

They are the collection of services which run in the Kubernetes master and continuously monitor the node in the cluster on the basis of metadata.name. If all the required services are running, then the node is validated and a newly created pod will be assigned to that node by the controller. If it is not valid, then the master will not assign any pod to it and will wait until it becomes valid.
Kubernetes master registers the node automatically, if –register-node flag is true.
–register-node = true

However, if the cluster administrator wants to manage it manually then it could be done by turning the flat of −
–register-node = false


    41 Lectures 
     5 hours 

 AR Shankar

    15 Lectures 
     2 hours 

 Harshit Srivastava, Pranjal Srivastava

    18 Lectures 
     1.5 hours 

 Nigel Poulton

    25 Lectures 
     1.5 hours 

 Pranjal Srivastava

    18 Lectures 
     1 hours 

 Pranjal Srivastava

    26 Lectures 
     1.5 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Java program to find largest of the three numbers using ternary operators

The conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide, which value should be assigned to the variable. The operator is written as −
variable x = (expression) ? value if true : value if false
Live Demo
public class LargestOf3Nums_TernaryOperator {
   public static void main(String args[]) {
      int a, b, c, temp, result;
      a = 10;
      b = 20;
      c = 30;

      temp = a < b ? a:b;
      result = c < temp ? c:temp;
      System.out.println("Largest number is ::"+result);
   }
}
Largest number is ::30
Python - Words Frequency in String Shorthands - GeeksforGeeks

26 May, 2020
Sometimes while working with Python strings, we can have problem in which we need to extract frequency of all the words in string. This problem has been solved earlier. This discusses the shorthands to solve this problem as this has application in many domains ranging from web development and competitive programming. Let’s discuss certain ways in which this problem can be solved.
Input : test_str = ‘Gfg is best’Output : {‘Gfg’: 1, ‘is’: 1, ‘best’: 1}
Input : test_str = ‘Gfg Gfg Gfg’Output : {‘Gfg’: 3}
Method #1 : Using dictionary comprehension + count() + split()The combination of above functions can be used to solve this problem. In this, we first split all the words and then perform count of them using count().
# Python3 code to demonstrate working of # Words Frequency in String Shorthands# Using dictionary comprehension + count() + split()  # initializing stringtest_str = 'Gfg is best . Geeks are good and Geeks like Gfg'  # printing original stringprint("The original string is : " + str(test_str))  # Words Frequency in String Shorthands# Using dictionary comprehension + count() + split()res = {key: test_str.count(key) for key in test_str.split()}  # printing result print("The words frequency : " + str(res)) 
The original string is : Gfg is best . Geeks are good and Geeks like GfgThe words frequency : {‘Gfg’: 2, ‘is’: 1, ‘best’: 1, ‘.’: 1, ‘Geeks’: 2, ‘are’: 1, ‘good’: 1, ‘and’: 1, ‘like’: 1}
 
Method #2 : Using Counter() + split()The combination of above methods can also be used to solve this problem. In this, we perform the task of counting using Counter() and separation of words using split().
# Python3 code to demonstrate working of # Words Frequency in String Shorthands# Using Counter() + split()from collections import Counter  # initializing stringtest_str = 'Gfg is best . Geeks are good and Geeks like Gfg'  # printing original stringprint("The original string is : " + str(test_str))  # Words Frequency in String Shorthands# Using Counter() + split()res = Counter(test_str.split())  # printing result print("The words frequency : " + str(dict(res))) 
The original string is : Gfg is best . Geeks are good and Geeks like GfgThe words frequency : {‘Gfg’: 2, ‘is’: 1, ‘best’: 1, ‘.’: 1, ‘Geeks’: 2, ‘are’: 1, ‘good’: 1, ‘and’: 1, ‘like’: 1}
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python - Remove duplicate values in dictionary - GeeksforGeeks

08 May, 2020
Sometimes, while working with Python dictionaries, we can have problem in which we need to perform the removal of all the duplicate values of dictionary, and we are not concerned if any key get removed in the process. This kind of application can occur in school programming and day-day programming. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loopThis is the brute force way in which we perform this task. In this, we keep track of occurred value, and remove it if it repeats.
# Python3 code to demonstrate working of # Remove duplicate values in dictionary# Using loop  # initializing dictionarytest_dict = { 'gfg' : 10, 'is' : 15, 'best' : 20, 'for' : 10, 'geeks' : 20}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Remove duplicate values in dictionary# Using looptemp = []res = dict()for key, val in test_dict.items():    if val not in temp:        temp.append(val)        res[key] = val  # printing result print("The dictionary after values removal : " + str(res)) 
The original dictionary is : {‘gfg’: 10, ‘for’: 10, ‘geeks’: 20, ‘is’: 15, ‘best’: 20}The dictionary after values removal : {‘gfg’: 10, ‘geeks’: 20, ‘is’: 15}
 
Method #2 : Using dictionary comprehensionThe following problem can also be performed using dictionary comprehension. In this, we perform task in similar way as above method, just as a shorthand.
# Python3 code to demonstrate working of # Remove duplicate values in dictionary# Using dictionary comprehension  # initializing dictionarytest_dict = { 'gfg' : 10, 'is' : 15, 'best' : 20, 'for' : 10, 'geeks' : 20}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Remove duplicate values in dictionary# Using dictionary comprehensiontemp = {val : key for key, val in test_dict.items()}res = {val : key for key, val in temp.items()}  # printing result print("The dictionary after values removal : " + str(res)) 
The original dictionary is : {‘gfg’: 10, ‘for’: 10, ‘geeks’: 20, ‘is’: 15, ‘best’: 20}The dictionary after values removal : {‘gfg’: 10, ‘geeks’: 20, ‘is’: 15}
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
Minimize Max Distance to Gas Station in C++

Suppose we have one horizontal number line. On that number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = size of the stations array. Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized. We have to find the smallest possible value of D.
So, if the input is like stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9, then the output will be 0.5
To solve this, we will follow these steps −
Define a function ok(), this will take x, array v,
Define a function ok(), this will take x, array v,
ret := 0
ret := 0
for initialize i := 0, when i < size of v, update (increase i by 1), do −ret := ret + ceiling of (v[i + 1] - v[i]) / x
for initialize i := 0, when i < size of v, update (increase i by 1), do −
ret := ret + ceiling of (v[i + 1] - v[i]) / x
ret := ret + ceiling of (v[i + 1] - v[i]) / x
return ret
return ret
From the main method do the following −
From the main method do the following −
low := 0
low := 0
n := size of s
n := size of s
high := s[n - 1] - s[0]
high := s[n - 1] - s[0]
while high - low >= 1e-6, do −mid := (low + high) / 2.0x := ok(mid, s)if x > K, then −low := midOtherwisehigh := mid
while high - low >= 1e-6, do −
mid := (low + high) / 2.0
mid := (low + high) / 2.0
x := ok(mid, s)
x := ok(mid, s)
if x > K, then −low := mid
if x > K, then −
low := mid
low := mid
Otherwisehigh := mid
Otherwise
high := mid
high := mid
return high
return high
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   int ok(double x, vector <int>& v){
      int ret = 0;
      for (int i = 0; i < v.size() - 1; i++) {
         ret += ceil((v[i + 1] - v[i]) / x) - 1;
      }
      return ret;
   }
   double minmaxGasDist(vector<int>& s, int K) {
      double low = 0;
      int n = s.size();
      double high = s[n - 1] - s[0];
      while (high - low >= 1e-6) {
         double mid = (low + high) / 2.0;
         int x = ok(mid, s);
         if (x > K) {
            low = mid;
         }
         else {
            high = mid;
         }
      }
      return high;
   }
};
main(){
   Solution ob;
   vector<int> v = {1,2,3,4,5,6,7,8,9,10};
   cout << (ob.minmaxGasDist(v, 9));
}
{1,2,3,4,5,6,7,8,9,10}, 9
0.5
Python issubclass()

23 Jan, 2020
We know that inheritance is one of the building blocks of Object-Oriented Programming concept. It is the capability of one class to derive or inherit the properties from some other class. It also provides the reusability of code. We don’t have to write the same code again and again. Also, it allows us to add more features to a class without modifying it.
Refer to the below articles to get the idea about OOPs and Inheritance in Python.
Object Oriented Programming in Python
Inheritance in Python
Python issubclass() is built-in function used to check if a class is a subclass of another class or not. This function returns True if the given class is the subclass of given class else it returns False.
Syntax: issubclass(object, classinfo)
Parameters:Object: class to be checkedclassinfo: class, types or a tuple of classes and types
Return Type: True if object is subclass of a class, or any element of the tuple, otherwise False.
Example:
# Python program to demonstrate# issubclass()    # Defining Parent classclass Vehicles:      # Constructor    def __init__(vehicleType):        print('Vehicles is a ', vehicleType)  # Defining Child classclass Car(Vehicles):      # Constructor    def __init__(self):        Vehicles.__init__('Car')  # Driver's code   print(issubclass(Car, Vehicles))print(issubclass(Car, list))print(issubclass(Car, Car))print(issubclass(Car, (list, Vehicles)))
Output:
True
False
True
True

Note: Don’t get confused between isinstance() and issubclass() as both these method are quite similar. However, the name itself explain the differences. isinstance() checks whether or not the object is an instance or subclass of the classinfo. Whereas, issubclass() only check whether it is a subclass of classinfo or not (not check for object relation).
python-inheritance
Python-OOP
python-oop-concepts
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream flatMapToDouble() in Java with examples

06 Dec, 2018
Stream flatMapToDouble(Function mapper) returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Stream flatMapToDouble(Function mapper) is an intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.
Note : Each mapped stream is closed after its contents have been placed into this stream. If a mapped stream is null, an empty stream is used, instead.Syntax :
DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper)

Where, DoubleStream is a sequence of primitive
double-valued elements and T is the type 
of stream elements. mapper is a stateless function 
which is applied to each element and the function
returns the new stream.

Example 1 : flatMapToDouble() function with operation of parsing string to double.
// Java code for Stream flatMapToDouble// (Function mapper) to get an DoubleStream// consisting of the results of replacing// each element of this stream with the// contents of a mapped stream.import java.util.*;import java.util.stream.DoubleStream;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a list of Strings        List<String> list = Arrays.asList("1.5", "2.7", "3",                                                "4", "5.6");          // Using Stream flatMapToDouble(Function mapper)        list.stream().flatMapToDouble(num         -> DoubleStream.of(Double.parseDouble(num)))        .forEach(System.out::println);    }}
Output :
1.5
2.7
3.0
4.0
5.6

Example 2 : flatMapToDouble() function with operation of returning stream with length of strings.
// Java code for Stream flatMapToDouble// (Function mapper) to get an DoubleStream// consisting of the results of replacing// each element of this stream with the// contents of a mapped stream.import java.util.*;import java.util.stream.DoubleStream;  class GFG {      // Driver code    public static void main(String[] args)    {          // Creating a List of Strings        List<String> list = Arrays.asList("Geeks", "GFG",                                 "GeeksforGeeks", "gfg");          // Using Stream flatMapToDouble(Function mapper)        // to get length of all strings present in list        list.stream().flatMapToDouble(str         -> DoubleStream.of(str.length()))        .forEach(System.out::println);    }}
Output :
5.0
3.0
13.0
3.0

Java - util package
Java-Functions
java-intstream
java-stream
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Collections in Java
Multidimensional Arrays in Java
Set in Java
Singleton Class in Java
Initializing a List in Java
Tailwind CSS Background Clip

23 Mar, 2022
This class accepts more than one value in tailwind CSS in which all the properties are covered in class form. It is the alternative to the CSS background-clip property. This property is used to define how to extend background (color or image) within an element.
Background Clip Classes:
bg-clip-border: This class is used to set the background color spread over the whole division.
bg-clip-padding: This class is used to set the background inside the border.
bg-clip-content: This class is used to set the background color to the content only.
bg-clip-text: This class is used to crop an element’s background to match the shape of the text. Useful for effects where you want a background image to be visible through the text.
Syntax:
<element class="bg-clip-{Clip type}">...</element>
Example:
HTML
<!DOCTYPE html> <head>     <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"           rel="stylesheet"> </head>   <body class="text-center mx-4 space-y-2">     <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS     <span class="bg-clip-text text-lg text-transparent                  bg-gradient-to-r                 from-green-400 to-blue-500">        Background Clip Class        </span>    </b>     <div class="mx-2 grid grid-cols-3 gap-2 bg-green-200 rounded-lg">        <div class="bg-clip-border p-6 bg-green-600 border-dashed                    border-4 border-green-300">        </div>        <div class="bg-clip-padding p-6 bg-green-600 border-dashed                    border-4 border-green-300">                      </div>        <div class="bg-clip-content p-6 bg-green-600 border-dashed                    border-4 border-green-300">                      </div>    </div></body>   </html> 
Output:
Tailwind CSS
Tailwind-Background
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

07 Jan, 2022
Equal Operator ==
The comparison operator called Equal Operator is the double equal sign “==”. This operator accepts two inputs to compare and returns true value if both of the values are same (It compares only value of variable, not data types) and return a false value if both of the values are not same. This should always be kept in mind that the present equality operator == is different from the assignment operator =. The assignment operator changes and assigns the variable on the left to have a new value as the variable on right, while the equal operator == tests for equality and returns true or false as per the comparison results.Example:  
php
<?php // Variable contains integer value$x = 999; // Variable contains string value$y = '999'; // Compare $x and $yif ($x == $y)    echo 'Same content';else    echo 'Different content';?>
Same content
 
Identical Operator ===
The comparison operator called as the Identical operator is the triple equal sign “===”. This operator allows for a much stricter comparison between the given variables or values. This operator returns true if both variable contains same information and same data types otherwise return false.Example:  
php
<?php // Variable contains integer value$x = 999; // Variable contains string value$y = '999'; // Compare $x and $yif ($x === $y)    echo 'Data type and value both are same';else    echo 'Data type or value are different';?>
Data type or value are different
 
In the above example, value of $x and $y are equal but data types are different so else part will execute. 
varshagumber28
PHP-Operators
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
set_script_timeout driver method – Selenium Python

15 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc.
This article revolves around set_script_timeout driver method in Selenium. set_script_timeout method sets the amount of time that the script should wait during an execute_async_script call before throwing an error.
Syntax –
driver.set_script_timeout(time_To_wait)
Example –Now one can use set_script_timeout method as a driver method as below –
diver.get("https://www.geeksforgeeks.org/")
driver.set_script_timeout(30)

To demonstrate, set_script_timeout method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object.
Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # sets timeout to 30driver.set_script_timeout(30)
Output –Browser –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Input Output Systems in Operating Systems - GeeksQuiz

03 Oct, 2019

. Interrupt from CPU temperature sensor (raises interrupt if 
  CPU temperature is too high)
. Interrupt from Mouse(raises interrupt if the mouse is moved 
  or a button is pressed)
. Interrupt from Keyboard(raises interrupt when a key is 
  pressed or released)
. Interrupt from Hard Disk(raises interrupt when a disk 
  read is completed)
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
HTML | <ul> type Attribute

21 Mar, 2022
The HTML <ul> type Attribute is used to specifies that which kind of marker used in the list.Note: The ul type attributes are not supported by HTML 5. Instead of using this attribute we can use CSS list-style-type Property.Syntax:
<ul type="disc | circle | square">
Attribute Values:
disc: Default. A filled circle.
circle: An unfilled circle
square A filled square.
Example 1: 
html
<!DOCTYPE html><html> <head>    <title>HTML ul type attribute</title></head> <body>    <h1>GeeksforGeeks</h1>         <h2>HTML ul type attribute</h2>           <p>GeeksforGeeks courses List:</p>       <ul>        <li>Geeks</li>        <li>Sudo</li>        <li>Gfg</li>        <li>Gate</li>        <li>Placement</li>    </ul></body> </html>                    
Output:
Example 2: 
html
<!DOCTYPE html><html> <head>    <title>HTML ul type attribute</title></head> <body>    <h1>GeeksforGeeks</h1>         <h2>HTML ul type attribute</h2>           <p>GeeksforGeeks courses List:</p>       <ul type="square">        <li>Geeks</li>        <li>Sudo</li>        <li>Gfg</li>        <li>Gate</li>        <li>Placement</li>    </ul></body> </html>                    
Output:
Supported Browsers: The browser supported by HTML <ul> Type attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
 
arorakashish0911
hritikbhatnagar2182
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operators in C - GeeksQuiz

12 Oct, 2021
#include "stdio.h"

int main() 

{ 

  int x, y = 5, z = 5; 

  x = y == z; 

  printf("%d", x); 

  

  getchar(); 

  return 0; 

}
0 
1 
5 
Compiler Error 
The crux of the question lies in the statement x = y==z. The operator == is executed before = because precedence of comparison operators (<=, >= and ==) is higher than assignment operator =. The result of a comparison operator is either 0 or 1 based on the comparison result. Since y is equal to z, value of the expression y == z becomes 1 and the value is assigned to x via the assignment operator. 
 

#include <stdio.h>

int main()
{
    int i = 1, 2, 3;
    
    printf("%d", i);
    
    return 0;
}



#include <stdio.h>

int main()
{
    int i = (1, 2, 3);
    
    printf("%d", i);
    
    return 0;
}


 
#include <stdio.h>

int main()
{
    int i;
    
    i = 1, 2, 3;
    printf("%d", i);
    
    return 0;
}

C
What is the output of the above program? 
3 
4 
5 
Compile-time error 
In C, prefix and postfix operators need l-value to perform operation and return r-value. The expression (++i)++ when executed increments the value of variable i(i is a l-value) and returns r-value. The compiler generates the error(l-value required) when it tries to post-incremeny the value of a r-value. 
   // Since a is 1, the expression --b 
   // is not executed because
   // of the short-circuit property 
   // of logical or operator
   // So c becomes 1, a and b remain 1
   int c = a || --b;

   // The post decrement operator -- 
   // returns the old value in current expression 
   // and then updates the value. So the 
   // value of expression a-- is 1.  Since the 
   // first operand of logical and is 1, 
   // shortcircuiting doesn't happen here.  So 
   // the expression --b is executed and --b 
   // returns 0 because it is pre-increment.
   // The values of a and b become 0, and 
   // the value of d also becomes 0.
   int d = a-- && --b;

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
Hash Functions and list/types of Hash functions
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
Nested Structure in C with Examples
Python Data Structures and Algorithms
Java static Keyword

❮ Java Keywords

A static method can be 
accessed without creating an object of the class first:
public class Main {
  // Static method
  static void myStaticMethod() {
    System.out.println("Static methods can be called without creating objects");
  }

  // Public method
  public void myPublicMethod() {
    System.out.println("Public methods must be called by creating objects");
  }

  // Main method
  public static void main(String[ ] args) {
    myStaticMethod(); // Call the static method
    // myPublicMethod(); This would output an error

    Main myObj = new Main(); // Create an object of Main
    myObj.myPublicMethod(); // Call the public method
  }
}


Try it Yourself »

The static keyword is a non-access modifier used for methods and attributes. Static methods/attributes can be accessed without creating an object of a class.
Read more about modifiers in our Java Modifiers Tutorial.

❮ Java Keywords

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
AtomicReference setOpaque() method in Java with Examples - GeeksforGeeks

27 Dec, 2019
The setOpaque() method of a AtomicReference class is used to set the value of this AtomicReference object with memory effects as specified by VarHandle.setOpaque(java.lang.Object...). In this way value is set in program order, but with no assurance of memory ordering effects with respect to other threads.
Syntax:
public final void setOpaque(V newValue)

Parameters: This method accepts newValue which is the new value to set.
Return value: This method returns nothing.
Below programs illustrate the setOpaque() method:Program 1:
// Java program to demonstrate// AtomicReference.setOpaque() methodimport java.util.concurrent.atomic.AtomicReference;  public class GFG {    public static void main(String[] args)    {          // create an atomic reference object.        AtomicReference<Float> ref            = new AtomicReference<Float>();          // set some value using setOpaque method        ref.setOpaque((float)9999.79);          // print value        System.out.println("value = " + ref.get());    }}
Program 2:
// Java program to demonstrate// AtomicReference.setOpaque() methodimport java.util.concurrent.atomic.AtomicReference;  public class GFG {    public static void main(String[] args)    {          // create an atomic reference object        AtomicReference<String> ref            = new AtomicReference<String>();          // set some value using setOpaque()        ref.setOpaque("CP Algos");          // print value        System.out.println("Algo = " + ref.get());    }}
References: https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/atomic/AtomicReference.html#setOpaque(V)
Java-Functions
Java-util-concurrent-atomic package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
Difference between Abstract Class and Interface in Java
How to remove an element from ArrayList in Java?
Vertical Text, with Horizontal Letters in CSS

By specifying text-orientation: upright and writing-mode: vertical-rl, we can display vertical text with horizontal CSS.
The syntax of CSS writing-mode and text-orientation property is as follows −
Selector {
   writing-mode: /*value*/
   text-orientation: /*value*/
}
The following examples illustrate CSS outline-offset property.
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         h4 {
            text-orientation: upright;
            writing-mode: vertical-rl;
            line-height: 3;
            box-shadow: inset 0 0 3px khaki;
         }
      </style>
   </head>
   <body>
      <h4>Sed nec tortor</h4>
   </body>
</html>
This gives the following output
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         body {
            display: flex;
            flex: 1;
         }
         p {
            text-orientation: upright;
            writing-mode: vertical-rl;
            line-height: 3;
            box-shadow: inset 0 0 13px orange;
         }
      </style>
   </head>
   <body>
      <p>One</p>
      <p>Two</p>
      <p>Three</p>
      <p>Four</p>
   </body>
</html>
This gives the following output
C# Program to find the largest element from an array using Lambda Expressions

Declare an array −
int[] arr = { 10, 90, 20, 19, 99, 57 };
Now to get the largest element from an array, use Max() method with lambda expressions −
arr.Max());
Here is the complete code −
 Live Demo
using System;
using System.Linq;
class Demo {
   static void Main() {
      int[] arr = { 10, 90, 20, 19, 99, 57 };
      Console.WriteLine(arr.Max(element => Math.Abs(element)));
   }
}
99
Why is the compiler not reading string after integer in C programming?

Compiler not reading the string after integer in C programming? How can we solve this problem?
When you enter an integer number and press enter to read next value, compiler stores null into the string’s first char and string input terminates. Because scanf will terminate whenever it reads a null character.
When we are trying to read string or character after int or float, we should read a temporary char which is present in the input buffer.
The following is the program without errors −
 Live Demo
#include <stdio.h>
struct student{
   char name[10];
   int roll;
   char temp;
} s;
int main(){
   printf("Enter information of students:\n");
   printf("\nEnter roll number: ");
   scanf("%d", &s.roll);
   scanf("%c",&s.temp); //read temporary character
   printf("\nEnter name: ");
   gets(s.name);
   printf("\nDisplaying Information of students:\n");
   printf("\nRoll number: %d\t", s.roll);
   printf("\nname:%s\t", s.name);
   return 0;
}
Enter information of students:
Enter roll number: 3
Enter name: tutorialspoint
Displaying Information of students:
Roll number: 29806
name:tutorialspoint