code-rag-bench/online-tutorials huggingface dataset:
Difference Between List and Set in Java - GeeksforGeeks

28 Jan, 2021
The List interface allows storing the ordered collection. It is a child interface of Collection. It is an ordered collection of objects in which duplicate values are allowed to store. List preserves the insertion order, it allows positional access and insertion of elements.
Declaration:
public abstract interface List extends Collection
The set interface in the java.util package and extends Collection interface is an unordered collection of objects in which duplicate values cannot be stored. It is an interface that implements the maths set. This interface contains the methods inherited from the Collection interface and adds a feature that restricts to insert the duplicate elements. 
Declaration: The Set interface is declared as:
public interface Set extends Collection
Example:
Input :  Add Elements = [1, 2, 3, 1]
Output:  Set = [1, 2, 3]
     List = [1, 2, 3, 1]

Input :  Add Elements = [a, b, d, b]
Output:  Set = [a, b, d]
     List = [a, b, d, b]
Below is the illustration of Set and List :
Java
// Implementation of List and Set in Javaimport java.io.*;import java.util.*;  class GFG {    public static void main(String[] args)    {        // List declaration        List<Integer> l = new ArrayList<>();        l.add(5);        l.add(6);        l.add(3);        l.add(5);        l.add(4);          // Set declaration        Set<Integer> s = new HashSet<>();        s.add(5);        s.add(6);        s.add(3);        s.add(5);        s.add(4);          // printing list        System.out.println("List = " + l);        // printing Set        System.out.println("Set = " + s);    }}
List = [5, 6, 3, 5, 4]
Set = [3, 4, 5, 6]
Difference between List and Set:
Java-Collections
java-list
java-set
Picked
Technical Scripter 2020
Difference Between
Java
Technical Scripter
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference Between Spark DataFrame and Pandas DataFrame
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java
What is volatile keyword in C++?

Here we will see what is the meaning of volatile qualifier in C++. The volatile qualifier is applied to a variable when we declare it. It is used to tell the compiler, that the value may change at any time. These are some properties of volatile.
The volatile keyword cannot remove the memory assignment.
It cannot cache the variables in register.
The value cannot change in order of assignment.
Let us see, how we can use the volatile keyword.
volatile int a;
int volatile a;
Here these two declarations are correct. Like other datatypes, we can use volatile pointers, structures, unions etc. The volatile structures and unions can be volatile itself, and their member variables can also be of type volatile.
The volatile is used in different places. For memory mapped peripheral registers, some global variables, that are accessed by some other functions or interrupt service routines, or in some multi-threaded applications, the volatile can be used.
int main (){
   int value;
   value++;
}
int main (){
   volatile int value;
   value++;
}
There are two blocks of code. In the first block the volatile keyword is not present. So for the first case, the variable will be copied from memory to CPU register, then the operations are performed. In the second case the volatile is present. So in this case the variable will not be copied from memory to registers.
GATE | GATE-CS-2014-(Set-3) | Question 65

29 Sep, 2021
The memory access time is 1 nanosecond for a read operation with a hit in cache, 5 nanoseconds for a read operation with a miss in cache, 2 nanoseconds for a write operation with a hit in cache and 10 nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. The cache hit-ratio is 0.9. The average memory access time (in nanoseconds) in executing the sequence of instructions is __________.(A) 1.26(B) 1.68(C) 2.46(D) 4.52Answer: (B)Explanation:
The question is to find the time taken for,
"100 fetch operation and 60 operand red operations and 40 memory
operand write operations"/"total number of instructions".

Total number of instructions= 100+60+40 =200

Time taken for 100 fetch operations(fetch =read)
= 100*((0.9*1)+(0.1*5)) // 1 corresponds to time taken for read 
                        // when there is cache hit

= 140 ns //0.9 is cache hit rate

Time taken for 60 read operations = 60*((0.9*1)+(0.1*5))
                                  = 84ns

Time taken for 40 write operations = 40*((0.9*2)+(0.1*10)) 
                                   = 112 ns

// Here 2 and 10 the time taken for write when there is cache 
// hit and no cahce hit respectively

So,the total time taken for 200 operations is = 140+84+112 
                                             = 336ns

Average time taken = time taken per operation = 336/200 
                                              = 1.68 ns 
