code-rag-bench/online-tutorials huggingface dataset:
How can Tensorflow be used to add dense layers on top using Python?

A dense layer can be added to the sequential model using the ‘add’ method, and specifying the type of layer as ‘Dense’. The layers are first flattened, and then a layer is added. This new layer will be applied to the entire training dataset.
Read More:
What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
We will use the Keras Sequential API, which is helpful in building a sequential model that is used to work with a plain stack of layers, where every layer has exactly one input tensor and one output tensor.
We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.
print("Adding dense layer on top")
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
print("Complete architecture of the model")
model.summary()
Code credit: https://www.tensorflow.org/tutorials/images/cnn
Adding dense layer on top
Complete architecture of the model
Model: "sequential_1"
_________________________________________________________________
Layer (type)                         Output Shape         Param #  
=================================================================
conv2d_3 (Conv2D)                  (None, 30, 30, 32)      896        
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 15, 15, 32)            0            
_________________________________________________________________
conv2d_4 (Conv2D)                  (None, 13, 13, 64)      18496      
_________________________________________________________________
max_pooling2d_3 (MaxPooling2 (None, 6, 6, 64)               0            
_________________________________________________________________
conv2d_5 (Conv2D)                  (None, 4, 4, 64)         36928      
_________________________________________________________________
flatten (Flatten)                  (None, 1024)               0            
_________________________________________________________________
dense (Dense)                        (None, 64)               65600      
_________________________________________________________________
dense_1 (Dense)                     (None, 10)               650        
=================================================================
Total params: 122,570
Trainable params: 122,570
Non-trainable params: 0
_________________________________________________________________
To complete the model, the last output tensor from the convolutional base (of shape (4, 4, 64)) is fed to one or more Dense layers to perform classification.
Dense layers will take vectors as input (which are 1D), and the current output is a 3D tensor.
Next, the 3D output is flattened to 1D, and one or more Dense layers are added on top.
CIFAR has 10 output classes, so a final Dense layer with 10 outputs is added.
The (4, 4, 64) outputs are flattened into vectors of shape (1024) before going through two Dense layers.
Angular Material 7 - Chips

The <mat-chip-list>, an Angular Directive, is used to a list of values as chips.
In this chapter, we will showcase the configuration required to draw a chip control using Angular Material.
Follow the following steps to update the Angular application we created in Angular 6 - Project Setup chapter −
Following is the content of the modified module descriptor app.module.ts.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatChipsModule} from '@angular/material'
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule,
      BrowserAnimationsModule,
      MatChipsModule,
      FormsModule,
      ReactiveFormsModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
export class AppModule { }
Following is the content of the modified HTML host file app.component.html.
<mat-chip-list>
   <mat-chip>One</mat-chip>
   <mat-chip>Two</mat-chip>
   <mat-chip color = "primary" selected>Tree</mat-chip>
   <mat-chip color = "accent" selected>Four</mat-chip>
</mat-chip-list>
Verify the result.
As first, we've created chip list using mat-chip-list.
Then, we've added chips to each chip list using mat-chip.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
What is Pass By Reference and Pass By Value in PHP?

In this article, we will learn about pass by value and pass by reference in PHP. 
Now, let’s understand these two concepts in detail.
In PHP generally, we followed to pass the arguments to the function with passed by value approach. We are following this practice because if the value of the argument within the function is changed, it does not get changed outside of the function.
In some cases we may need to modify function arguments, So to allow a function to modify its arguments, they must be passed by reference.
Let's begin with passed by reference. As it is already mentioned we can pass a variable by reference to a function so the function can modify the variable. To begin the process of passing the parameters passed by reference, prepend an ampersand (&) to the argument name in the function definition.
Let's test this with a simple example.
<?php
   function calculate(&$a){
      $a++;
   }
   $a=5;
   calculate($a);
   echo $a;
?>
6
Here we have declared variable aandpassingitaspassbyreferencetothefunctioncalculate().Soastheprinciplesaysifthevalueofthea gets changed inside the function then it will be also going to change outside the function.
There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. This is deprecated in 5.4 version of PHP when you use to calculate(&$a); it throws an error.
Let's test an example to understand pass by value.
<?php
   function calculate($a){
      $a++;
   echo $a."<br/>";
   }
   $a=5;
   calculate($a);
   echo $a;
?>
6
5
Here we have passed the value to the function calculate() as pass by value. Its value gets changed inside the function but that is not reflected outside the function. The value of the variable remains the same outside the function.
value_of_css_property() element method – Selenium Python

