code-rag-bench/online-tutorials huggingface dataset:
v-bind Directive in Vue.js

06 Jun, 2022
The v-bind directive is a Vuejs directive used to bind one or more attributes, or a component prop to an element. If that attribute is binded to our data defined in Vuejs instance then dynamically changes can be observed as data changes. First, we will create a div element with id as app and let’s apply the v-bind directive to a element. Further, we can use a button execute a function when click even occurs which will inverse the value of data.
Syntax:
v-bind:attribute="expression";
Since developers use this attribute too often, Vuejs provides a shorthand for this attribute as follows:
:attribute="expression";
Things we can do with v-bind:
Multiple classes can be passed.
Classes can be passed as arrays.
Supports variables to be assigned as a condition for classes and props.
Supports variable as arrays also.
It can be used in child components also.
Inline styles can also be assigned using v-bind. 
Parameters: This directive accepts expression which will be deciding which attribute value to use. Example: This example uses Vuejs to toggle the classes of an element with v-bind. Further, we will use CSS to apply a different color to each class so that we can see them changing.
HTML
<!DOCTYPE html><html> <head>     <!-- Load Vuejs -->    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">    </script>     <style>        .active {            color: blue;        }         .error {            color: red;        }    </style></head> <body>    <div style="text-align: center;width: 600px;">        <h1 style="color: green;">            GeeksforGeeks        </h1>        <b>            VueJS | v-bind directive        </b>    </div>     <div id="canvas" style=        "border:1px solid #000000;        width: 600px;height: 200px;">         <div id="app" style=            "text-align: center;            padding-top: 40px;">            <button v-on:click=                "ifActive = !ifActive">                Click to Toggle            </button>            // here we have used the : short hand of v-bind:            <h1 :class=                "{active: ifActive, error: !ifActive}">                GeeksforGeeks            </h1>        </div>    </div>     <script>        var app = new Vue({            el: '#app',            data: {                ifActive: true            }        })    </script></body> </html>                  
Output:
satyamm09
Vue.JS
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
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 ?
Data Structures | Linked List | Question 11

14 Jul, 2019
Consider the function f defined below.
struct item {   int data;   struct item * next; };   int f(struct item *p) {   return (          (p == NULL) ||           (p->next == NULL) ||           (( P->data <= p->next->data) && f(p->next))         ); } 
For a given linked list p, the function f returns 1 if and only if (GATE CS 2003)
(A) not all elements in the list have the same data value.(B) the elements in the list are sorted in non-decreasing order of data value(C) the elements in the list are sorted in non-increasing order of data value(D) None of themAnswer: (B)Explanation:The function f() works as follows1) If linked list is empty return 12) Else If linked list has only one element return 13) Else if node->data is smaller than equal to node->next->data and same thing holds for rest of the list then return 14) Else return 0Quiz of this Question
Data Structures
Data Structures-Linked List
Linked Lists
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Array | Question 2
Data Structures | Hash | Question 5
Data Structures | Queue | Question 2
Amazon Interview Experience for SDE-II
Data Structures | Binary Trees | Question 1
Data Structures | Misc | Question 2
Data Structures | Queue | Question 11
FIFO vs LIFO approach in Programming
Data Structures | Binary Trees | Question 15
Data Structures | Graph | Question 4
Python | sympy.diff() method

12 Jun, 2019
With the help of sympy.diff() method, we can find the differentiation of mathematical expressions in the form of variables by using sympy.diff() method.
Syntax : sympy.diff(expression, reference variable)Return : Return differentiation of mathematical expression.
Example #1 :In this example we can see that by using sympy.diff() method, we can find the differentiation of mathematical expression with variables. Here we use symbols() method also to declare a variable as symbol.
# import sympyfrom sympy import * x, y = symbols('x y')gfg_exp = x + yexp = sympy.expand(gfg_exp**2)print("Before Differentiation : {}".format(exp))  # Use sympy.diff() methoddif = diff(exp, x)  print("After Differentiation : {}".format(dif))
Output :
Before Differentiation : x**2 + 2*x*y + y**2
After Differentiation : 2*x + 2*y
 Example #2 :
# import sympyfrom sympy import * x, y = symbols('x y')gfg_exp = sin(x)*cos(x)  print("Before Differentiation : {}".format(gfg_exp))  # Use sympy.diff() methoddif = diff(gfg_exp, x)  print("After Differentiation : {}".format(dif))
Output :
Before Differentiation : sin(x)*cos(x)
After Differentiation : -sin(x)**2 + cos(x)**2
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Getting the Modulus of the Determinant of a Matrix in R Programming – determinant() Function

03 Jun, 2020
determinant() function in R Language is a generic function that returns separately the modulus of the determinant, optionally on the logarithm scale, and the sign of the determinant.
Syntax: determinant(x, logarithm = TRUE, ...)
Parameters:x: matrixlogarithm: if TRUE (default) return the logarithm of the modulus of the determinant
Example 1:
# R program to illustrate# determinant function  # Initializing a matrix with# 3 rows and 3 columnsx <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3)  # Getting the matrix representationx  # Calling the determinant() functiondeterminant(x)
Output:
     [, 1] [, 2] [, 3]