Gate PYQs on Avg. Memory access time with Ashish Verma | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.6K subscribersGate PYQs on Avg. Memory access time with Ashish Verma | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0032:44 / 45:00•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=jVZeD59sfik" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2014-(Set-3)
GATE-GATE-CS-2014-(Set-3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | Marquee truespeed attribute

14 Jan, 2022
If the scrolldelay value less then 60 and truespeed mode is on then the value of scrolldelay is not effecting the scrolling. If the scrolldelay value more then 60 and truespeed mode is on then the truespeed is not effecting the scrolling. So, basically it is used to set scrollDelay attribute should be taken as an exact value or not.Syntax:  
<marquee truespeed="truespeed" >
Attribute value: There is no value for truespeed. Specifying an arbitrary value has the same effect as specifying it with no value.  
truespeed 
truespeed="true"
truespeed="false"
truespeed="on"
truespeed="truespeed" 
Example:  
html
<!DOCTYPE html><html> <head>    <title>HTML | Marquee truespeed attribute</title>    <style>        .main {            text-align: center;        }    </style></head> <body>    <h1 style="color:green; text-align:center;">      GeeksforGeeks  </h1>    <div class="main">        <marquee scrollamount="3"                 scrolldelay="6"                 bgcolor="Green"                 direction="left"                 loop="">            Left        </marquee>        <marquee scrollamount="3"                 scrolldelay="6"                 truespeed="truespeed"                 bgcolor="Green"                 direction="right"                 loop="">            Right        </marquee>    </div></body> </html>
Output:  
Supported Browsers: The browsers supported by HTML Marquees truespeed attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
 
hritikbhatnagar2182
ManasChhabra2
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Reverse the values of an Object in R Programming – rev() Function

17 Jun, 2020
rev() function in R Language is used to return the reverse version of data objects. The data objects can be defined as Vectors, Data Frames by Columns & by Rows, etc.
Syntax: rev(x)
Parameter:x: Data object
Returns: Reverse of the data object passed
Example 1:
# R program to reverse a vector  # Create a vectorvec <- 1:5                           vec    # Apply rev() function to vector    vec_rev <- rev(vec)                      vec_rev                                  
Output:
[1] 1 2 3 4 5
[1] 5 4 3 2 1

Example 2: Reverse Columns of a Data Frame
# R program to reverse # columns of a Data Frame  # Creating a data.framedata <- data.frame(x1 = 1:5,                               x2 = 6:10,                   x3 = 11:15)data    # Print reversed example data framedata_rev <- rev(data)                    data_rev
Output:
   x1 x2 x3
1  1  6 11
2  2  7 12
3  3  8 13
4  4  9 14
5  5 10 15
 
  x3 x2 x1
1 11  6  1
2 12  7  2
3 13  8  3
4 14  9  4
5 15 10  5

Example 3: Reverse Rows of a Data Frame
# R program to reverse# rows of a data frame  # Creating a data framedata <- data.frame(x1 = 1:5,                               x2 = 6:10,                   x3 = 11:15)data    # Calling rev() & apply() functions combineddata_rev_row_a <- apply(data, 2, rev)    data_rev_row_a   # Alternative without rev()  data_rev_row_b <- data[nrow(data):1, ]   data_rev_row_b
Output:
  x1 x2 x3
1  1  6 11
2  2  7 12
3  3  8 13
4  4  9 14
5  5 10 15
     x1 x2 x3
[1,]  5 10 15
[2,]  4  9 14
[3,]  3  8 13
[4,]  2  7 12
[5,]  1  6 11
  x1 x2 x3
5  5 10 15
4  4  9 14
3  3  8 13
2  2  7 12
1  1  6 11

R DataFrame-Function
R List-Function
R Matrix-Function
R Object-Function
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Software Engineering | Slicing

16 Feb, 2022
Slicing or program slicing is a technique used in software testing which takes a slice or a group of program statements in the program for testing particular test conditions or cases that may affect a value at a particular point of interest. It can also be used for the purpose of debugging in order to find the bugs more easily and quickly. Slicing techniques were originally defined by Mark Weiser and they were only static in nature at that time. Afterward, Bogdan Korel and Janusz Laski introduced dynamic slicing, which can work for a particular execution of the program. It is of 2 types: static slicing and dynamic slicing, these are explained as following below: 
1. Static slicing:  
A static slice of a program contains all statements that may affect the value of a variable at any point for any arbitrary execution of the program.
Static slices are generally larger.
It considers every possible execution of the program.
2. Dynamic slicing:  
A dynamic slice of a program contains all the statements that actually affect the value of a variable at any point for a particular execution of the program.
Dynamic slices are generally smaller.
Considers only a particular execution of the program.
Let us see an example by the given code snippet: 
CPP
int z = 10;int n;cin >> n;int sum = 0;if (n > 10)    sum = sum + n;else    sum = sum - n;cout << "Hey";
Static slice for the variable sum:  
CPP
int n;cin >> n;int sum = 0;if (n > 10)    sum = sum + n;else    sum = sum - n;
Dynamic slice for the variable sum when n = 22;  
CPP
int n;cin >> n;int sum = 0;if (n > 10)    sum = sum + n;
As it can be observed in the above example the static slice takes all the possible execution (in this case it is 2) of the program which may affect the value of the variable sum. Whereas in the case of dynamic slicing, it considers only a particular execution (when n = 22) of the program which actually affects the value of the variable sum. Hence, the dynamic slice is always smaller than a static slice. 
ashwani prasad
SaiLokeshReddyGayam
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to read file word by word

29 Dec, 2020
Prerequisites: File Handling in Python
Given a text file and the task is to read the information from file word by word in Python.
Examples:
Input:I am R2J!Output:IamR2J!
Input:Geeks 4 GeeksAnd in that dream, we were flying.Output:Geeks4GeeksAndinthatdream,wewereflying.
Approach:
Open a file in read mode which contains a string.Use for loop to read each line from the text file.Again use for loop to read each word from the line splitted by ‘ ‘.Display each word from each line in the text file.
Open a file in read mode which contains a string.
Use for loop to read each line from the text file.
Again use for loop to read each word from the line splitted by ‘ ‘.
Display each word from each line in the text file.
Example 1: Let’s suppose the text file looks like this –
Text File:
# Python program to read # file word by word   # opening the text filewith open('GFG.txt','r') as file:       # reading each line        for line in file:           # reading each word                for word in line.split():               # displaying the words                       print(word) 
Output:
Geeks
4
geeks
Example 2: Let’s suppose the text file contains more than one line.
Text file:
# Python program to read # file word by word   # opening the text filewith open('GFG.txt','r') as file:       # reading each line        for line in file:           # reading each word                for word in line.split():               # displaying the words                       print(word) 
Output:
Geeks
4
Geeks
And
in
that
dream,
we
were
flying.

Python file-handling-programs
python-file-handling
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to make an image draggable in HTML5 ? - GeeksforGeeks

19 Aug, 2021
Drag and drop is a very common and widely used feature in a modern-day website. It simply means to drag an image with the cursor and drop it to any other place. In this article, we are going to learn how to make an image draggable using HTML 5.
Making any HTML5 elements including images draggable is quite easy. We take the help of the ‘draggable’ attribute. It takes true, false, or auto as arguments. The default value is auto. The draggable property depends upon the browser. If we set the value true then the image is draggable. If we set the value false, the image is not draggable. 
Syntax:
<img src="" alt="" draggable="true">
Example:
HTML
<!DOCTYPE html><html lang="en">  <body>    <h2 style="color: green">GeeksforGeeks</h2>      <p><b>Draggable image</b></p>      <img src="https://media.geeksforgeeks.org/wp-content/uploads/20210810224356/geeksimage2-200x146.png"         alt="image" draggable="true"/>  </body></html>
Output:
Draggable image
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML-Questions
HTML5
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Top 10 Angular Libraries For Web Developers
How to count the total number of links in a page in Selenium?

The total number of links in a page can be counted with the help of findElements() method. The logic is to return a list of web elements with tagname anchor, then getting the size of that list.
Code Implementation
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class LinkCount {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://www.tutorialspoint.com/index.htm";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      //Using tagname with anchor
      List<WebElement> links = driver.findElements(By.tagName("a"));
      System.out.println(“The number of links is “ + links.size());
      driver.close();
   }
}
Daemon thread in Java