27 Apr, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies
This article revolves around how to use value_of_css_property method in Selenium. value_of_css_property method is used to get value of a css property for a element.
element.clear()
Example –
<input type="text" name="passwd" style="font-size:120px" id="passwd-id" />
To find an element one needs to use one of the locating strategies, For example,
element = driver.find_element_by_id("passwd-id")
element = driver.find_element_by_name("passwd")
element = driver.find_element_by_xpath("//input[@id='passwd-id']")
Also, to find multiple elements, we can use –
elements = driver.find_elements_by_name("passwd")
Now one can get this field’s css properties with
element.value_of_css_property('font-size')
Let’s try to get value_of_css_property of search field on geeksforgeeks.Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_id("gsc-i-id2")    # print widthprint(element.value_of_css_property('width'))
Output-
Terminal Output –
161px
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
BigDecimal equals() Method in Java

04 Dec, 2018
The java.math.BigDecimal.equals() method checks for equality of a BigDecimal value with the object passed. This method considers two BigDecimal objects equal if only if they are equal in value and scale.
Syntax:
public boolean equals(Object obj)
Parameters: This function accepts an Object obj as a mandatory parameter for comparison with this BigDecimal object.
Return Value: This method returns boolean true if and only if the Object passed as parameter is a BigDecimal whose value and scale are equal to that of this BigDecimal object and returns false otherwise. Thus, this function does not return true when it compares 124.0 and 124.0000.
Examples:
Input: 
b1 = new BigDecimal("4743.00")
b2 = new BigDecimal("4743.00000")
Output: false

Input: 
b1 = new BigDecimal(4743)
b2 = new BigDecimal("4743")
Output: true

Below programs illustrate equals() method of BigDecimal class:Program 1:
// Java program to demonstrate equals() method  import java.io.*;import java.math.*;  public class GFG {      public static void main(String[] args)    {          // Creating 2 BigDecimal objects        BigDecimal b1, b2;          b1 = new BigDecimal("4743.00");        b2 = new BigDecimal("4743.00000");          if (b1.equals(b2)) {            System.out.println(b1 + " and " + b2 + " are equal.");        }        else {            System.out.println(b1 + " and " + b2 + " are not equal.");        }    }}
4743.00 and 4743.00000 are not equal.

Program 2:
// Java program to demonstrate equals() method  import java.io.*;import java.math.*;  public class GFG {      public static void main(String[] args)    {          // Creating 2 BigDecimal objects        BigDecimal b1, b2;          b1 = new BigDecimal(67891);        b2 = new BigDecimal("67891");          if (b1.equals(b2)) {            System.out.println(b1 + " and " + b2 + " are equal.");        }        else {            System.out.println(b1 + " and " + b2 + " are not equal.");        }    }}
67891 and 67891 are equal.

Java-BigDecimal
Java-Functions
java-math
Java-math-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
List Interface in Java with Examples
Strings in Java
Different ways of Reading a text file in Java
Reverse an array in Java
How to remove an element from ArrayList in Java?
Checked vs Unchecked Exceptions in Java
ArrayList get(index) Method in Java with Examples
ArrayList to Array Conversion in Java : toArray() Methods
Comparator Interface in Java with Examples
Exceptions in Java
YACC program to implement a Calculator and recognize a valid Arithmetic expression

26 Aug, 2020
Problem: YACC program to implement a Calculator and recognize a valid Arithmetic expression.
Explanation:Yacc (for “yet another compiler compiler.”) is the standard parser generator for the Unix operating system. An open source program, yacc generates code for the parser in the C programming language. The acronym is usually rendered in lowercase but is occasionally seen as YACC or Yacc.
Examples:
Input: 4+5 
Output: Result=9
Entered arithmetic expression is Valid

Input: 10-5
Output: Result=5
Entered arithmetic expression is Valid

Input: 10+5-
Output: 
Entered arithmetic expression is Invalid

Input: 10/5
Output: Result=2
Entered arithmetic expression is Valid

Input: (2+5)*3
Output: Result=21
Entered arithmetic expression is Valid

Input: (2*4)+
Output: 
Entered arithmetic expression is Invalid

