code-rag-bench/online-tutorials huggingface dataset:
TCL script to find sum of n natural numbers using looping statements

26 Apr, 2021
In this article, we will discuss the overview of TCL script and will cover the TCL script to find the sum of n natural numbers using looping statements with the help of an example. Let’s discuss it one by one.
Pre-requisite –You can go through this article to understand a few basics through this link. https://www.geeksforgeeks.org/basics-of-ns2-and-otcltcl-script/.
Overview :We will understand the syntax of the while loop and for loop in Tool Command Language with a simple example. In this example, we will first use the while loop to find the sum of the first n natural numbers, and then we will see how to use for loop to accomplish the same. We will also compare the syntax with a familiar language to understand it better. 
While-loop implementation :We will discuss the implementation steps as follows.
Step-1 :The first step is to read a number from the user after prompting to do so. To read the number we use gets, and we use puts to give a prompt.
puts "Enter a number"
gets stdin b
Step-2 :Our next step is to initialize the sum to 0 and the iteration variable, i to 0. After this, we can have the while loop implementation of the code.
set sum 0
set i 0
while {$i<=$b} {
 set sum [expr $sum+$i]
 incr i
}
Note – The syntax of the while loop must be exactly as shown above. If you neglect the spaces or type the opening curly brace in a new line, the result will be an error.
Step-3 :The implementation of the while loop specified above would like the following in C programming as follows. 
sum=0;
i=0;
while(i<=b)
{
sum=sum+i;
i++;  
}
Step-4 :Finally, the whole code and output are as follows.Code –
puts "Enter a number"
gets stdin b
set sum 0
set i 0
while {$i<=$b} {
 set sum [expr $sum+$i]
 incr i
}
puts "The sum of first $b natural numbers is $sum"
Output :
For-loop implementation :We will discuss the implementation steps as follows.
Step-1 :The first 2 lines of code are the same as in the while loop. So, let’s look at the for loop implementation part.
set sum 0
for {set i 1} {$i<=$b} {incr i} {
set sum [expr $sum+$i]
}
Note – The syntax of for loop must be exactly as shown above. If you neglect the spaces or type the opening curly brace in a new line, the result will be an error.
Step-2 :The implementation of the for loop specified above would like the following in C programming as follows.
sum=0;
for(i=1;i<=n;i++)
{
sum=sum+i;
}
Step-3 :Finally, let’s view the entire code and its output as follows.Code –
puts "Enter a number"
gets stdin b
set sum 0
for {set i 1} {$i<=$b} {incr i} {
set sum [expr $sum+$i]
}
puts "The sum of first $b natural numbers is $sum"
Output :
loop
Computer Networks
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install cx_oracle in Python on Windows?

22 Sep, 2021
The cx_oracle package is used to connect with the Oracle database using python. In this, article, we will look into the process of installing the cx_oracle package on Windows.
The only thing that you need for installing the Scrapy module on Windows are:
Python 
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install cx_oracle
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
To verify if Pywin32 has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
conda list cx_oracle 
You’ll get the below message if the installation is complete:
If you want the installation to be done through PIP,  open up the Command Prompt and use the below command:
pip install cx_oracle
You will get a similar message once the installation is complete:
To verify if the cx_oracle package has been successfully installed in your system run the below command in Command Prompt:
python -m pip show cx_oracle 
You’ll get the below message if the installation is complete:
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
EOF, getc() and feof() in C

28 May, 2017
In C/C++, getc() returns EOF when end of file is reached. getc() also returns EOF when it fails. So, only comparing the value returned by getc() with EOF is not sufficient to check for actual end of file. To solve this problem, C provides feof() which returns non-zero value only if end of file has reached, otherwise it returns 0.For example, consider the following C program to print contents of file test.txt on screen. In the program, returned value of getc() is compared with EOF first, then there is another check using feof(). By putting this check, we make sure that the program prints “End of file reached” only if end of file is reached. And if getc() returns EOF due to any other reason, then the program prints “Something went wrong”
#include <stdio.h>  int main(){  FILE *fp = fopen("test.txt", "r");  int ch = getc(fp);  while (ch != EOF)   {    /* display contents of file on screen */     putchar(ch);       ch = getc(fp);  }      if (feof(fp))     printf("\n End of file reached.");  else      printf("\n Something went wrong.");  fclose(fp);        getchar();  return 0;}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-File Handling
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Substring in C++
Function Pointer in C
Different Methods to Reverse a String in C++
std::string class in C++
Unordered Sets in C++ Standard Template Library
What is the purpose of a function prototype?
Enumeration (or enum) in C
C Language Introduction
Operators in C / C++
Power Function in C/C++
Reading QR codes using Node.js