A Daemon thread is a background service thread which runs as a low priority thread and performs background operations like garbage collection. JVM exits if only daemon threads are remaining.
The setDaemon() method of the Thread class is used to mark/set a particular thread as either a daemon thread or a user thread. The Java Virtual Machine exits when the only threads running are all daemon threads. This method must be called before the thread is started.
Live Demo
class adminThread extends Thread {
   adminThread() {
      setDaemon(false);
   }
   public void run() {
      boolean d = isDaemon();
      System.out.println("daemon = " + d);
   }
}

public class Tester {
   public static void main(String[] args) throws Exception {
      Thread thread = new adminThread();
      System.out.println("thread = " + thread.currentThread());
      thread.setDaemon(false);
      thread.start();
   }
}
thread = Thread[main,5,main]
daemon = false
How to get the list of column headers from a Pandas DataFrame?

To get a list of Pandas DataFrame column headers, we can use df.columns.values.
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Print the input DataFrame.
Print the input DataFrame.
Print the list of df.columns.values output.
Print the list of df.columns.values output.
 Live Demo
import pandas as pd

df = pd.DataFrame(
   {
      "x": [5, 2, 1, 9],
      "y": [4, 1, 5, 10],
      "z": [4, 1, 5, 0]
   }
)

print "Input DataFrame is:\n", df
print "List of headers are: ", list(df.columns.values)
Input DataFrame is:
   x  y  z