Input: 2%5
Output: Result=2
Entered arithmetic expression is Valid 
Lexical Analyzer Source Code:
%{   /* Definition section */  #include<stdio.h>  #include "y.tab.h"  extern int yylval;%}  /* Rule Section */%%[0-9]+ {          yylval=atoi(yytext);          return NUMBER;         }[\t] ;  [\n] return 0;  . return yytext[0];  %%  int yywrap(){ return 1;}
Parser Source Code :
%{   /* Definition section */  #include<stdio.h>  int flag=0;%}  %token NUMBER  %left '+' '-'  %left '*' '/' '%'  %left '(' ')'  /* Rule Section */%%  ArithmeticExpression: E{           printf("\nResult=%d\n", $$);           return 0;          }; E:E'+'E {$$=$1+$3;}   |E'-'E {$$=$1-$3;}   |E'*'E {$$=$1*$3;}   |E'/'E {$$=$1/$3;}   |E'%'E {$$=$1%$3;}   |'('E')' {$$=$2;}   | NUMBER {$$=$1;}   ;  %%  //driver codevoid main(){   printf("\nEnter Any Arithmetic Expression which                    can have operations Addition,                    Subtraction, Multiplication, Division,                           Modulus and Round brackets:\n");     yyparse();   if(flag==0)   printf("\nEntered arithmetic expression is Valid\n\n");}  void yyerror(){   printf("\nEntered arithmetic expression is Invalid\n\n");   flag=1;}
Output:
nidhi_biet
Lex program
Compiler Design
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Issues in the design of a code generator
Peephole Optimization in Compiler Design
Code Optimization in Compiler Design
Type Checking in Compiler Design
Directed Acyclic graph in Compiler Design (with examples)
Data flow analysis in Compiler
S - attributed and L - attributed SDTs in Syntax directed translation
Difference between Compiler and Interpreter
Introduction of Compiler Design
Runtime Environments in Compiler Design
Python | Longest String in list

11 Dec, 2019
Sometimes, while working with Python Lists, we can have a problem in which we receive Strings as elements and wish to compute the String which has maximum length. This kind of problem can have applications in many domains. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using loopThis is the brute method in which we perform this task. In this, we run a loop to keep a memory of longest string length and return the string which has max length in list.
# Python3 code to demonstrate working of# Longest String in list# using loop  # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks']  # printing original list print("The original list : " + str(test_list))  # Longest String in list# using loopmax_len = -1for ele in test_list:    if len(ele) > max_len:        max_len = len(ele)        res = ele  # printing resultprint("Maximum length string is : " + res)
The original list : ['gfg', 'is', 'best', 'for', 'geeks']
Maximum length string is : geeks

 
Method #2 : Using max() + keyThis method can also be used to solve this problem. In this, we use inbuilt max() with “len” as key argument to extract the string with the maximum length.
# Python3 code to demonstrate working of# Longest String in list# using max() + key  # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks']  # printing original list print("The original list : " + str(test_list))  # Longest String in list# using max() + keyres = max(test_list, key = len)  # printing resultprint("Maximum length string is : " + res)
The original list : ['gfg', 'is', 'best', 'for', 'geeks']
Maximum length string is : geeks

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Defaultdict in Python
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
Python | Split string into list of characters
Prototype - addClassName() Method

This method Adds a CSS class to element.
element.addClassName(className);

An HTML element in which CSS class is added.
<html>
   <head>
      <title>Prototype examples</title>
      <script type="text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function addClass() {
            node = $("firstDiv");
            node.addClassName("title");
         }
      </script>
   </head>

   <style type = "text/css">
      .title {
         color:#36C;
         font-size:20px;
      }
   </style>
   
   <body>
      <div id = "firstDiv">
         <p>This is first paragraph</p> 
      </div>
      <br />
      
      <input type = "button" value = "Add Class" onclick = "addClass();"/>
   </body>
</html>
This is first paragraph
Ruby | Array length() function

06 Dec, 2019
Array#length() : length() is a Array class method which returns the number of elements in the array.
Syntax: Array.length()
Parameter: Array
Return: the number of elements in the array.
Example #1 :
# Ruby code for length() method  # declaring arraya = [18, 22, 33, nil, 5, 6]  # declaring arrayb = [1, 4, 1, 1, 88, 9]  # declaring arrayc = [18, 22, 50, 6]  # length method exampleputs "length() method form : #{a.length()}\n\n"  puts "length() method form : #{b.length()}\n\n"  puts "length() method form : #{c.length()}\n\n"
Output :
length() method form : 6

length() method form : 6

length() method form : 4


Example #2 :
# Ruby code for length() method  # declaring arraya = ["abc", "nil", "dog"]  # declaring arrayc = ["cat", nil]  # declaring arrayb = ["cow", nil, "dog"]    # length method exampleputs "length() method form : #{a.length()}\n\n"  puts "length() method form : #{b.length()}\n\n"  puts "length() method form : #{c.length()}\n\n"
Output :
length() method form : 3

length() method form : 3

length() method form : 2


Ruby Array-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Global Variable in Ruby
Ruby | Enumerator each_with_index function
Ruby | Array select() function
Ruby | Case Statement
Ruby | unless Statement and unless Modifier
Ruby | Hash delete() function
Ruby | Data Types
Ruby | Array class find_index() operation
Ruby For Beginners
Equivalent for Row_Number() in SAP ABAP

When you want to modify the contents and store them into table and also to add a column for the value, use something like
DATA: my_string TYPE String
LOOP AT itab INTO wa_itab.
my_string = sy-tabix.
CONCATENATE some_text my_string more_text into wa_itab-my_field.
MODIFY itab FROM wa_itab.
CLEAR my_string.
ENDLOOP.
Cordova - Network Information

This plugin provides information about device's network.
To install this plugin, we will open command prompt and run the following code −
C:\Users\username\Desktop\CordovaProject>cordova plugin 
   add cordova-plugin-network-information

Let's create one button in index.html that will be used for getting info about network.
<button id = "networkInfo">INFO</button>
We will add three event listeners inside onDeviceReady function in index.js. One will listen for clicks on the button we created before and the other two will listen for changes in connection status.
document.getElementById("networkInfo").addEventListener("click", networkInfo);
document.addEventListener("offline", onOffline, false);
document.addEventListener("online", onOnline, false);
networkInfo function will return info about current network connection once button is clicked. We are calling type method. The other functions are onOffline and onOnline. These functions are listening to the connection changes and any change will trigger the corresponding alert message.
function networkInfo() {
   var networkState = navigator.connection.type;
   var states = {};
   states[Connection.UNKNOWN]  = 'Unknown connection';
   states[Connection.ETHERNET] = 'Ethernet connection';
   states[Connection.WIFI]     = 'WiFi connection';
   states[Connection.CELL_2G]  = 'Cell 2G connection';
   states[Connection.CELL_3G]  = 'Cell 3G connection';
   states[Connection.CELL_4G]  = 'Cell 4G connection';
   states[Connection.CELL]     = 'Cell generic connection';
   states[Connection.NONE]     = 'No network connection';
   alert('Connection type: ' + states[networkState]);
}

function onOffline() {
   alert('You are now offline!');
}

function onOnline() {
   alert('You are now online!');
}
When we start the app connected to the network, onOnline function will trigger alert.
If we press INFO button the alert will show our network state.
If we disconnect from the network, onOffline function will be called.

    45 Lectures 
     2 hours 

 Skillbakerystudios

    16 Lectures 
     1 hours 

 Nilay Mehta
 Print
 Add Notes
 Bookmark this page
C# | Count the total number of elements in the List

01 Feb, 2019
List class represents the list of objects which can be accessed by index. It comes under the System.Collection.Generic namespace. List class can be used to create a collection of different types like integers, strings etc. List class also provides the methods to search, sort, and manipulate lists. List.Count Property is used to get the total number of elements contained in the List.
Properties:
It is different from the arrays. A list can be resized dynamically but arrays cannot be.
List class can accept null as a valid value for reference types and it also allows duplicate elements.
If the Count becomes equals to Capacity then the capacity of the List increases automatically by reallocating the internal array. The existing elements will be copied to the new array before the addition of the new element.
Syntax:
list_name.Count
Below programs illustrate the use of Count property:
Example 1:
// C# code to get the number of// elements contained in Listusing System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main()    {          // Creating a List of integers        List<int> firstlist = new List<int>();          // adding elements in firstlist        for (int i = 4; i < 10; i++) {            firstlist.Add(i * 2);        }          // To get the number of        // elements in the List        Console.WriteLine(firstlist.Count);    }}
Output:
6

Example 2:
// C# code to get the number of// elements contained in Listusing System;using System.Collections.Generic;  class Geeks {      // Main Method    public static void Main()    {          // Creating a List of integers        List<int> firstlist = new List<int>();          // To get the number of        // elements in the List        Console.WriteLine(firstlist.Count);    }}
Output:
0

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.count?view=netframework-4.7.2
CSharp-Collections-Namespace
CSharp-Generic-List
CSharp-Generic-Namespace
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to make a case-insensitive query in MongoDB?

For a case-insensitive query, use regex in MongoDB. Let us create a collection with documents −
> db.demo314.insertOne({"Name":"Chris brown"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50d742f8647eb59e562056")
}
> db.demo314.insertOne({"Name":"David Miller"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50d743f8647eb59e562057")
}
> db.demo314.insertOne({"Name":"CHRIS BROWN"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50d744f8647eb59e562058")
}
> db.demo314.insertOne({"Name":"DAVID MILLER"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50d747f8647eb59e562059")
}
> db.demo314.insertOne({"Name":"chris brown"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e50d749f8647eb59e56205a")
}
Display all documents from a collection with the help of find() method −
> db.demo314.find();
This will produce the following output −
{ "_id" : ObjectId("5e50d742f8647eb59e562056"), "Name" : "Chris brown" }
{ "_id" : ObjectId("5e50d743f8647eb59e562057"), "Name" : "David Miller" }
{ "_id" : ObjectId("5e50d744f8647eb59e562058"), "Name" : "CHRIS BROWN" }
{ "_id" : ObjectId("5e50d747f8647eb59e562059"), "Name" : "DAVID MILLER" }
{ "_id" : ObjectId("5e50d749f8647eb59e56205a"), "Name" : "chris brown" }
Following is the query to make a case-insensitive query. This displays “chris brown” name available in every possible case in the document −
> db.demo314.find({"Name":/chris brown/i});
This will produce the following output −
{ "_id" : ObjectId("5e50d742f8647eb59e562056"), "Name" : "Chris brown" }
{ "_id" : ObjectId("5e50d744f8647eb59e562058"), "Name" : "CHRIS BROWN" }
{ "_id" : ObjectId("5e50d749f8647eb59e56205a"), "Name" : "chris brown" }
How to place an image into a frame in Tkinter?

To place an image into a Tkinter frame, you can follow the steps given below −
Import the required libraries and create an instance of tkinter frame. To open an image and place it inside the frame, we will use the Pillow (PIL) library.
Import the required libraries and create an instance of tkinter frame. To open an image and place it inside the frame, we will use the Pillow (PIL) library.
Set the size of the frame using geometry method.
Set the size of the frame using geometry method.
Create a frame and specify its height and width. Place the frame at the center of the window using place() method with anchor='center'.
Create a frame and specify its height and width. Place the frame at the center of the window using place() method with anchor='center'.
Open an image using ImageTk.PhotoImage(Image.open("image"))
Open an image using ImageTk.PhotoImage(Image.open("image"))
Next, create a label object inside the frame and pass the image inside the label.
Next, create a label object inside the frame and pass the image inside the label.
Finally, run the mainloop of the application window
Finally, run the mainloop of the application window
# Import required libraries
from tkinter import *
from PIL import ImageTk, Image

# Create an instance of tkinter window
win = Tk()

# Define the geometry of the window
win.geometry("700x500")

frame = Frame(win, width=600, height=400)
frame.pack()
frame.place(anchor='center', relx=0.5, rely=0.5)

# Create an object of tkinter ImageTk
img = ImageTk.PhotoImage(Image.open("forest.jpg"))

# Create a Label Widget to display the text or Image
label = Label(frame, image = img)
label.pack()

win.mainloop()
When we run the above code, it will display the following output −
HTML | <spacer> tag - GeeksforGeeks

27 Aug, 2019
The HTML <spacer> tag is used to create some white-space. This tag is history in HTML5, there is no more support in HTML5 also this tag does not support by any major browsers.Syntax:
<spacer type="" size="">
Attribute:
type: This attribute holds the value for the type of space horizontal, vertical or block.
size: This attribute holds a number of pixels for the horizontal or vertical type of spacer.
height: This attribute holds the pixel number for block type spacer.
width: This attribute holds the pixel number for block type spacer.
align: This attribute holds the alignment of the block of white-space.
Below example illustrate the HTML <spacer> tag:Example:
<!DOCTYPE html><html>  <head>    <title>HTML <spacer> Tag</title>    <style>        h1 {            color: green;        }    </style></head>  <body>    <center>        <h1>GeeksforGeeks</h1>        <h2>HTML <spacer> tag</h2>        <p>A Computer Science Portal            <spacer type="block" width="50" /> for Geeks</p>      </center></body>  </html>
Output:
Supported Browsers: The <spacer> tag does not supported by major browsers:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Tags
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML Cheat Sheet - A Basic Guide to HTML
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Tryit Editor v3.7

Tryit: HTML italic text
Boolean list initialization in Python

There are scenarios when we need to get a list containing only the Boolean values like true and false. In this article how to create list containing only Boolean values.
We use range function giving it which is the number of values we want. Using a for loop we assign true or false today list as required.
 Live Demo
res = [True for i in range(6)]
# Result
print("The list with binary elements is : \n" ,res)
Running the above code gives us the following result −
The list with binary elements is :
[True, True, True, True, True, True]
The * operator can repeat the same value required number of times. We use it to create a list with a Boolean value.
 Live Demo
res = [False] * 6
# Result
print("The list with binary elements is : \n" ,res)
Running the above code gives us the following result −
The list with binary elements is :
[False, False, False, False, False, False]
We can also use the byte array function which will give us 0 as default value.
 Live Demo
res = list(bytearray(5))
# Result
print("The list with binary elements is : \n" ,res)
Running the above code gives us the following result −
The list with binary elements is :
[0, 0, 0, 0, 0]
Compute pearson product-moment correlation coefficients of two given NumPy arrays - GeeksforGeeks

02 Sep, 2020
In NumPy, We can compute pearson product-moment correlation coefficients of two given arrays with the help of numpy.corrcoef() function.
In this function, we will pass arrays as a parameter and it will return the pearson product-moment correlation coefficients of two given arrays.
Syntax: numpy.corrcoef(x, y=None, rowvar=True, bias=, ddof=)Return: Pearson product-moment correlation coefficients
Let’s see an example:
Example 1:
Python
# import libraryimport numpy as np  # create numpy 1d-arrayarray1 = np.array([0, 1, 2])array2 = np.array([3, 4, 5])  # pearson product-moment correlation# coefficients of the arraysrslt = np.corrcoef(array1, array2)  print(rslt)
Output
[[1. 1.]
 [1. 1.]]

Example 2:
Python
# import numpy libraryimport numpy as np  # create a numpy 1d-arrayarray1 = np.array([ 2, 4, 8])array2 = np.array([ 3, 2,1])    # pearson product-moment correlation# coefficients of the arraysrslt2 = np.corrcoef(array1, array2)  print(rslt2)
Output
[[ 1.         -0.98198051]
 [-0.98198051  1.        ]]

Python numpy-program
Python numpy-Statistics Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Defaultdict in Python
Python OOPs Concepts
Python | os.path.join() method
Python | Pandas dataframe.groupby()
JSON - Comparison with XML

JSON and XML are human readable formats and are language independent. They both have support for creation, reading and decoding in real world situations. We can compare JSON with XML, based on the following factors −
XML is more verbose than JSON, so it is faster to write JSON for programmers.
XML is used to describe the structured data, which doesn't include arrays whereas JSON include arrays.
JavaScript's eval method parses JSON. When applied to JSON, eval returns the described object.
Individual examples of XML and JSON −
{
   "company": Volkswagen,
   "name": "Vento",
   "price": 800000
}
<car>
   <company>Volkswagen</company>
   <name>Vento</name>
   <price>800000</price>
</car>

    20 Lectures 
     1 hours 

 Laurence Svekis

    16 Lectures 
     1 hours 

 Laurence Svekis

    10 Lectures 
     1 hours 

 Laurence Svekis

    23 Lectures 
     2.5 hours 

 Laurence Svekis

    9 Lectures 
     48 mins

 Nilay Mehta

    18 Lectures 
     2.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
HTTP headers | Accept-Charset

07 Nov, 2019
The HTTP Accept-Charset is a request type header. This header is used to indicate what character set are acceptable for the response from the server. The accept-charset header specifies the character encodings which are accepted by the client and this header also allows a user-agent to specify the charsets it supports.With the help of content negotiation it selects the type of encoding and then uses it to inform the client of its choice with the Content-Type response header, which is usually present in charset= parameter. Our Web-Browser usually doesn’t send this header, as transmitting it would allow fingerprinting and the default value for each resource is usually correct. If this Header is not present, a user-agent would have to specify each charset parameter for each text/* media type it accepted, e.g.
Accept: text/html;charset=US-ASCII, text/html;charset=UTF-8, text/plain;
charset=US-ASCII,text/plain;charset=UTF-8
Note: When the server fails to serve any character encoding form this request, it will send back a 406 Not Acceptable error code so to avoid this and provide better user experience if no Accept-Charset header is present, the default is that any character set is acceptable.
Syntax:
This is the for single charset.Accept-Charset: <charset>
Accept-Charset: <charset>
This syntax works to select multiple character sets with quality value.Accept-Charset: <charset>,  <charset> ;q= 
Accept-Charset: <charset>,  <charset> ;q= 
Directives: This header accepts three directives as mentioned above and described below:
<charset>: This directive holds the charset type, any character encoding name, like UTF-32 ,UTF-16 or iso-8859-15.
*: This directive is used as a wildcard for any character not mentioned in anywhere in header.
Note: This ;q= defines the factor weighting, value placed in an order of preference expressed using a relative quality value.
Examples:
In this example single value is on Accept-Charset headerAccept-Charset: iso-8859-5
Accept-Charset: iso-8859-5
In this example double value is Accept-Charset headerAccept-Charset: utf-8, iso-8859-1;q=0.7
Accept-Charset: utf-8, iso-8859-1;q=0.7
In this example double value is Accept-Charset header with the second one using “ * “ wildcard to select all encodingsAccept-Charset: utf-8, iso-8859-1;q=0.7, *;q=0.9
Accept-Charset: utf-8, iso-8859-1;q=0.7, *;q=0.9
Supported Browsers: The browsers are not compatible with HTTP Accept-Charset header.
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How do I drop a primary key in MySQL?

To drop a primary key, use ALTER at first to alter the table. With that, use DROP to drop the key as in the below
alter table yourTableName drop primary key;
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> StudentId int NOT NULL,
   -> StudentName varchar(20),
   -> StudentAge int,
   -> primary key(StudentId)
   -> );
Query OK, 0 rows affected (0.48 sec)
Here is the query to check the description of table −
mysql> desc DemoTable;
This will produce the following output−
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| StudentId   | int(11)     | NO   | PRI | NULL    |       |
| StudentName | varchar(20) | YES  |     | NULL    |       |
| StudentAge  | int(11)     | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
Following is the query to drop a primary key in MySQL −
mysql> alter table DemoTable drop primary key;
Query OK, 0 rows affected (1.70 sec)
Records: 0 Duplicates: 0 Warnings: 0
Let us check the table description once again −
mysql> desc DemoTable;
This will produce the following output −
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| StudentId   | int(11)     | NO   |     | NULL    |       |
| StudentName | varchar(20) | YES  |     | NULL    |       |
| StudentAge  | int(11)     | YES  |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
Exception Handling in Java - GeeksQuiz

30 Sep, 2018
Main.java:4: error: incompatible types
         throw 10;
               ^
  required: Throwable
  found:    int
Main.java:6: error: unexpected type
      catch(int e) {
            ^
  required: class
  found:    int
2 errors
Got the Test Exception
Inside finally block 
Got the Test Exception
Inside finally block 
Main.java:12: error: exception Derived has already been caught
    catch(Derived d)  { System.out.println("Caught derived class exception"); } 
a = 0
Divide by zero error
inside the finally block

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Variable initialization in C++

Variables are the names given by the user. A datatype is also used to declare and initialize a variable which allocates memory to that variable. There are several datatypes like int, char, float etc. to allocate the memory to that variable.
There are two ways to initialize the variable. One is static initialization in which the variable is assigned a value in the program and another is dynamic initialization in which the variables is assigned a value at the run time.
The following is the syntax of variable initialization.
datatype variable_name = value;
Here,
datatype − The datatype of variable like int, char, float etc.
variable_name − This is the name of variable given by user.
value − Any value to initialize the variable. By default, it is zero.
The following is an example of variable initialization.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int a = 20;
   int b;
   cout << "The value of variable a : "<< a; // static initialization
   cout << "\nEnter the value of variable b : "; // dynamic initialization
   cin >> b;
   cout << "\nThe value of variable b : "<< b;
   return 0;
}
The value of variable a : 20
Enter the value of variable b : 28
The value of variable b : 28
In the above program, two variables are declared a and b.
int a = 20;
int b;
The variable a is initialized with a value in the program while the variable b is initialized dynamically.
cout << "The value of variable a : "<< a; // static initialization
cout << "\nEnter the value of variable b : "; // dynamic initialization
cin >> b;
cout << "\nThe value of variable b : "<< b;
The Initialize Method in Ruby

25 Sep, 2019
The initialize method is useful when we want to initialize some class variables at the time of object creation. The initialize method is part of the object-creation process in Ruby and it allows us to set the initial values for an object.
Below are some points about Initialize :
We can define default argument.
It will always return a new object so return keyword is not used inside initialize method
Defining initialize keyword is not necessary if our class doesn’t require any arguments.
If we try to pass arguments into new and if we don’t define initialize we are going to get an error.
Syntax:
def initialize(argument1, argument2, .....)
Example :
# Ruby program of Initialize methodclass Geeks    # Method with initialize keyword  def initialize(name)  endend
Output :
=> :initialize
In above example, we add a method called initialize to the class, method have a single argument name. using initialize method will initialize a object.
Example :
# Ruby program of Initialize methodclass Rectangle    # Method with initialize keyword  def initialize(x, y)      # Initialize variable    @x = x    @y = y  endend  # create a new Rectangle instance by calling Rectangle.new(10, 20)
Output :
#<Rectangle:0x0000555e7b1ba0b0 @x=10, @y=20>
In above example, Initialize variable are accessed using the @ operator within the class but to access them outside of the class we will use public methods.
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby For Beginners
Ruby | Array class find_index() operation
Ruby | String concat Method
Ruby on Rails Introduction
Ruby | Types of Variables
Ruby | Array shift() function
PHP | strtoupper() Function

08 Mar, 2018
The strtoupper() function is used to convert a string into uppercase. This function takes a string as parameter and converts all the lowercase english alphabets present in the string to uppercase. All other numeric characters or special characters in the string remains unchanged.
Syntax:
string strtoupper ( $string )

Parameter: The only parameter to this function is a string that is to be converted to upper case.
Return value: This function returns a string in which all the alphabets are uppercase.
Examples:
Input : $str  = "GeeksForGeeks"
        strtoupper($str)
Output: GEEKSFORGEEKS

Input : $str  = "going BACK he SAW THIS 123$#%"
        strtoupper($str)
Output: GOING BACK HE SAW THIS 123$#%

Below programs illustrate the strtoupper() function in PHP:
Program 1
<?php  // original string$str = "GeeksForGeeks";  // string converted to upper case$resStr = strtoupper($str);  print_r($resStr);  ?>
Output:
GEEKSFORGEEKS

Program 2
<?php  // original string$str = "going BACK he SAW THIS 123$#%";  // string to upper case$resStr = strtoupper($str);  print_r($resStr);  ?>
Output:
GOING BACK HE SAW THIS 123$#%

Reference:http://php.net/manual/en/function.strtoupper.php
PHP-function
PHP-string
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
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 ?
How to count the number of words in a text file using Java?

Read the number of words in text file
Create a FileInputStream object by passing the required file (object) as a parameter to its constructor.
Read the contents of the file using the read() method into a byte array.
 Insatiate a String class by passing the byte array to its constructor.
Using split() method read the words of the String to an array.
Create an integer variable, initialize it with 0, int the for loop for each element of the string array increment the count.
import java.io.File;
import java.io.FileInputStream;
public class Sample {
   public static void main(String args[]) throws Exception{

      int count =0;
      File file = new File("data");
      FileInputStream fis = new FileInputStream(file);
      byte[] bytesArray = new byte[(int)file.length()];
      fis.read(bytesArray);
      String s = new String(bytesArray);
      String [] data = s.split(" ");
      for (int i=0; i<data.length; i++) {
         count++;
      }
      System.out.println("Number of characters in the given file are " +count);
   }
}
Number of characters in the given String are 4
Difference between Server OS and Client OS

02 Jul, 2020
1. Client OS :It is an operating system that operates within desktop. It is used to obtain services from a server. It run on the client devices like laptop, computer and is very simple operating system.
2. Server OS :It is an operating system that is designed to be used on server. It is used to provide services to multiple client. It can serve multiple client at a time and is very advanced operating system.
Difference between Server OS and Client OS :
Computer Networks
Difference Between
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – How to change font and size of Label text ?

26 Mar, 2020
A label is a graphical control element which displays text on a form. A label is generally used to identify a nearby text box or other widget. Some labels can respond to events such as mouse clicks, allowing the text of the label to be copied, but this is not standard user-interface practice.
In this article, we will see how to change the font and size of the text in Label, we can do this by using setFont() method.
Syntax : label.setFont(QFont(font_name, size))
Argument : It take two argument :1. Font name it can be ‘Arial’, ‘Times’ etc.2. Size to be set in integer.
Below is the Python implementation –
# importing the required libraries  from PyQt5.QtWidgets import * from PyQt5.QtGui import * import sys  class Window(QMainWindow):    def __init__(self):        super().__init__()          # set the title        self.setWindowTitle("Label")          # setting  the geometry of window        self.setGeometry(0, 0, 400, 300)          # creating a label widget        # by default label will display at top left corner        self.label_1 = QLabel('Arial font', self)          # moving position        self.label_1.move(100, 100)          # setting font and size        self.label_1.setFont(QFont('Arial', 10))          # creating a label widget        # by default label will display at top left corner        self.label_2 = QLabel('Times font', self)          # moving position        self.label_2.move(100, 120)          # setting font and size        self.label_2.setFont(QFont('Times', 10))            # show all the widgets        self.show()      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
LongStream sum() in Java - GeeksforGeeks

06 Dec, 2018
LongStream sum() returns the sum of elements in this stream. This is a special case of a reduction. LongStream sum() is a terminal operation i.e, it may traverse the stream to produce a result or a side-effect.
Note : A reduction operation (also called a fold) takes a sequence of input elements and combines them into a single summary result by repeated application of a combining operation, such as finding the sum or maximum of a set of numbers.
Syntax :
long sum()

Return Value : The function returns the sum of elements in this stream.
Example 1 :
// Java code for LongStream.sum() to// find the sum of elements in LongStreamimport java.util.*;import java.util.stream.LongStream;  class GFG {      // Driver code    public static void main(String[] args)    {        // Creating an LongStream        LongStream stream = LongStream.of(2L, 4L, 6L, -2L, -4L);          // Using LongStream.sum() to find        // sum of elements in LongStream        long sumOfElements = stream.sum();          // Displaying the calculated sum        System.out.println(sumOfElements);    }}
6

Example 2 :
// Java code for LongStream.sum() to// find the sum of elements// divisible by 3 in given rangeimport java.util.*;import java.util.stream.LongStream;  class GFG {      // Driver code    public static void main(String[] args)    {        // Using LongStream.sum() to find        // sum of elements dividible by 3        // in given range        long sumOfElements = LongStream.range(2L, 10L)                                 .filter(num -> num % 3 == 0)                                 .sum();          // Displaying the calculated sum        System.out.println(sumOfElements);    }}
18

Java - util package
Java-Functions
java-longstream
java-stream
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Generics in Java
Comparator Interface in Java with Examples
Strings in Java
Difference between Abstract Class and Interface in Java
How to remove an element from ArrayList in Java?