[1, ]    3   -1    2
[2, ]    2    7    6
[3, ]    6    3   -1

$modulus
[1] 5.220356
attr(, "logarithm")
[1] TRUE

$sign
[1] -1

attr(, "class")
[1] "det"

Example 2:
# R program to illustrate# determinant function  # Initializing a matrix with# 2 rows and 2 columnsx <- matrix(c(1, 2, 3, 4), 2, 2)  # Getting the matrix representationx  # Calling the determinant() functiondeterminant(x, logarithm = FALSE)
Output:
     [, 1] [, 2]
[1, ]    1    3
[2, ]    2    4

$modulus
[1] 2
attr(, "logarithm")
[1] FALSE

$sign
[1] -1

attr(, "class")
[1] "det"

R Matrix-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
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Loops in R (for, while, repeat)
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
R - if statement
How to filter R DataFrame by values in a column?
Logistic Regression in R Programming
Difference between class alv and function alv in SAP ABAP?

Class alv and Function alv are different in terms of features. Below is the difference:
Class alv are secured as compared to function alv.
While using class alv, it improves the performance.
With use of function alv, you can create screens using function module however you need to call separate programs to generate screen.
Class alv provides Object Oriented functionality and hence they are easily reusable.
You can execute function modules asynchronously and can also be called by other systems remotely.
Below is an example of class ALV:
DATA: lcl_alv TYPE REF TO cl_gui_alv_grid,
      t_gly TYPE STANDARD TABLE OF Travels .
SELECT * FROM Travels INTO TABLE t_gly.
CREATE OBJECT lcl_alv
    EXPORTING I_PARENT = cl_gui_container=>screen0.
CALL METHOD lcl_alv->set_table_for_first_display
    EXPORTING
       I_STRUCTURE_NAME = 'Travels'
    CHANGING
       IT_OUTTAB = t_gly.
CALL SCREEN 100.
 Few of function module to create ALV reports:
Below shows the use of function module to display an ALV grid:
DATA: it_spfli TYPE TABLE OF spfli.
SELECT * FROM spfli INTO TABLE it_spfli.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    i_structure_name = 'SPFLI'
  TABLES
    t_outtab         = it_spfli.
How can we restrict access to methods with specific HTTP verbs in C# ASP.NET
WebAPI?

The HTTP verbs comprise a major portion of our “uniform interface” constraint and
provide us the action counterpart to the noun-based resource. The primary or mostcommonly-used HTTP verbs (or methods, as they are properly called) are POST,
GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and
delete (or CRUD) operations, respectively. There are a number of other verbs, too,
but are utilized less frequently. Of those less-frequent methods, OPTIONS and
HEAD are used more often than others.
Action method can be named as HTTP verbs like Get, Post, Put, Patch or Delete.
However, we can append any suffix with HTTP verbs for more readability. For
example, Get method can be GetAllStudents() or any other name which starts with
Get.
public class DemoController : ApiController{
   public IHttpActionResult GetAllStudents(){
      //Retrieves students data
      return Ok();
   }
   public IHttpActionResult Post([FromBody]Student student){
      //Insert student data
      return Ok();
   }
   public IHttpActionResult Put([FromBody]Student student){
      //Update student data
      return Ok();
   }
   public IHttpActionResult Delete(int id){
      //Delete student data
      return Ok();
   }
}
The other way defining Http Verb of an action method instead naming is by using Http Verb Attribute. We can easily restrict access to an ASP.NET Web API
method to be called using a specific HTTP method.
using DemoWebApplication.Models;
using System.Collections.Generic;
using System.Web.Http;
namespace DemoWebApplication.Controllers{
   public class DemoController : ApiController{
      [HttpGet] //HttpVerb Attribute
      public IHttpActionResult FetchStudentsList(){
         List<Student> students = new List<Student>{
            new Student{
               Id = 1,
               Name = "Mark"
            },
            new Student{
               Id = 2,
               Name = "John"
            }
         };
         return Ok(students);
      }
   }
}
Now let us try to access the above action method using post request.
We could see that when we send a post request to FetchStudentsList action method we getting 405 Method Not Allowed response since it is decorated with [HttpGet] attribute.
Git Pull Branch from Bitbucket

Now continue working on our new branch in our local Git.
Lets pull from our Bitbucket repository again so that our code is up-to-date:
git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), 428 bytes | 5.00 KiB/s, done.
From https://bitbucket.org/w3schools-test/hello-world
 * [new branch]      html-skeleton -> origin/html-skeleton
Already up to date.
Now our main branch is up todate. And we can see that there is a new 
branch 
available on Bitbucket.
Do a quick status check:
git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
And confirm which branches we have, and where we are working at the moment:
git branch
* master
So, we do not have the new branch on our local Git. But 
we know it is available on 
Bitbucket. So we can use the -a option to see all local and remote branches:
git branch -a
* master
  remotes/origin/html-skeleton
  remotes/origin/master