0  5  4  4
1  2  1  1
2  1  5  5
3  9 10  0
List of headers are: ['x', 'y', 'z']
How To Delete Columns From PySpark DataFrames | Towards Data Science

Dropping columns from DataFrames is one of the most commonly performed tasks in PySpark. In today’s short guide, we’ll explore a few different ways for deleting columns from a PySpark DataFrame. Specifically, we’ll discuss how to
delete a single column
drop multiple columns
reverse the operation and instead, select the desired columns in cases where this is more convenient.
First, let’s create an example DataFrame that we’ll reference throughout this guide in order to demonstrate a few concepts.
from pyspark.sql import SparkSession# Create an instance of spark sessionspark_session = SparkSession.builder \    .master('local[1]') \    .appName('Example') \    .getOrCreate()# Create an example DataFramedf = spark_session.createDataFrame(    [        (1, True, 'a', 1.0),        (2, True, 'b', 2.0),        (3, False, 'c', 3.0),        (4, False, 'd', 4.0),    ],    ['colA', 'colB', 'colC', 'colD'])df.show()+----+-----+----+----+|colA| colB|colC|colD|+----+-----+----+----+|   1| true|   a| 1.0||   2| true|   b| 2.0||   3|false|   c| 3.0||   4|false|   d| 4.0|+----+-----+----+----+
The most elegant way for dropping columns is the use of pyspark.sql.DataFrame.drop function that returns a new DataFrame with the specified columns being dropped:
df  = df.drop('colC')df.show()+----+-----+----+|colA| colB|colD|+----+-----+----+|   1| true| 1.0||   2| true| 2.0||   3|false| 3.0||   4|false| 4.0|+----+-----+----+
Note that if a specified column does not exist in the column, this will be a no-op meaning that the operation won’t fail and will have no effect at all.
Usually, you may have to drop multiple columns in one go. If this is the case, then you can specify the columns you wish to drop as a list and then unpack them using an asterisk as shown below.
cols_to_drop = ['colB', 'colC']df = df.drop(*cols_to_drop)df.show()+----+----+|colA|colD|+----+----+|   1| 1.0||   2| 2.0||   3| 3.0||   4| 4.0|+----+----+
In some cases, it may be more convenient you reverse the drop operation and actually select only the subset of columns you want to keep. For example, if the number of columns you want to drop is greater than the number of columns you want to keep in the resulting DataFrame then it makes sense to perform a selection instead.
As an example, consider that we want to keep only one column from the DataFrame above. In this case it makes more sense to simply select that column rather than dropping the other 3 columns:
df = df.select('colA')df.show()+----+|colA|+----+|   1||   2||   3||   4|+----+
In today’s short guide we discussed a few different ways for deleting columns from a PySpark DataFrame. Apart from directly dropping columns, we’ve also seen that in some cases it might be more convenient to reverse the operation and actually select only the desired columns you wish to keep in the resulting DataFrame.
Become a member and read every story on Medium. Your membership fee directly supports me and other writers you read. You’ll also get full access to every story on Medium.
You may also like
VBScript DateSerial Function

It is a function that returns a date for the specified day, month and year parameters.
DateSerial(year,month,day)

year, a Required Parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year.
year, a Required Parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year.
month, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 12.
month, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 12.
day, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 31.
day, a Required Parameter. It can also be in the form of an expression, which should range from 1 to 31.
<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write(DateSerial(2013,5,10))
       
      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
Fri May 10 00:00:00 UTC+0530 2013 


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
C library function - abort()

The C library function void abort(void) abort the program execution and comes out directly from the place of the call.
Following is the declaration for abort() function.
void abort(void)
NA
NA
This function does not return any value.
The following example shows the usage of abort() function.
#include <stdio.h>
#include <stdlib.h>

int main () {
   FILE *fp;
   
   printf("Going to open nofile.txt\n");
   fp = fopen( "nofile.txt","r" );
   if(fp == NULL) {
      printf("Going to abort the program\n");
      abort();
   }
   printf("Going to close nofile.txt\n");
   fclose(fp);
   
   return(0);
}
Let us compile and run the above program that will produce the following result when it tries to open nofile.txt file, which does not exist −
Going to open nofile.txt                                                    
Going to abort the program                                                  
Aborted (core dumped)


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Convert the case of every value in a MySQL Column to uppercase