12 Feb, 2021
When we are working with Node.js to build any application, we might want our apps to interact with external apps or payment gateways that provide QR codes to communicate the information. In this article, we will see how we can decode a QR code in our node.js applications. 
Let’s set up our workspace by executing these commands:
Creating directory:
npm init -y
mkdir src
cd src
nano app.js
Installing packages:
We need to install an npm package in order to work ahead.
To work with the qrcode-reader, we also need an image parser. Jimp Module is used for image parsing.
npm install qrcode-reader jimp
Suppose we have an image of a QR code in the same directory as our source code. We need the data embedded in the image.
First import all the packages in app.js
var Jimp = require("jimp");
var fs = require('fs')
var QrCode = require('qrcode-reader');
Now we need to load our QR code:
// Read the image and create a buffer  
// (Here image.png is our QR code)
var buffer = fs.readFileSync(__dirname + '/image.png');
Parse the image using Jimp module and use decode() method of qrcode-reader package:
// Parse the image  
Jimp.read(buffer, function(err, image) {
   if (err) {
       console.error(err);
   }
   let qrcode = new qrCode();
   qrcode.callback = function(err, value) {
       if (err) {
           console.error(err);
       }
       console.log(value.result);
   };
   qrcode.decode(image.bitmap);
});
Here we can read the data that is in string format.
Index.js
Javascript
//Importing jimp modulevar Jimp = require("jimp");// Importing filesystem modulevar fs = require('fs')// Importing qrcode-reader modulevar qrCode = require('qrcode-reader'); // Read the image and create a buffer// (Here image.png is our QR code)var buffer = fs.readFileSync(__dirname + '/image.png'); // Parse the image using Jimp.read() methodJimp.read(buffer, function(err, image) {    if (err) {        console.error(err);    }    // Creating an instance of qrcode-reader module    let qrcode = new qrCode();    qrcode.callback = function(err, value) {        if (err) {            console.error(err);        }        // Printing the decrypted value        console.log(value.result);    };    // Decoding the QR code    qrcode.decode(image.bitmap);});
Run index.js file using the following command: 
node index.js
Output:
Output data 
mridulmanochagfg
Node.js-Misc
JavaScript
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TextDecoder and TextEncoder in Javascript?

TextEncoder is used to convert a given string to utf-8 standard. It retunes an Uint8Array from the string.
TextDecoder is used to covert a stream of bytes into a stream of code points. It can decode UTF-8 , ISO-8859-2, KOI8-R, GBK etc.
Following is the code for TextDecoder and TextEncoder in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result,.sample {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
   }
   .result {
      color: red;
   }