Note: branch -r is for remote branches only.
We see that the branch html-skeleton is available remotely, but not on our local git. Lets check it out:
git checkout html-skeleton
Switched to a new branch 'html-skeleton'
Branch 'html-skeleton' set up to track remote branch 'html-skeleton' from 'origin'.
And check if it is all up to date:
git pull
Already up to date.
Which branches do we have now, and where are we working from?
git branch
* html-skeleton
  master
Now, open your favourite editor and confirm that the changes from the Bitbucket branch carried over.
That is how you pull a Bitbucket branch to your local Git.
List all local and remote branches of the current Git.
git  


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.
upper_bound in C++

Here we will see that is the upper_bound() function in C++ STL. This function returns an iterator that points to the first element in the container, which is considered to go after val. The syntax is like:
iterator upper_bound (const value_type& val);
const_iterator upper_bound (const value_type& val) const;
The return value is an iterator, pointing to the first element in the container which is considered to go after val.
 Live Demo
#include <iostream>
#include <set>
using namespace std;
int main () {
   set<int> myset;
   set<int>::iterator itlow,itup;
   for (int i = 1; i < 10; i++) myset.insert(i*10);
   itup = myset.upper_bound (60);
   myset.erase(itup);
   cout << "myset contains:";
   for (set<int>::iterator it = myset.begin(); it!=myset.end(); ++it)
   cout << ' ' << *it;
}
myset contains: 10 20 30 40 50 60 80 90
Class and Object in Java - GeeksQuiz

07 Mar, 2018
values of obj1: 
a = 11 b = 21
values of obj2: 
a = 11 b = 21

values of obj1: 
a = 11 b = 21
values of obj2: 
a = 10 b = 20

values of obj1: 
a = 11 b = 20
values of obj2: 
a = 10 b = 21

a = 1
b = 2
b = 2
a = 1
Inside First
Inside Second
Inside First
Inside First
obj1.a = 1  obj1.b = 2
obj2.a = 4  obj2.b = 3
obj1.a = 4  obj1.b = 3
obj2.a = 4  obj2.b = 3
obj1.a = 1  obj1.b = 2
obj2.a = 4  obj2.b = 3
obj1.a = 4  obj1.b = 3
obj2.a = 4  obj2.b = 3
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
How to set background images in ReactJS ?
Microsoft Interview Experience for Internship (Via Engage)
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Alter Multiple Columns at Once in SQL Server?
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
C Program to read contents of Whole File
How to Replace Values in a List in Python?
How to find p-value for correlation coefficient in R?

The t test is used to find the p−value for the correlation coefficient and on the basis of that we decide whether there exists a statistically significant relationship between two variables or not. In R, we can perform this test by using function cor.test. For example, if we have a vector x and y then we can find the p−value using cor.test(x,y).
 Live Demo
set.seed(444)
x1<−1:10
y1<−10:1
cor.test(x1,y1)
Pearson's product−moment correlation
data: x1 and y1
t = −134217728, df = 8, p−value < 2.2e−16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−1 −1
sample estimates:
cor
−1
 Live Demo
x2<−rnorm(5000,12,1)
y2<−rnorm(5000,12,3)
cor.test(x2,y2)
Pearson's product−moment correlation
data: x2 and y2
t = −1.0611, df = 4998, p−value = 0.2887
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.04270876 0.01271735
sample estimates:
cor
−0.01500724
 Live Demo
x3<−rpois(10000,10)
y3<−rpois(10000,8)
cor.test(x3,y3)
Pearson's product−moment correlation
data: x3 and y3
t = 1.2085, df = 9998, p−value = 0.2269
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.007516765 0.031677652
sample estimates:
cor
0.01208509
 Live Demo
x4<−runif(5557,10,20)
y4<−runif(5557,12,25)
cor.test(x4,y4)
Pearson's product−moment correlation
data: x4 and y4
t = −0.84014, df = 5555, p−value = 0.4009
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.03755372 0.01502620
sample estimates:
cor
−0.01127155
 Live Demo
x5<−rexp(479,3.2)
y5<−rexp(479,1.2)
cor.test(x5,y5)
Pearson's product−moment correlation
data: x5 and y5
t = −1.3626, df = 477, p−value = 0.1736
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.15101987 0.02747874
sample estimates:
cor
−0.06226847
 Live Demo
x6<−rlnorm(1000,2,1.5)
y6<−rlnorm(1000,4,0.8)
cor.test(x6,y6)
Pearson's product−moment correlation
data: x6 and y6
t = −1.4907, df = 998, p−value = 0.1364
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.10880908 0.01490269
sample estimates:
cor
−0.04713393
 Live Demo
x7<−sample(0:9,5000,replace=TRUE)
y7<−sample(1:10,5000,replace=TRUE)
cor.test(x7,y7)
Pearson's product−moment correlation
data: x7 and y7
t = −1.2418, df = 4998, p−value = 0.2144
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.04526022 0.01016128
sample estimates:
cor
−0.01756296
 Live Demo