For this, use UPPER() on MySQL column. Let us first create a table −
mysql> create table DemoTable627 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,FirstName varchar(100));
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable627(FirstName) values(UPPER('John'));
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable627(FirstName) values(UPPER('Sam'));
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable627(FirstName) values(UPPER('Mike'));
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable627(FirstName) values(UPPER('Carol'));
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable627(FirstName) values(UPPER('dAVID'));
Query OK, 1 row affected (0.70 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable627;
This will produce the following output −
+----+-----------+
| Id | FirstName |
+----+-----------+
|  1 | JOHN      |
|  2 | SAM       |
|  3 | MIKE      |
|  4 | CAROL     |
|  5 | DAVID     |
+----+-----------+
5 rows in set (0.00 sec)
Setting Font Size with Em Using CSS

For scalable size of text, the font-size is expressed in em. Bye default one em is equal to 16px or 12pt. Its value is relative to the parent element’s font-size.
The syntax of CSS font-size property is as follows −
Selector {
   font-size: /*value*/
}
The following examples illustrate how CSS font-size property can be set in ems −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   width: 40%;
   border: 2px solid yellow;
   padding: 20px;
   font-size: 1em;
}
span {
   font-size: 2em;
   background-color: chartreuse;
}
</style>
</head>
<body>
<div>
<p>This is a demo paragraph<span> displaying font sizes</span> set with em in CSS.</p>
</div>
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
table {
   width: 40%;
   border: 2px ridge red;
   font-size: 0.8em;
}
span {
   font-size: 1.5em;
   background-color: silver;
}
</style>
</head>
<body>
<h2>Class Info</h2>
<table>
<tr>
<th>Number of Students</th>
</tr>
<tr>
<td>Class A</td>
<td><span>50 Students</span></td>
</tr>
<tr>
<td>Class B</td>
<td><span>40 Students</span></td>
</tr>
</table>
</body>
</html>
This gives the following output −
Arduino - Arithmetic Operators

Assume variable A holds 10 and variable B holds 20 then −
void loop () {
   int a = 9,b = 4,c;
   c = a + b;
   c = a - b;
   c = a * b;
   c = a / b;
   c = a % b;
}
a + b = 13
a - b = 5
a * b = 36
a / b = 2
Remainder when a divided by b = 1


    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
GATE-CS-2016 (Set 1) - GeeksforGeeks

11 Oct, 2021
I    P always beats Q
II.  R always beats S
III. S loses to P only sometimes
IV.  R always loses to Q 
(i) P is likely to beat all the three other players
(ii) S is the absolute worst player in the set 
f(x) = 2x7 + 3x - 5
     = 2x7 - 2x + 5x - 5
For exponential dependence we must have functions of form
f(x) = a.(k power x) : a,k are constants and f(0)=a

Let us assume: C = cycles for failure ; L = Load; a, k = constants
according to question C is an exponential function of L
Hence we can say,

1) C = a x (k^L) ---- > in case C is increasing exponentially
2) C = a / (k^L) ---- > in case C is decreasing exponentially

we take 2nd equation and apply log to both side we get:

log C + L x (log k) = log a ...... by logarithmic property

given (C=100 for L=80) and (C=10000 for L=40)
apply these to values to above equation, this gives us 2 equations
and 2 variables:

log a = log 100 + (80 x log k)...............(1)
log a = log 10000 + (40 x log k)...........(2)

we have 2 variables and 2 equations hence we find
log a = 6
log k= 1/20

now find, [ L = (log a - log C) / (log k) ] for C=5000 cycles

=> L = (6 - log 5000)*20 = 46.0206 ~ 46.02 => [ANS]

GATE-CS-2016 (Set 2)
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Python | Text to Speech by using pyttsx3

18 Apr, 2022
pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline and is compatible with both Python 2 and 3. An application invokes the pyttsx3.init() factory function to get a reference to a pyttsx3. Engine instance. it is a very easy to use tool which converts the entered text into speech. The pyttsx3 module supports two voices first is female and the second is male which is provided by “sapi5” for windows. It supports three TTS engines :
sapi5 – SAPI5 on Windows
nsss – NSSpeechSynthesizer on Mac OS X
espeak – eSpeak on every other platform
Installation To install the pyttsx3 module, first of all, you have to open the terminal and write
pip install pyttsx3
 If you receive errors such as No module named win32com.client, No module named win32, or No module named win32api, you will need to additionally install pypiwin32. It can work on any platform. Now we are all set to write a program for conversion of text to speech. Code : Python program to convert text to speech 
Python3
# Import the required module for text # to speech conversionimport pyttsx3 # init function to get an engine instance for the speech synthesisengine = pyttsx3.init() # say method on the engine that passing input text to be spokenengine.say('Hello sir, how may I help you, sir.') # run and wait method, it processes the voice commands.engine.runAndWait()
Output : The output of the above program would be a voice saying,
'Hello sir, how may I help you, sir.'
varshagumber28
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Read file from sibling directory