</style>
</head>
<body>
<h1>TextDecoder and TextEncoder in Javascript</h1>
<div class="sample"></div>
<button class="Btn">ENCODE STRING</button>
<div class="result"></div>
<h3>Click on the above button to encode the above string</h3>
<div class="sample"></div>
<button class="Btn">Decode STRING</button>
<div class="result"></div>
<h3>Click on the above button to decode the above string</h3>
<script>
   let BtnEle = document.querySelectorAll(".Btn");
   let sampleEle = document.querySelectorAll(".sample");
   let resEle = document.querySelectorAll(".result");
   let str = "Hello world";
   let str1 = new Uint8Array([119, 111, 114, 108, 100]);
   sampleEle[0].innerHTML = str;
   sampleEle[1].innerHTML = str1;
   BtnEle[0].addEventListener("click", () => {
      let textEncoder = new TextEncoder();
      resEle[0].innerHTML += "Encoded String = " + textEncoder.encode(str) + "<br>";
   });
   BtnEle[1].addEventListener("click", () => {
      let textDecoder = new TextDecoder();
      resEle[1].innerHTML += "Decoded String = " + textDecoder.decode(str1) + "<br>";
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘ENCODE STRING’ button −
On clicking the ‘Decode STRING’ button −
How to convert left linear grammar to right linear grammar?

Regular grammar describes a regular language. It consists of four components, which are as follows −
G = (N, E, P, S)
Where,
N: finite set of non-terminal symbols,
N: finite set of non-terminal symbols,
E: a finite set of terminal symbols,
E: a finite set of terminal symbols,
P: a set of production rules, each of one is in the forms
P: a set of production rules, each of one is in the forms
S → aB
S → aB
S → a
S → a
S → ∈,
S → ∈,
S ∈ N is the start symbol.
S ∈ N is the start symbol.
The above grammar can be of two forms −
Right Linear Regular Grammar
Right Linear Regular Grammar
Left Linear Regular Grammar
Left Linear Regular Grammar
Now, let us see the steps to convert left linear grammar to right linear grammar −
Consider a left linear grammar as given below −
S→ Sa|Abc
A→ Sa|Ab|a
Step 1 − We will convert the given left linear grammar to finite automata.
Step 2 − We will now interchange the initial and final state.
Step 3 − Now we will reverse the direction of all transactions.
Step 4 − We will construct the regular grammar for the above finite automata which will be right linear grammar, as shown below −
C→aA
A→bA|cb
S→aS
Consider another example
The given left linear grammar is −
S→S10|S11|B|e
B→B0|0
First eliminate non-deterministic of grammar
S→SA|B|e
A→10|11
B→B0|0
So, the right linear grammar is −
S→BS’|S’
S’→e|10S’|11S’
B→0B’
B’→0B’|e
Replace 0 with NA in R DataFrame - GeeksforGeeks

31 Aug, 2021
In this article, we are going to discuss how to replace 0 with NA values in dataframe in R Programming Language.
NA stands for Null values which can represent Null data / Null elements in a dataframe. The task can be achieved by first defining a dataframe that contains 0 as values. Then we can replace 0 with NA by using index operator [].
Syntax:
dataframe[dataframe== 0] = NA
where,
dataframe is the input dataframe
In index we are checking if the value is 0, if it is 0 then we are replacing it as NA
Example: Replacing 0 with NA for integer data
R
# create a dataframe with 0 # along with numeric values and displaydata=data.frame(column1=c(1,2,3,0,0),                column2=c(0,1,0,2,0)) # Actual datadata # replace 0 with NAdata[data==0]=NA print("===============") # displaydata
Output:
Example: R program to create a dataframe with strings along with 0 and replace 0 with NA
R
# create a dataframe with 0 # along with string values and displaydata=data.frame(column1=c("sravan","Bobby","ojaswi",0,0),                column2=c(0,"Rohith",0,"Gnanesh",0)) # Actual datadata # replace 0 with NAdata[data==0]=NA print("===============") # displaydata
Output:
adnanirshad158
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R
newScheduledThreadPool Method

A scheduled thread pool can be obtainted by calling the static newScheduledThreadPool() method of Executors class.
ExecutorService executor = Executors.newScheduledThreadPool(1);

The following TestThread program shows usage of newScheduledThreadPool method in thread based environment.
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

public class TestThread {

   public static void main(final String[] arguments) throws InterruptedException {
      final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

      final ScheduledFuture<?> beepHandler = 
         scheduler.scheduleAtFixedRate(new BeepTask(), 2, 2, TimeUnit.SECONDS);

      scheduler.schedule(new Runnable() {

         @Override
         public void run() {
            beepHandler.cancel(true);
            scheduler.shutdown();			
         }
      }, 10, TimeUnit.SECONDS);
   }  

   static class BeepTask implements Runnable {

      public void run() {
         System.out.println("beep");      
      }
   }
}
This will produce the following result.
beep
beep
beep
beep


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Projection Operations in LINQ

Projection is an operation in which an object is transformed into an altogether new form with only specific properties.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Operators {
   class Program {
      static void Main(string[] args) {
      
         List<string> words = new List<string>() { "an", "apple", "a", "day" };

         var query = from word in words select word.Substring(0, 1);

         foreach (string s in query)
            Console.WriteLine(s);
            Console.ReadLine();
      }
   }
}
Module Module1

   Sub Main()
   
      Dim words = New List(Of String) From {"an", "apple", "a", "day"}

      Dim query = From word In words Select word.Substring(0, 1);

      Dim sb As New System.Text.StringBuilder()
	  
      For Each letter As String In query
         sb.AppendLine(letter)
         Console.WriteLine(letter)
      Next
         Console.ReadLine()
		 
   End Sub
   
End Module
When the above code in C# or VB is compiled and executed, it produces the following result −
a
a
a
d

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Operators {
   class Program {
      static void Main(string[] args) {
      
         List<string> phrases = new List<string>() { "an apple a day", "the quick brown fox" };

         var query = from phrase in phrases
                     from word in phrase.Split(' ')
                     select word;

         foreach (string s in query)
            Console.WriteLine(s);
            Console.ReadLine();
      }
   }
}
Module Module1

   Sub Main()
   
      Dim phrases = New List(Of String) From {"an apple a day", "the quick brown fox"}

      Dim query = From phrase In phrases 
                  From word In phrase.Split(" "c) 
                  Select word;

      Dim sb As New System.Text.StringBuilder()
	  
      For Each str As String In query
         sb.AppendLine(str)
         Console.WriteLine(str)
      Next 
         Console.ReadLine()
		 
   End Sub
   
End Module
When the above code in C# or VB is compiled and executed, it produces the following result −
an
apple
a
day
the
quick
brown
fox


    23 Lectures 
     1.5 hours 

 Anadi Sharma

    37 Lectures 
     13 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page
What is a static constructor in C#?

A static constructor is a constructor declared using a static modifier. It is the first block of code executed in a class. With that, a static constructor executes only once in the life cycle of class.
The following is an example of static constructors in C# −
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Difference {
   class Demo {
      static int val1;
      int val2;

      static Demo() {
         Console.WriteLine("This is Static Constructor");
         val1 = 70;
      }

      public Demo(int val3) {
         Console.WriteLine("This is Instance Constructor");
         val2 = val3;
      }
   
      private void show() {
         Console.WriteLine("First Value = " + val1);
         Console.WriteLine("Second Value = " + val2);
      }

      static void Main(string[] args) {
         Demo d1 = new Demo(110);
         Demo d2 = new Demo(200);
         d1.show();
         d2.show();
         Console.ReadKey();
      }
   }
}
Ethereum - Solidity for Contract Writing

Solidity is an object-oriented language especially developed for contract writing. It is a high-level language, which inherits traits from C++, Python, and JavaScript. The Solidity compiler compiles your source code into bytecode that runs on Ethereum Virtual Machine (EVM).
For quick understanding of the Solidity syntax, look at the sample code in the IDE.
pragma solidity >=0.4.22 <0.6.0;
contract Ballot {

The first line is a directive to the compiler. The second line starts the definition of the contract. Within the contract, you declare variables such as −
address chairperson;

You can also define structures such as Proposal and create an array of these structure items. Examine this in the code window.
You may then define a constructor which is invoked at the time of instantiating a contract.
constructor(uint8 _numProposals) public {

After the constructor, you will define several methods, which are the contract methods. In the sample contract, giveRightToVote is one such method having the following syntax −
function giveRightToVote(address toVoter) public {

The public keyword makes this method publicly invokable by any client who has access to the contract.
Likewise, the sample contract defines three more methods called delegate, vote, and winningProposal. Examine these for your own understanding of the Solidity syntax. These are the prerequisites to writing your own contract. Explaining the full syntax of Solidity is beyond the scope of this tutorial.

    38 Lectures 
     4.5 hours 

 Abhilash Nelson

    53 Lectures 
     9.5 hours 

 Frahaan Hussain

    62 Lectures 
     8.5 hours 

 Frahaan Hussain

    103 Lectures 
     9.5 hours 

 Total Seminars

    31 Lectures 
     3.5 hours 

 Swapnil Kole

    64 Lectures 
     12.5 hours 

 Blockchain Post
 Print
 Add Notes
 Bookmark this page
Java Exceptions (Try...Catch)

When executing Java code, different errors can occur: coding errors made by the programmer, errors due to wrong input, 
or other unforeseeable things.
When an error occurs, Java will normally stop and generate an error message. The technical term for this is: Java will throw an exception (throw an error).
The try statement allows you to define a block of code to be 
tested for errors while it is being executed.
The catch statement allows you to define a block of code to 
be executed, if an error occurs in the try block.
The try and catch keywords 
come in pairs:
try {
  //  Block of code to try
}
catch(Exception e) {
  //  Block of code to handle errors
}

Consider the following example:
This will generate an error, because myNumbers[10] does not exist.
public class Main {
  public static void main(String[ ] args) {
    int[] myNumbers = {1, 2, 3};
    System.out.println(myNumbers[10]); // error!
  }
}

The output will be something like this:
If an error occurs, we can use try...catch to catch the error and execute some code to handle it:
public class Main {
  public static void main(String[ ] args) {
    try {
      int[] myNumbers = {1, 2, 3};
      System.out.println(myNumbers[10]);
    } catch (Exception e) {
      System.out.println("Something went wrong.");
    }
  }
}
 
 

The output will be:
The finally statement lets you execute code, after try...catch, regardless of the result:
public class Main {
  public static void main(String[] args) {
    try {
      int[] myNumbers = {1, 2, 3};
      System.out.println(myNumbers[10]);
    } catch (Exception e) {
      System.out.println("Something went wrong.");
    } finally {
      System.out.println("The 'try catch' is finished.");
    }
  }
}
 

The output will be:
The throw statement allows you to create a custom error.
The throw statement is used together with an exception type. There are many exception types available in Java: ArithmeticException, 
FileNotFoundException, ArrayIndexOutOfBoundsException, SecurityException, etc:
Throw an exception if age is below 18 (print "Access 
denied"). If age is 18 or older, print "Access granted":
public class Main {
  static void checkAge(int age) {
    if (age < 18) {
      throw new ArithmeticException("Access denied - You must be at least 18 years old.");
    }
    else {
      System.out.println("Access granted - You are old enough!");
    }
  }

  public static void main(String[] args) {
    checkAge(15); // Set age to 15 (which is below 18...)
  }
}
 

The output will be:
If age was 20, you would not get an exception:
checkAge(20);

The output will be:
Insert the missing parts to handle the error in the code below.
 {
  int[] myNumbers = {1, 2, 3};
  System.out.println(myNumbers[10]);
}  (Exception e) {
  System.out.println("Something went wrong.");
}

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

11 Jan, 2022
Snackbars provide brief messages about app processes. Material UI for React has this component available for us, and it is very easy to integrate. We can use SnackBar Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command.
npm install @material-ui/core
npm install @material-ui/icons
Project Structure: It will look like the following.
Project Structure
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
import React from "react";import IconButton from "@material-ui/core/IconButton";import Snackbar from "@material-ui/core/Snackbar";import CloseIcon from "@material-ui/icons/Close";import Button from "@material-ui/core/Button";  export default function App() {  const [open, setOpen] = React.useState(false);    const handleToClose = (event, reason) => {    if ("clickaway" == reason) return;    setOpen(false);  };    const handleClickEvent = () => {    setOpen(true);  };    return (    <div style={{}}>      <h4>        How to use SnackBar Component in ReactJS?      </h4>      <Button onClick={handleClickEvent}>        Open Snackbar      </Button>      <Snackbar        anchorOrigin={{          horizontal: "left",          vertical: "bottom",        }}        open={open}        autoHideDuration={5000}        message="Sample Warning"        onClose={handleToClose}        action={          <React.Fragment>            <IconButton              size="small"              aria-label="close"              color="inherit"              onClick={handleToClose}            >              <CloseIcon fontSize="small" />            </IconButton>          </React.Fragment>        }      />    </div>  );}
Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
Reference: https://material-ui.com/components/snackbars/
gulshankumarar231
Material-UI
React-Questions
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create a multi-page website using React.js ?
ReactJS useNavigate() Hook
Axios in React: A Guide for Beginners
How to do crud operations in ReactJS ?
React-Router Hooks
Installation of Node.js on Linux
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
HTML | <video> poster Attribute

16 Jun, 2022
The HTML <video> poster Attribute is used to display the image while video downloading or when user click the play button. If this image not set then it will take the first frame of video as a poster image. 
Syntax:
<video poster="URL">
Attribute Values: It contains a single value URL which specifies the link of source image. There are two types of URL link which are listed below:
Absolute URL: It points to another webpage.
Relative URL: It points to other files of the same web page.
Example: 
html
<!DOCTYPE html><html> <head>    <title>HTML video poster Attribute</title></head> <body>    <center>        <h1 style="color:green;">GeeksforGeeks</h1>         <h3>HTML video poster Attribute</h3>         <video width="400" height="200" controls poster="https://media.geeksforgeeks.org/wp-content/uploads/20190627130930/a218.png">            <source src="https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.mp4"                                                            type="video/mp4">            <source src="https://media.geeksforgeeks.org/wp-content/uploads/20190616234019/Canvas.move_.ogg"                                                            type="video/ogg">        </video>    </center></body> </html>
Output:
 
Note: Always specify the width and the height of the video else web page will be confused that how much space that video will be required due to that reason web page become slow down.
Supported Browsers: The browser supported by HTML <video> poster Attribute are listed below:
Google Chrome 3.0 and above
Edge 12.0 and above
Firefox 3.5 and above
Internet Explorer 9.0 and above
Opera 10.5 and above
Safari 3.1 and above
Akanksha_Rai
satyamm09
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
turtle.hideturtle() function in Python

17 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This method is used to make the turtle invisible. It’s a good idea to do this while you’re in the middle of a complicated drawing because hiding the turtle speeds up the drawing observably. This method does not require any argument.
Syntax:
turtle.hideturtle() or turtle.ht()


Below is the implementation of the above method with some examples :
Example 1 :
Python3
# importing packageimport turtle  # forward turtle by 100turtle.forward(100)  # hide the turtleturtle.hideturtle()
Output :
Example 2 :
Python3
# importing packageimport turtle  # draw a circleturtle.circle(80)  # hide the turtleturtle.hideturtle()
Output :
Without hiding the turtle
Hiding the turtle
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Python – tensorflow.concat()

26 Jun, 2020
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.
concat() is used to concatenate tensors along one dimension.
Syntax: tensorflow.concat( values, axis, name )
Parameter:
values: It is a tensor or list of tensor.
axis: It is 0-D tensor which represents dimension to concatenate.
name(optional): It defines the name for the operation.
Returns: It returns the concatenated Tensor.
Example 1:
Python3
# Importing the libraryimport tensorflow as tf  # Initializing the input tensort1 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]t2 = [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]    # Printing the input tensorprint('t1: ', t1)print('t2: ', t2)  # Calculating resultres = tf.concat([t1, t2], 2)  # Printing the resultprint('Result: ', res)
Output:
t1:  [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
t2:  [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]
Result:  tf.Tensor(
[[[ 1  2  7  4]
  [ 3  4  8  4]]

 [[ 5  6  2 10]
  [ 7  8 15 11]]], shape=(2, 2, 4), dtype=int32)
  
  


Example 2:
Python3
# Importing the libraryimport tensorflow as tf  # Initializing the input tensort1 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]t2 = [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]    # Printing the input tensorprint('t1: ', t1)print('t2: ', t2)  # Calculating resultres = tf.concat([t1, t2], 1)  # Printing the resultprint('Result: ', res)
Output:
t1:  [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
t2:  [[[7, 4], [8, 4]], [[2, 10], [15, 11]]]
Result:  tf.Tensor(
[[[ 1  2]
  [ 3  4]
  [ 7  4]
  [ 8  4]]

 [[ 5  6]
  [ 7  8]
  [ 2 10]
  [15 11]]], shape=(2, 4, 2), dtype=int32)



Python-Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
TypeScript | String concat() Method

18 Jun, 2020
The concat() is an inbuilt function in TypeScript which is used to add two or more strings and returns a new single string. 
Syntax:
string.concat(string2, string3[, ..., stringN]); 
Parameter: This method accept a single parameter as mentioned above and described below.
string2...stringN: This parameter holds the strings which will be concatenate.
Return Value: This method returns the concatenated string.
Below example illustrate the  String concat() method in TypeScriptJS:
Example 1: 
JavaScript
<script>    // Original strings    var str1 = new String('GeeksforGeeks');     var str2 = new String(' - Best Platform');       // Combines the text of two strings and     // returns a new string.    console.log("Concatenated String : "             + str1.concat(str2.toString()));</script>
Output: 
Concatenated String : GeeksforGeeks - Best Platform

Example 2: 
JavaScript
<script>    // Original strings    var str1 = new String('Geeks');     var str2 = new String('for');     var str3 = new String('Geeks');       // Combines the text of two strings and     // returns a new string.    var str = str2.concat(str3.toString())    str = str1.concat(str.toString())    console.log("Concatenated String : " + str);</script>
Output: 
Concatenated String : GeeksforGeeks
TypeScript
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 ?
How to select all records that are 10 minutes within current timestamp in MySQL?

You can select all records that are 10 minutes within current timestamp using the following syntax−
SELECT *FROM yourTableName
WHERE yourColumnName > = DATE_SUB(NOW(),INTERVAL 10 MINUTE);
To understand the above syntax, let us create a table. The query to create a table is as follows−
mysql> create table users
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> UserName varchar(20),
   -> UserLastseen datetime,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.91 sec)
Insert some records in the table using insert command. The query is as follows−
mysql> insert into users(UserName,UserLastseen) values('Larry','2019-01-15 02−45−00');
Query OK, 1 row affected (0.15 sec)

mysql> insert into users(UserName,UserLastseen) values('Sam',now());
Query OK, 1 row affected (0.25 sec)

mysql> insert into users(UserName,UserLastseen) values('Mike','2019-01-15 02−30−00');
Query OK, 1 row affected (0.15 sec)

mysql> insert into users(UserName,UserLastseen) values('Bob','2019-01-15 15−02−00');
Query OK, 1 row affected (0.23 sec)

mysql> insert into users(UserName,UserLastseen) values('David','2019-01-15 14−55−00');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement. The query is as follows−
mysql> select *from users;
The following is the output−
+----+----------+---------------------+
| Id | UserName | UserLastseen        |
+----+----------+---------------------+
|  1 | Larry    | 2019-01-15 02−45−00 |
|  2 | Sam | 2019-01-15 15−01−52 |
|  3 | Mike | 2019-01-15 02−30−00 |
|  4 | Bob | 2019-01-15 15−02−00 |
|  5 | David | 2019-01-15 14−55−00 |
+----+----------+---------------------+
5 rows in set (0.00 sec)
Here is the query to select all records that are 10 minutes within the current timestamp−
mysql> select *from users
   -> where UserLastseen> = date_sub(now(),interval 10 minute);
The following is the output−
+----+----------+---------------------+
| Id | UserName | UserLastseen        |
+----+----------+---------------------+
|  2 | Sam      | 2019-01-15 15−01−52 |
|  4 | Bob      | 2019-01-15 15−02−00 |
|  5 | David    | 2019-01-15 14−55−00 |
+----+----------+---------------------+
3 rows in set (0.00 sec)
How to Show Percentage in Pie Chart in Excel? - GeeksforGeeks

29 Jun, 2021
Pie charts are mostly used as it is more appealing and easy to understand for any type of audience. It is divided into various parts and each part of pie charts denotes a subcategory of the original data set. This sub-category data is sometimes shown using the original values or sometimes using percentages as each subcategory represents the proportion of data.
In this article, we are going to see how to show percentages in a pie chart using Excel. 
Consider the example shown below :
Example: Consider the data set which consists of information about the number of students enrolled in our courses. 
The steps are as follows :
Insert the data set in the form of a table as shown above in the cells of the Excel sheet.
Select the data set and go to the Insert tab at the top of the Excel window.
Now, select Insert Doughnut or Pie chart. A drop-down will appear.
Select a 2-D pie chart from the drop-down. A pie chart will be built.
Select -> Insert -> Doughnut or Pie Chart -> 2-D Pie
Initially, the pie chart will not have any data labels in it. To add data labels, select the chart and then click on the “+” button in the top right corner of the pie chart and check the Data Labels button.
Pie Chart
It can be observed that the pie chart contains the value in the labels but our aim is to show the data labels in terms of percentage. 
The steps are as follows :
Select the pie chart.
Right-click on it. A pop-down menu will appear.
Click on the Format Data Labels option.
The Format Data Labels dialog box will appear.
In this dialog box check the “Percentage” button and uncheck the Value button. This will replace the data labels in pie chart from values to percentage.
The final pie chart with percentages in the data labels is now ready.
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Use Solver in Excel?
Macros in Excel
How to Find the Last Used Row and Column in Excel VBA?
How to Sum Values Based on Criteria in Another Column in Excel?
Introduction to Excel Spreadsheet
Java Program to Draw a Shape in Excel Sheet using Apache POI
How to Run a Macro Automatically When Workbook Opens in Excel?
How to Read Data From Text File in Excel VBA?
How to Check if the Number is Prime Number in Excel?
Using CHOOSE Function along with VLOOKUP in Excel
How can I generate random integers between 0 and 9 using Python?

The randint() function in a random module returns a randomly generated integer in the given range. To obtain a random integer between 0 to 9,
>>> import random
>>> random.randint(0,9)
0
>>> random.randint(0,9)
5
>>> random.randint(0,9)
6
>>> random.randint(0,9)
8
Java String toCharArray() with example - GeeksforGeeks

04 Dec, 2018
The java string toCharArray() method converts the given string into a sequence of characters. The returned array length is equal to the length of the string.
Syntax :
public char[] toCharArray()   
Return : It returns a newly allocated character array.

// Java program to demonstrate// working of toCharArray() method  class Gfg {    public static void main(String args[])    {        String s = "GeeksforGeeks";        char[] gfg = s.toCharArray();        for (int i = 0; i < gfg.length; i++) {            System.out.println(gfg[i]);        }    }}
Output:
G
e
e
k
s
f
o
r
G
e
e
k
s

Java-Functions
Java-lang package
Java-Strings
Java
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Multidimensional Arrays in Java
Overriding in Java
Stack Class in Java
Collections in Java
Basic Object Oriented Data Model - GeeksforGeeks

10 Dec, 2021
Need of Object Oriented Data Model : To represent the complex real world problems there was a need for a data model that is closely related to real world. Object Oriented Data Model represents the real world problems easily. 
Object Oriented Data Model : In Object Oriented Data Model, data and their relationships are contained in a single structure which is referred as object in this data model. In this, real world problems are represented as objects with different attributes. All objects have multiple relationships between them. Basically, it is combination of Object Oriented programming and Relational Database Model as it is clear from the following figure :  
Object Oriented Data Model 
= Combination of Object Oriented Programming + Relational database model
Components of Object Oriented Data Model : 
 
Basic Object Oriented Data Model
 
Objects – An object is an abstraction of a real world entity or we can say it is an instance of class. Objects encapsulates data and code into a single unit which provide data abstraction by hiding the implementation details from the user. For example: Instances of student, doctor, engineer in above figure.  
Attribute – An attribute describes the properties of object. For example: Object is STUDENT and its attribute are Roll no, Branch, Setmarks() in the Student class.  
Methods – Method represents the behavior of an object. Basically, it represents the real-world action. For example: Finding a STUDENT marks in above figure as Setmarks().  
Class – A class is a collection of similar objects with shared structure i.e. attributes and behavior i.e. methods. An object is an instance of class. For example: Person, Student, Doctor, Engineer in above figure.  
class student
{
    char Name[20];
    int roll_no;
    --
    --
    public:
    void search();
    void update();
}
In this example, students refers to class and S1, S2 are the objects of class which can be created in main function. 
Inheritance – By using inheritance, new class can inherit the attributes and methods of the old class i.e. base class. For example: as classes Student, Doctor and Engineer are inherited from the base class Person.  
Advantages of Object Oriented Data Model : 
Codes can be reused due to inheritance.
Easily understandable.
Cost of maintenance can reduced due to reusability of attributes and functions because of inheritance.
Disadvantages of Object Oriented Data Model : 
It is not properly developed so not accepted by users easily.
adarshlondhe19
sunnyk23995
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Second Normal Form (2NF)
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Types of Functional dependencies in DBMS
Difference between Where and Having Clause in SQL
Relational Model in DBMS
Difference between OLAP and OLTP in DBMS
KDD Process in Data Mining
MySQL | Regular expressions (Regexp)
Difference between File System and DBMS
Easy Text-to-Speech with Python. Text to Speech | by Dhilip Subramanian | Towards Data Science

Text-to-speech (TTS) technology reads aloud digital text. It can take words on computers, smartphones, tablets and convert them into audio. Also, all kinds of text files can be read aloud, including Word, pages document, online web pages can be read aloud. TTS can help kids who struggle with reading. Many tools and apps are available to convert text into speech.
Python comes with a lot of handy and easily accessible libraries and we’re going to look at how we can deliver text-to-speech with Python in this article.
Different API’s are available in Python in order to convert text to speech. One of Such API’s is the Google Text to Speech commonly known as the gTTS API. It is very easy to use the library which converts the text entered, into an audio file which can be saved as a mp3 file. It supports several languages and the speech can be delivered in any one of the two available audio speeds, fast or slow. More details can be found here
Import gTTS library and “os” module in order to play the converted audio
from gtts import gTTS import os
Creating a text that we want to convert into audio
text = “Global warming is the long-term rise in the average temperature of the Earth’s climate system”
gTTS supports multiple languages. Please refer to the documentation here. Selected ‘en’ -> English and stored in the language variable
language = ‘en’
Creating an object called speech and passing the text and language to the engine. Marked slow = False which tells the module that the converted audio should have a high speed.
speech = gTTS(text = text, lang = language, slow = False)
Saving the converted audio in a mp3 file named called ‘text.mp3’
speech.save(“text.mp3”)
Playing the converted file, using Windows command ‘start’ followed by the name of the mp3 file.
os.system(“start text.mp3”)
The output of the above program saved as text.mp3 file. Mp3 file should be a voice saying, 'Global warming is the long-term rise in the average temperature of the Earth’s climate system'
Here, covert the text file into speech. Reading the text file and pass to gTTS module
Import gTTS and os library
from gtts import gTTS import os
Reading the text file and store into object called text. My file name is “draft.txt”
file = open("draft.txt", "r").read().replace("\n", " ")
Choosing language English
language = ‘en’
Passing the text file into gTTS module and store into speech
speech = gTTS(text = str(file), lang = language, slow = False)
Saving the converted audio in a mp3 file named called ‘voice.mp3’
speech.save("voice.mp3")
Playing the mp3 file
os.system("start voice.mp3")
Converted draft.txt file into voice.mp3
Draft.txt file saved as a voice.mp3 file.Play the Mp3 file to listen the text presented in the draft.txt file
GTTS is an easy tool to convert text to voice, but it requires an internet connection to operate because it depends entirely on Google to get the audio data.
Thanks for reading. Keep learning and stay tuned for more!
You can also read this article on KDnuggets.