x8<−sample(101:150,100000,replace=TRUE)
y8<−sample(51:150,100000,replace=TRUE)
cor.test(x8,y8)
Pearson's product−moment correlation
data: x8 and y8
t = −0.7474, df = 99998, p−value = 0.4548
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
−0.008561341 0.003834517
sample estimates:
cor
−0.002363503
Check for None Tuple in Python

When it is required to check for 'None' value in a tuple, the 'all' method and the generator expression can be used.
The 'all' method checks to see if all the values inside an iterable are True values. If yes, it returns True, else returns False.
Below is a demonstration of the same −
Live Demo
my_tuple_1 = (None, None, None, None, None, None, None )

print ("The tuple is : " )
print(my_tuple_1)

my_result = all(elem is None for elem in my_tuple_1)

print("Does the tuple contain only None values ? ")
print(my_result)
The tuple is :
(None, None, None, None, None, None, None)
Does the tuple contain only None values ?
True
A tuple is defined and is displayed on the console.
It is iterated over using list comprehension and the 'all' method is used to check the elements in the tuple.
This result is assigned to a value.
It is displayed as output on the console.
How to turn JavaScript array into the comma-separated list?

To turn JavaScript array into a comma-separated list, use the Array.join() method. JavaScript array join() method joins all the elements of an array into a string. The following is the syntax −
array.join(separator);
The following is the parameter −
separator − Specifies a string to separate each element of the array. If omitted, the array elements are separated by a comma.
You can try to run the following code to turn JavaScript array into a comma-separated list −
Live Demo
<html>
   <head>
      <title>JavaScript Array join Method</title>
   </head>

   <body>
      <script>
         var arr = new Array("Java","PHP","Ruby");
         var str = arr.join();
         document.write("str : " + str );
         var str = arr.join(", ");
         document.write("<br />str : " + str );
      </script>
   </body>
</html>
Add element to HashSet in C#

To add the element to HashSet, the code is as follows −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args){
      HashSet<string> set1 = new HashSet<string>();
      set1.Add("A");
      set1.Add("B");
      set1.Add("C");
      set1.Add("D");
      set1.Add("E");
      set1.Add("F");
      set1.Add("G");
      set1.Add("H");
      Console.WriteLine("Elements in HashSet1...");
      foreach (string res in set1){
         Console.WriteLine(res);
      }
      HashSet<string> set2 = new HashSet<string>();
      set2.Add("John");
      set2.Add("Jacob");
      set2.Add("Ryan");
      set2.Add("Tom");
      set2.Add("Andy");
      set2.Add("Tim");
      set2.Add("Steve");
      set2.Add("Mark");
      Console.WriteLine("Elements in HashSet2... (Enumerator iterating through HashSet)");
      HashSet<string>.Enumerator demoEnum = set2.GetEnumerator();
      while (demoEnum.MoveNext()) {
         string res = demoEnum.Current;
         Console.WriteLine(res);
      }
      Console.WriteLine("Is HashSet1 equal to HashSet2? = "+set1.Equals(set2));
   }
}
This will produce the following output −
Elements in HashSet1...
A
B
C
D
E
F
G
H
Elements in HashSet2... (Enumerator iterating through HashSet)
John
Jacob
Ryan
Tom
Andy
Tim
Steve
Mark
Is HashSet1 equal to HashSet2? = False Count of HashSet2 = 8
Count of HashSet2 (updated) = 0
Let us now see another example −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args){
      HashSet<int> set1 = new HashSet<int>();
      set1.Add(100);
      set1.Add(200);
      Console.WriteLine("Elements in HashSet1...");
      foreach (int res in set1){
         Console.WriteLine(res);
      }
      HashSet<int> set2 = new HashSet<int>();
      set2.Add(100);
      set2.Add(200);
      Console.WriteLine("Elements in HashSet2...");
      foreach (int res in set2){
         Console.WriteLine(res);
      }
      Console.WriteLine("Is set1 a subset of set2? "+set1.IsSubsetOf(set2));
   }
}
This will produce the following output −
Elements in HashSet1...
100
200
Elements in HashSet2...
100
200
Is set1 a subset of set2? True
MySQL concatenation operator?