06 Jun, 2021
In this article, we will discuss the method to read files from the sibling directory in Python. First, create two folders in a root folder, and one folder will contain the python file and the other will contain the file which is to be read. Below is the dictionary tree:
Directory Tree:
root :
|
|__Sibling_1:
|    \__demo.py
|      
|__Sibling_2:
|      \__file.txt
Here Sibling_1 and Sibling_2 are siblings. We are going to discuss the method to read data from file.text in demo.py which exists in the sibling folder. We will be using the os module to change the current working directory to a directory having file.txt.
file.txt:
This is the data that need to be read!!
1. Importing os module and storing the path of demo.py in a variable called path. The os.path.realpath(__file__) method will give the path where the file demo.py exists which will be ‘D:\root\Sibling_1\demo.py’.
Python
# importing os moduleimport os    # gives the path of demo.pypath = os.path.realpath(__file__)print(path)
Output:
'D:\root\Sibling_1\demo.py'
2. Getting the directory using os.path.dirname() where demo.py exists and storing it in variable dir.
Python
import os  # gives the path of demo.pypath = os.path.realpath(__file__)  # gives the directory where demo.py# existsdir = os.path.dirname(path)print(dir)
Output:
'D:\root\Sibling_1'
3. Replacing the folder name in dir string from Sibling_1 to Sibling_2, so that now dir has directory ‘D:\root\Sibling_2’ where file.txt exist. Now we will use the method os.chdir() to change the working directory from the current directory to the directory stored in dir.
Python
import os  path = os.path.realpath(__file__)dir = os.path.dirname(path)  # replaces folder name of Sibling_1 to# Sibling_2 in directorydir = dir.replace('Sibling_1', 'Sibling_2')  # changes the current directory to Sibling_2 # folderos.chdir(dir)print(dir)
Output:
'D:\root\Sibling_2'
4. Now as the directory is changed to a sibling folder we can use the open() method to directly open and read any file in the folder.
Python
# importing os moduleimport os  # gives the path of demo.pypath = os.path.realpath(__file__)  # gives the directory where demo.py # existsdir = os.path.dirname(path)  # replaces folder name of Sibling_1 to # Sibling_2 in directorydir = dir.replace('Sibling_1', 'Sibling_2')  # changes the current directory to # Sibling_2 folderos.chdir(dir)  # opening file.txt which is to readf = open('file.txt')  # reading data from file.txt and storing# it in datadata = f.read()  # printing dataprint(data)
Output:
This is the data that need to be read!!
Picked
Python directory-program
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operators Precedence in C++

Try the following example to understand operators precedence concept available in C++. Copy and paste the following C++ program in test.cpp file and compile and run this program.
Check the simple difference with and without parenthesis. This will produce different results because (), /, * and + have different precedence. Higher precedence operators will be evaluated first −
#include <iostream>
using namespace std;
 