You can use in-built function CONCAT() from MySQL. The syntax is as follows −
SELECT CONCAT(('(',yourColumnName1,',', yourColumnName2,',',yourColumnName3,...N')')as anyVariableName from yourTableName;
To understand the above syntax, let us first create a table. The query to create a table is as follows −
mysql> create table Concatenation_OperatorDemo
-> (
->
-> VendorId int,
-> VendorName varchar(100),
-> VendorCountry varchar(100)
-> );
Query OK, 0 rows affected (0.69 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into Concatenation_OperatorDemo values(101,'Carol','US');
Query OK, 1 row affected (0.19 sec)

mysql> insert into Concatenation_OperatorDemo values(102,'Bob','UK');
Query OK, 1 row affected (0.18 sec)

mysql> insert into Concatenation_OperatorDemo values(103,'John','US');
Query OK, 1 row affected (0.14 sec)

mysql> insert into Concatenation_OperatorDemo values(104,'David','UK');
Query OK, 1 row affected (0.25 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from Concatenation_OperatorDemo;
The following is the output −
+----------+------------+---------------+
| VendorId | VendorName | VendorCountry |
+----------+------------+---------------+
| 101      | Carol      | US            |
| 102      | Bob        | UK            |
| 103      | John       | US            |
| 104      | David      | UK            |
+----------+------------+---------------+
4 rows in set (0.00 sec)
Now you can concat N number of columns using concat() function. Here, we will concat all three columns from the above table. The query to concat the column values are as follows −
mysql> select concat('(',VendorId,',', VendorName,',', VendorCountry,')')as
ConcatenationDemo
-> from Concatenation_OperatorDemo;
The following is the output −
+-------------------+
| ConcatenationDemo |
+-------------------+
| (101,Carol,US)    |
| (102,Bob,UK)      |
| (103,John,US)     |
| (104,David,UK)    |
+-------------------+
4 rows in set (0.00 sec)
C# - Bitwise Operators

The Bitwise operators supported by C# are listed in the following table. Assume variable A holds 60 and variable B holds 13, then −
The following example demonstrates all the bitwise operators available in C# −
using System;

namespace OperatorsAppl {

   class Program {
   
      static void Main(string[] args) {
         int a = 60;            /* 60 = 0011 1100 */ 
         int b = 13;            /* 13 = 0000 1101 */
         int c = 0; 
         
         c = a & b;             /* 12 = 0000 1100 */ 
         Console.WriteLine("Line 1 - Value of c is {0}", c );
         
         c = a | b;             /* 61 = 0011 1101 */
         Console.WriteLine("Line 2 - Value of c is {0}", c);
         
         c = a ^ b;             /* 49 = 0011 0001 */
         Console.WriteLine("Line 3 - Value of c is {0}", c);
         
         c = ~a;                /*-61 = 1100 0011 */
         Console.WriteLine("Line 4 - Value of c is {0}", c);
         
         c = a << 2;      /* 240 = 1111 0000 */
         Console.WriteLine("Line 5 - Value of c is {0}", c);
         
         c = a >> 2;      /* 15 = 0000 1111 */
         Console.WriteLine("Line 6 - Value of c is {0}", c);
         Console.ReadLine();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
Line 1 - Value of c is 12
Line 2 - Value of c is 61
Line 3 - Value of c is 49
Line 4 - Value of c is -61
Line 5 - Value of c is 240
Line 6 - Value of c is 15


    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
How to reverse the elements of an array using stack in java?

Stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example – a deck of cards or a pile of plates, etc.
A stack is first in first out, it has two main operations push and pop. Push inserts data in to it and pop retrieves data from it.
To reverse an array using stack initially push all elements in to the stack using the push() method then, retrieve them back using the pop() method into another array.
Live Demo
import java.util.Arrays;
import java.util.Stack;

public class ReversinArrayUsingStack {
   public static void main(String args[]) {
      Stack<Integer> stack = new Stack<Integer>();
      int[] myArray = {23, 93, 56, 92, 39};
      int size = myArray.length;
      for(int i=0; i<size; i++) {
         stack.push(myArray[i]);
      }
      int[] reverseArray = new int[size];
      for(int i=0; i<size; i++) {
         reverseArray[i] = stack.pop();
      }
      System.out.println("Reversed array is ::"+Arrays.toString(reverseArray));
   }
}
Reversed array is ::[39, 92, 56, 93, 23]
Python Program to Count the Frequency of Words Appearing in a String Using a Dictionary

When it is required to count the frequency of words that appear in a string with the help of dictionary, the ‘split’ method is used to split the values, and a list comprehension is used.
The list comprehension is a shorthand to iterate through the list and perform operations on it.
A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).
Below is a demonstration for the same −
 Live Demo
my_string = input("Enter the string :")
my_list=[]
my_list=my_string.split()
word_freq=[my_list.count(p) for p in my_list]
print("The frequency of words is ...")
print(dict(zip(my_list,word_freq)))
Enter the string :Hi jane how are you jane
The frequency of words is ...
{'Hi': 1, 'jane': 2, 'how': 1, 'are': 1, 'you': 1}
A string is entered by the user, and is assigned to a variable.
An empty list is created.
The string is split, and put in the list.
A list comprehension is used to iterate over the list, and the ‘count’ method is used to count the values.
This is assigned to a variable.
The list and word frequency are zipped, and converted to a dictionary.
It is then displayed on the console.
Convert a List to a Set in Java

In order to convert a List to a Set in Java, we can create an ArrayList and pass the List as an argument in the parameterized constructor of an HashSet. This can be done as follows −
List l = new ArrayList();
Set s = new HashSet(l);
Let us see a program to convert a list to a set in Java −
 Live Demo
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
public class Example {
   public static void main(String[] args) {
      List l = new ArrayList();
      l.add("Good");
      l.add("Morning");
      l.add("Morning");
      Set s = new HashSet(l);
      System.out.println(s);
   }
}
[Morning, Good]
Remove the top border from an element in Bootstrap 4

Use the border-top-0 class to remove the top border from an element.
Set the class as if we add any other class to an element −
<div class="mystyle border border-top-0">
  Top border is missing
</div>
Above, I have taken <div> as our element. Another class “mystyle” is also added that styles our div −
.mystyle {
  width: 350px;
  height: 170px;
  margin: 10px;
}
You can try to run the following code to work with the border-top-0 class in Bootstrap 4 −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <style>
    .mystyle {
      width: 350px;
      height: 170px;
      margin: 10px;
    }
    </style>
  </head>
<body>

<div class="container">
  <h2>Rectangle</h2>
  <div class="mystyle border border-top-0">Top border is missing</div>
</div>

</body>
</html>
Easy Steps To Plot Geographic Data on a Map — Python | by Ahmed Qassim | Towards Data Science

Assume that you are working in a startup and you need to conduct spatial data analysis and prediction to users’ geographical data. Or your company runs a lot of delivery operations and your job again to analyze, visualize and maybe predict the drivers or users’ geographical data. So, visualizing your data (predicted ones maybe) on a map will be very necessary.
In this article, I will go through easy steps of how to plot geographic data on any map using Python. The thing that I found it very useful and helpful in my previous projects using the same language: Python- check my article: Spatial Data Analysis for Traffic Management.
Off course, when we mention geographical data it crosses to our mind the coordinates of a data point which are: Longitude and Latitude. This is true, they are just the X and Y coordinates for a specific point on the map. However, there are other types of geographic data, such as polygon, line data. The main focus here will be on how to visualize points data on a map. shall we begin?
First, let us start by Loading the libraries
import numpy as npimport pandas as pdimport matplotlib.pyplot as plt
Loading the Spatial Dataset
df = pd.read_csv(‘C:/.. .../SpatialDataSet.txt’)
Taking a look at the dataset
df.head()
My dataset is a simple one (1444 rows × 2 columns). I have collected random geographical data points in Riyadh City for this demonstration.
Now, we have to define the Bounding Box. Bounding Box is the area defined by two longitudes and two latitudes that will include all spatial points.
BBox = ((df.longitude.min(),   df.longitude.max(),               df.latitude.min(), df.latitude.max())> (46.5691,46.8398, 24.6128, 24.8256)
Go to opestreetmap.org website and export the desired map as an image by first entering the bounding box data. I did the same as explained in the below image (more details are mentioned here as well: steps to export a map image).
Back to the coding environment and load the map image:
ruh_m = plt.imread('C:/.. ... /Riyadh_map.png')
Finally, plot the ‘df.longitude’ and ‘df.latitude’ coordinates as scatter points on the ‘ruh_m’ map image. Note that it is important to set up the X-axis and Y-axis as per the bounding box ‘BBox’
fig, ax = plt.subplots(figsize = (8,7))ax.scatter(df.longitude, df.latitude, zorder=1, alpha= 0.2, c='b', s=10)ax.set_title('Plotting Spatial Data on Riyadh Map')ax.set_xlim(BBox[0],BBox[1])ax.set_ylim(BBox[2],BBox[3])ax.imshow(ruh_m, zorder=0, extent = BBox, aspect= 'equal')
Can we ignore duplicate rows in COUNT?

Yes, we can ignore duplicate rows in COUNT using DISTINCT. Following is the syntax:
select count(distinct yourColumnName) from yourTableName;
In MySQL, COUNT() will display the number of rows. DISTINCT is used to ignore duplicate rows and get the count of only unique rows.
Let us first create a table:
mysql> create table DemoTable
(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   FirstName varchar(10)
);
Query OK, 0 rows affected (0.47 sec)
Following is the query to insert some records in the table using insert command:
mysql> insert into DemoTable(FirstName) values('Larry');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable(FirstName) values('John');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable(FirstName) values('Sam');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(FirstName) values('John');
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable(FirstName) values('John');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable(FirstName) values('Larry');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable(FirstName) values('Mike');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable(FirstName) values('Robert');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(FirstName) values('Carol');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(FirstName) values('Mike');
Query OK, 1 row affected (0.12 sec)
Following is the query to display records from the table using select command:
mysql> select *from DemoTable;
This will produce the following output:
+----+-----------+
| Id | FirstName |
+----+-----------+
|  1 | Larry     |
|  2 | John      |
|  3 | Sam       |
|  4 | John      |
|  5 | John      |
|  6 | Larry     |
|  7 | Mike      |
|  8 | Robert    |
|  9 | Carol     |
| 10 | Mike      |
+----+-----------+
10 rows in set (0.00 sec)
Following is the query to ignore duplicate rows in COUNT and get the count of only unique rows:
mysql> select count(distinct FirstName) from DemoTable;
This will produce the following output:
+---------------------------+
| count(distinct FirstName) |
+---------------------------+
|                         6 |
+---------------------------+
1 row in set (0.03 sec)
Compare two strings lexicographically in Java.

The compareTo() method of the String class. This method compares two Strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argument string. This method returns
a negative integer if current String object lexicographically precedes the argument string.
a positive integer if current String object lexicographically follows the argument
true when the strings are equal.
Live Demo
import java.lang.*;
public class StringDemo {
   public static void main(String[] args) {
      String str1 = "tutorials", str2 = "point";
      // comparing str1 and str2
      int retval = str1.compareTo(str2);
      // prints the return value of the comparison
      if (retval < 0) {
         System.out.println("str1 is greater than str2");
      } else if (retval == 0) {
         System.out.println("str1 is equal to str2");
      } else {
         System.out.println("str1 is less than str2");
      }
   }
}
str1 is less than str2
Java Program to subtract months from current date using Calendar.add() method

Import the following package for Calendar class in Java.
import java.util.Calendar;
Firstly, create a Calendar object and display the current date and time.
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date and Time = " + calendar.getTime());
Now, let us decrement the months using the calendar.add() method and Calendar.MONTH constant. Set a negative value since we are decrementing.
calendar.add(Calendar.MONTH, -10);
 Live Demo
import java.util.Calendar;
public class Demo {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date = " + calendar.getTime());
// Subtract 8 months from current date
calendar.add(Calendar.MONTH, -8);
System.out.println("Updated Date = " + calendar.getTime());
}
}
Current Date = Thu Nov 22 16:37:42 UTC 2018
Updated Date = Thu Mar 22 16:37:42 UTC 2018
8085 program for pulse waveform - GeeksforGeeks

31 Jan, 2022
Problem – Write a program to generate continuous square wave. Use D0 bit to output the square wave. The required waveform is:
Explanation –The alternate pattern of 0/1 bits can be provided by loading the accumulator with AAH(10101010) and rotating the pattern once through each loop. Bit D0 of the output port is used to proved logic 0 and 1. Therefore, all other bits can be masked by ANDing the accumulator with 01H.
Example –
Accumulator   : 1 0 1 0 1 0 1 0
And with 01H  : 0 0 0 0 0 0 0 1
Output        : 0 0 0 0 0 0 0 0
So output => 0

After RLC :

Accumulator   : 0 1 0 1 0 1 0 1 
And with 01H  : 0 0 0 0 0 0 0 1
Output        : 0 0 0 0 0 0 0 1
So output => 1

Program –
Program Description –
Register D is loaded with AAH(10101010).Bit pattern is moved to accumulator.Bit pattern is rotated left and saved again in register D. This save is necessary as accumulator is used again in the program.Mask all bits but 0th bit.Output A at port 1.
Register D is loaded with AAH(10101010).
Bit pattern is moved to accumulator.
Bit pattern is rotated left and saved again in register D. This save is necessary as accumulator is used again in the program.
Mask all bits but 0th bit.
Output A at port 1.
clintra
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Difference between SRAM and DRAM
8259 PIC Microprocessor
Direct Access Media (DMA) Controller in Computer Architecture
Introduction of Control Unit and its Design
Architecture of 8085 microprocessor
Difference between Hardwired and Micro-programmed Control Unit | Set 2
Pin diagram of 8086 microprocessor
Storage Structure in Operating Systems
Computer Architecture | Flynn's taxonomy
Read and write tar archive files using Python (tarfile)

The ‘tar’ utility was originally introduced for UNIX operating system. Its purpose is to collect multiple files in a single archive file often called tarball which makes it easy to distribute the files. Functions in tarfile module of Python’s standard library help in creating tar archives and extracting from the tarball as required. The archives can be constructed with gzip, bz2 and lzma compressions or without any compression at all.
Main function defined in this module is main() using which writing to tar file or reading from it is accomplished.
This function returns a TarFile object corresponding to file name which is provided to it as parameter. The function requires another parameter called mode, which by default is ‘r’ indicating no compression. Other modes are listed below
The module defines TarFile class. Instead of open() function, TarFile object can be instantiated by calling constructor.
This constructor also needs a file name and mode parameter. Possible values of mode parameter are as above.
Other methods in this class are as follows
This method adds a file to the archive. The method needs a name which can be name of file, directory, symbolic link,shortcut etc. Directories are recursively added by default. To prevent recursive addition set recursive parameter to False.
This method adds TarInfo object to the archive.
This method extracts all members of archive into current path if any other path is not explicitly provided.
This method extracts specified member to given path, default is current path.
Following example opens a tar file for compression with gzip algorithm and adds a file in it.
>>> fp = tarfile.open("zen.tar.gz","w:gz")
>>> fp.add("zen.txt")
>>> fp.close()
Assuming that ‘zen.txt’ file is present in current working directory, it will be added in ‘zen.tar.gz’ file.
Following code extracts the files from the tar archive and extracts all files (in this case there is only on) and puts them in current folder. To verify the result, you may delete or rename ‘zen.txt’ in current folder.
>>> fp = tarfile.open("zen.tar.gz","r:gz")
>>> fp.extractall()
>>> fp.close()
You will find that ‘zen.txt’ file will appear in the current directory.
To create a tar consisting of all files in current directory, use following code
import tarfile, glob
>>> fp=tarfile.open('file.tar','w')
>>> for file in glob.glob('*.*'):
fp.add(file)
>>> fp.close()
Creation and extraction of tar files can be achieved through command line interface. For example ‘lines.txt’ file is added in a tar file by following command executed in command window
C:\python36 >python -m tarfile -c line.tar lines.txt
Following command line options can be used.
Following command line will extract line.tar in newdir folder under current directory.
C:\python36>python -m tarfile -e line.tar newdir/
Following command line will list all files in the tar archive.
C:\python36>python -m tarfile -l files.tar
This article on tarfile module explained classes and functions defined in it.
How to create a vertical tab menu with CSS and JavaScript?


To create a vertical tab menu 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>
* {
   box-sizing: border-box
}
.tab {
   float: left;
   border: 1px solid blue;
   background-color: black;
   width: 20%;
   height: 200px;
}
.tab button {
   display: block;
   background-color: inherit;
   color: white;
   padding: 22px 16px;
   width: 100%;
   border: none;
   outline: none;
   text-align: left;
   cursor: pointer;
   transition: 0.3s;
   font-size: 17px;
}
.tab button:hover {
   background-color: gray;
}
.tab button.active {
   background-color: #006400;
}
.demo2 {
   float: left;
   padding: 0px 10px;
   border: 1px solid;
   width: 70%;
   border-left: none;
   height: 200px;
}
</style>
</head>
<body>
<h2>Examination</h2>
<p>Following is the exam information:</p>
<div class="tab">
   <button class="demo" onclick="infofunc(event, 'dates')" id="current">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";
}
document.getElementById("current").click();
</script>
</body>
</html>
This will produce the following output −
Click on any of the tabs, let’s say “Exam Centre” −
Minimum number of coins that make a given value

There is a list of coin C(c1, c2, ......Cn) is given and a value V is also given. Now the problem is to use the minimum number of coins to make the chance V.
Note: Assume there is the infinite number of coins C.
In this problem, we will consider a set of different coins C{1, 2, 5, 10} are given, There is the infinite number of coins of each type. To make change the requested value we will try to take the minimum number of coins of any type. As an example, for value 22: we will choose {10, 10, 2}, 3 coins as the minimum.
Input:
The required value. Say 48
Output:
Minimum required coins. Here the output is 7.
48 = 10 + 10 + 10 + 10 + 5 + 2 + 1
minCoins(coinList, n, value)
Input: list of different coins, number of coins, given value.
Output: Minimum number of coins to get given value.
Begin
   if value = 0, then
      return 0
   define coins array of size value + 1, fill with ∞
   coins[0] := 0

   for i := 1 to value, do
      for j := 0 to n, do
         if coinList[j] <= i, then
            tempCoins := coins[i-coinList[j]]
         if tempCoins ≠ ∞ and (tempCoins + 1) < coins[i], then
            coins[i] := tempCoins + 1
      done
   done

   return coins[value]
End


#include<iostream>
using namespace std;

int minCoins(int coinList[], int n, int value) {
   int coins[value+1];       //store minimum coins for value i

   if(value == 0)
      return 0;              //for value 0, it needs 0 coin

   coins[0] = 0;

   for (int i=1; i<=value; i++)
      coins[i] = INT_MAX;            //initially all values are infinity except 0 value

   for (int i=1; i<=value; i++) {      //for all values 1 to value, find minimum values
      for (int j=0; j<n; j++)
         if (coinList[j] <= i) {
            int tempCoins = coins[i-coinList[j]];
         if (tempCoins != INT_MAX && tempCoins + 1 < coins[i])
            coins[i] = tempCoins + 1;
      }
   }
   return coins[value];       //number of coins for value
}

int main() {
   int coins[] = {1, 2, 5, 10};
   int n = 4, value;
   cout << "Enter Value: "; cin >> value;
   cout << "Minimum "<<minCoins(coins, n, value)<<" coins required.";
   return 0;
}
Enter Value: 48
Minimum 7 coins required.
JavaScript - Date parse() Method

Javascript date parse() method takes a date string and returns the number of milliseconds since midnight of January 1, 1970.
Its syntax is as follows −
Date.parse(datestring)

Note − Parameters in the bracket are always optional.
datestring − A string representing a date
Number of milliseconds since midnight of January 1, 1970.
Try the following example.
<html>
   <head>
      <title>JavaScript parse Method</title>
   </head>
   
   <body>      
      <script type = "text/javascript">
         var msecs = Date.parse( "Aug 28, 2008 23:30:00" );
         document.write( "Number of milliseconds from 1970: " + msecs );
      </script>     
   </body>
</html>
Number of milliseconds from 1970: 1219946400000


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page