main() {
   int a = 20;
   int b = 10;
   int c = 15;
   int d = 5;
   int e;
 
   e = (a + b) * c / d;      // ( 30 * 15 ) / 5
   cout << "Value of (a + b) * c / d is :" << e << endl ;

   e = ((a + b) * c) / d;    // (30 * 15 ) / 5
   cout << "Value of ((a + b) * c) / d is  :" << e << endl ;

   e = (a + b) * (c / d);   // (30) * (15/5)
   cout << "Value of (a + b) * (c / d) is  :" << e << endl ;

   e = a + (b * c) / d;     //  20 + (150/5)
   cout << "Value of a + (b * c) / d is  :" << e << endl ;
  
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Value of (a + b) * c / d is :90
Value of ((a + b) * c) / d is  :90
Value of (a + b) * (c / d) is  :90
Value of a + (b * c) / d is  :50


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
C# - Loops

There may be a situation, when you need to execute a block of code several number of times. In general, the statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.
Programming languages provide various control structures that allow for more complicated execution paths.
A loop statement allows us to execute a statement or a group of statements multiple times and following is the general from of a loop statement in most of the programming languages −
C# provides following types of loop to handle looping requirements. Click the following links to check their detail.
It repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body.
It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
It is similar to a while statement, except that it tests the condition at the end of the loop body
You can use one or more loop inside any another while, for or do..while loop.
Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.
C# provides the following control statements. Click the following links to check their details.
Terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.
Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
A loop becomes infinite loop if a condition never becomes false. The for loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty.
using System;

namespace Loops {
   class Program {
      static void Main(string[] args) {
         for (; ; ) {
            Console.WriteLine("Hey! I am Trapped");
         }
      }
   }
} 
When the conditional expression is absent, it is assumed to be true. You may have an initialization and increment expression, but programmers more commonly use the for(;;) construct to signify an infinite loop.

    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
Python - Plotting charts in excel sheet using openpyxl module

Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmatic operations and plotting graphs.
# import openpyxl module
import openpyxl
#import BubbleChart,Reference,Series class from openpyxl.chart #sub_module
from openpyxl.chart import BubbleChart, Reference, Series
# Call a Workbook() function of openpyxl to create a new blank #Workbook object
wb = openpyxl.Workbook()
# Get workbook active sheetfrom the active attribute.
sheet = wb.active
rows = [
   ("Number of Products", "Sales in USD", "Market share"),
   (14, 12200, 15),
   (20, 60000, 33),
   (18, 24400, 10),
   (22, 32000, 42),
]
#write content of each row in 1st, 2nd and 3rd column of the active #sheet respectively.
for row in rows:
   sheet.append(row)
# Create object of BubbleChart class
chart = BubbleChart()
# create data for plotting
xvalues = Reference(sheet, min_col = 1, min_row = 2, max_row = 5)
yvalues = Reference(sheet, min_col = 2, min_row = 2, max_row = 5)
size = Reference(sheet, min_col = 3, min_row = 2, max_row = 5)
# create a 1st series of data
series = Series(values = yvalues, xvalues = xvalues, zvalues = size, title ="2013")
# add series data to the chart object
chart.series.append(series)
# set the title of the chart
chart.title = " BUBBLE-CHART "
# set the title of the x-axis
chart.x_axis.title = " X_AXIS "  
# set the title of the y-axis
chart.y_axis.title = " Y_AXIS "
# add chart to the sheet the top-left corner of a chart
# is anchored to cell E2
sheet.add_chart(chart, "E2")  
# save the file
wb.save("bubbleChart.xlsx")
Check if a string is palindrome in C using pointers

Suppose we have a string s. We have to check whether the given string is a palindrome or not. We have to solve this problem using pointers in C.
So, if the input is like s = "racecar", then the output will be True.
To solve this, we will follow these steps −
length := size of string
forward := pointing to the first character of string
reverse := pointing to the last character of string
while position of reverse >= position of forward, doif character pointed by reverse is same as character pointed by forward, thenincrease forward and decrease reverse by 1otherwisecome out from loop
if character pointed by reverse is same as character pointed by forward, thenincrease forward and decrease reverse by 1
increase forward and decrease reverse by 1
otherwisecome out from loop
come out from loop
if position of forward >= position of reverse, thenreturn True
return True
return False
Let us see the following implementation to get better understanding −
 Live Demo
#include <stdio.h>
#include <string.h>
int solve(char *string){
   int length;
   char *forward, *reverse;
   length = strlen(string);
   forward = string;
   reverse = forward + length - 1;
   for (forward = string; reverse >= forward;) {
      if (*reverse == *forward) {
         reverse--;
         forward++;
      } else
         break;
   } if (forward > reverse)
      return 1;
   else
      return 0;
}
int main(){
   char string[] = "racecar";
   printf("%d", solve(string));
}
"racecar"
1
Difference between Instance Variable and Local Variable - GeeksforGeeks

31 May, 2021
A variable is a name given to a memory location. It is the basic unit of storage in a program.
The value stored in a variable can be changed during program execution.
A variable is only a name given to a memory location. All the operations are done on the variable effects of a memory location.
In Java, all the variables must be declared before use.
Instance Variable: These variables are declared within a class but outside a method, constructor, or block and always get a default value.
These variables are usually created when we create an object and are destroyed when the object is destroyed.
We may use an access specifier, for instance, variable, and if no access specifier is specified, then the default access specifier is used.
Each and every object will have its own copy of instance variables.
Example:
class Taxes  
{  
   int count; // Count is an Instance variable  
   /*...*/  
}  
Local Variable: These variables are declared within a method but do not get any default value.
They are usually created when we enter a method or constructor and are destroyed after exiting the block or when the call returns from the method.
Its scope is generally limited to a method and its scope starts from the line they are declared. Their scope usually remains there until the closing curly brace of the method comes.
The initialization of the local variable is mandatory.
Example:
int area()      
{    
        int length = 10; // Local variable          
        int breadth = 5; // Local variable          
        int rectarea = length*breadth; // Local variable          
        return rectarea;          
}  
Tabular difference between the instance variable vs local variable:
Instance Variable 
Local Variable 
C-Variable Declaration and Scope
Articles
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Time Complexity and Space Complexity
Docker - COPY Instruction
Time complexities of different data structures
SQL | Date functions
Difference between Class and Object
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
Go Tutorial

Go is a popular programming language.
Go is used to create computer programs.
Our "Try it Yourself" editor makes it easy to learn Go. You can edit Go code and view the result in your browser.
Click on the "Try it Yourself" button to see how it works.
Insert the missing part of the code below to output "Hello World".
package main   
import ("fmt")
func main() {  
  ("Hello World!")
}

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

To skip rows, use LIMIT OFFSET. Let us first create a table −
mysql> create table DemoTable860(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Name varchar(100)
);
Query OK, 0 rows affected (0.73 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable860(Name) values('Chris');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable860(Name) values('Robert');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable860(Name) values('David');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable860(Name) values('Bob');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable860(Name) values('Mike');
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable860(Name) values('Sam');
Query OK, 1 row affected (0.07 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable860;
This will produce the following output −
+----+--------+
| Id | Name   |
+----+--------+
|  1 | Chris  | 
|  2 | Robert |
|  3 | David  |
|  4 | Bob    |
|  5 | Mike   |
|  6 | Sam    |
+----+--------+
6 rows in set (0.00 sec)
Following is the query to skip rows in MySQL −
mysql> select *from DemoTable860 limit 3 offset 2;
This will produce the following output −
+----+-------+
| Id | Name  |
+----+-------+
|  3 | David |
|  4 | Bob   |
|  5 | Mike  |
+----+-------+
3 rows in set (0.00 sec)
How to read test data from an excel sheet and use it to test facebook login in Selenium Webdriver?

We can read test data from an excel sheet and use it to test Facebook login with Selenium webdriver in Python. We can access excel with Python with the help of the OpenPyXL library.
To install this library, we have to run the command - pip install openpyxl. Besides, we have to add the statement import openpyxl in our code. To start with, we have to load the excel workbook with the help of the load_workbook method.
The path of the workbook is passed as a parameter to this method. Then we have to determine its active sheet by applying the sheet method on the loaded workbook object.
To test the Facebook login page, we need to have the email and password of the user and this data is saved in an excel workbook as shown in the below image. The email – abc@gmail.com is at cell (address: row=2, column=1) and password – test123 is at cell(address: row=2, column=1).
To read these data, we shall use the cell method on the active sheet. The row and column numbers are passed as parameters to this method. Then the value method is applied on those particular cell addresses to read values within it.
import openpyxl
from selenium import webdriver
#configure workbook path
b = openpyxl.load_workbook("C:\\Data.xlsx")
#get active sheet
sht = b.active
#get cell address of email within active sheet
e = sht.cell (row = 2, column = 1)
#get cell address of password within active sheet
p = sht.cell (row = 2, column = 2)
#get values
email = e.value
passw = p.value
#set chromodriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(0.5)
#launch URL
driver.get("https://www.facebook.com/")
#identify element
l = driver.find_element_by_id("email")
#enter email obtained from excel
l.send_keys(email)
m = driver.find_element_by_id("pass")
#enter password obtained from excel
m.send_keys(passw)
#get values entered
s = l.get_attribute("value")
t = m.get_attribute("value")
print("Email is: ")
print(s)
print("Password is: ")
print(t)
#browser quit
driver.quit()
How to disable delete permission of File and Directory in Linux?

Many times there can be un-intentional delete of files or directories. That can lead to loss of important data or some misconfiguration of the system so we need a way to stop the accidental deletion of files and directories it may not be applicable to all the files and directories but we can have a design where at least some files and directories are prevented from such scenario.
We use the change attribute command to prevent scenario below will see how this command is applied to two files and directories.
Below is the syntax of change attribute command.
chattr [operator] [flag] [filename]
Where the operator can be ‘+’ , ‘-‘ or ‘=’ .
And flag can be set to i to make the file immutable.
Now let’s first investigate the existing attribute of a directory and the files in it. We see that they are normal files which can be rewritten and deleted.
~/Documents/tutorials$ pwd ; ls -l
/home/ubuntu/Documents/tutorials
total 4
drwxrwxr-x 2 ubuntu ubuntu 4096 Dec 31 21:13 linux
~/Documents/tutorials$ lsattr
-------------e-- ./linux
~/Documents/tutorials$ cd linux/
~/Documents/tutorials/linux$ lsattr
-------------e-- ./passwd_bkup.txt
-------------e-- ./movie_list.txt
Now we apply the ‘i’ flag to make one of the file immutable so that it can not be deleted.
$ sudo chattr +i passwd_bkup.txt
[sudo] password for ubuntu:
$ lsattr
----i--------e-- ./passwd_bkup.txt
-------------e-- ./movie_list.txt
As you can see the passwd_bkup.txt file now has i file attribute. Now let’s try deleting this file. The file with I attribute will not get deleted while the other files will get deleted.
$ rm -rf passwd_bkup.txt
rm: cannot remove 'passwd_bkup.txt': Operation not permitted
# Other file gets deleted.
$ rm -rf movie_list.txt
$ lsattr
----i--------e-- ./passwd_bkup.txt
Now the directory containing this file also does not get deleted because it can not become empty.
$ rm -rf linux/
rm: cannot remove 'linux/passwd_bkup.txt': Operation not permitted