code-rag-bench/online-tutorials huggingface dataset:
Convert String float to float list in Python

20 Jul, 2021
Sometimes, while working with data, we could be dealing with numbers, that are in decimal and not integers. This is general case in data science domain. Let’s discuss how to resolve a problem in which we may have a comma separated float numbers and we need to convert to float list.
Method #1 : Using list comprehension + split() + float() The combination of the above methods can be used to perform this task. In this, we convert the String to string list using split and then convert the string to float using float().
Python3
# Python3 code to demonstrate working of# Convert String float to float list# using list comprehension + split() + float() # initializing stringtest_str = "3.44, 7.8, 9.12, 100.2, 6.50" # printing original stringprint("The original string is : " + test_str) # Convert String float to float list# using list comprehension + split() + float()res = [float(idx) for idx in test_str.split(', ')] # printing resultprint("The float list is : " + str(res))
The original string is : 3.44, 7.8, 9.12, 100.2, 6.50
The float list is : [3.44, 7.8, 9.12, 100.2, 6.5]
 
Method #2 : Using map() + split() + float() The combination of above functions can also be used to solve this problem. In this, we perform the task of extending logic to the entire list using map(), rest all the functionalities are performed as above method.
Python3
# Python3 code to demonstrate working of# Convert String float to float list# using map() + split() + float() # initializing stringtest_str = "3.44, 7.8, 9.12, 100.2, 6.50" # printing original stringprint("The original string is : " + test_str) # Convert String float to float list# using map() + split() + float()res = list(map(float, test_str.split(', '))) # printing resultprint("The float list is : " + str(res))
The original string is : 3.44, 7.8, 9.12, 100.2, 6.50
The float list is : [3.44, 7.8, 9.12, 100.2, 6.5]
 
anikakapoor
Python list-programs
Python
Python Programs
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
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Lodash _.delay() Method

23 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.delay() method is used to call the given function as the parameter after the stated wait time is over, which is in milliseconds. Any further arguments are provided to the function when it is called.
Syntax:
_.delay( func, wait, args )
Parameters: This method accepts three parameters as mentioned above and described below:
func: It is the function that has to be delayed.
wait: It is the number of milliseconds for which the function call is delayed.
args: It is the arguments with which the given function is being called. It is an optional parameter.
Return Value: This method returns the timer id.
Example 1: In this example, the content is printed after the delay of 3 seconds as the wait time is 3 seconds.
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Using the _.delay() method// with its parameter_.delay(function(content) {    console.log(content);  }, 3000, 'GeeksforGeeks!');  // Print the content after this lineconsole.log('Content:');
Output:
Content:
GeeksforGeeks!
Example 2: In this example, each integer is printed after a delay of 2 seconds.
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Defining func parameterlet func = number => {  console.log(number);};  // Defining for loopfor(let i = 1; i <= 5; i++) {          // Using the _.delay() method    // with its parameter    _.delay(func, 2000 * (i + 1), i);}  // Prints the integer after this lineconsole.log('Integers are as follows:');
Output:
Integers are as follows:
1
2
3
4
5
JavaScript-Lodash
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
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
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 create Neumorphism Effect using HTML and CSS ?

14 Jan, 2021
Neumorphism (neomorphism) is a modern way of styling web-elements of any web-page and providing a 3D effect. This animation effect can be easily generated by using HTML and CSS. Box-shadow property of CSS can be used to implemented Neumorphism. It is used to add a dark shadow to one side and a light shadow to the other side of the given element. 
HTML code: In this section we will make the layout of the box.
index.html:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8"></head>  <body>    <div class="container">        <div class="neu-1"> GeeksForGeeks</div>        <div class="neu-2">GeeksForGeeks</div>    </div></body>  </html>
CSS code: In this section, we will use some CSS properties to design the box.
index.css:
HTML
<style>  *{    padding: 0;    margin: 0;    box-sizing: border-box;  }  .container {    height: 100vh;    display: flex;    flex-direction: row;    justify-content: center;    align-items: center;    padding: 30px;    background: #dde1e7;  }  .neu-1 {    height: 300px;    width: 300px;    background: #dde1e7;    border-radius: 6px;    box-shadow: -3px -3px 7px #ffffffb2,                   3px 3px 5px rgba(94, 104, 121, 0.945);  }  .neu-2 {    margin: 50px;    height: 300px;    width: 300px;    background: #dde1e7;    border-radius: 6px;    box-shadow: inset -3px -3px 7px #ffffffb0,        inset 3px 3px 5px rgba(94, 104, 121, 0.692);  }</style>
Complete Code: In this section, we will combine the above two section to create a Neumorphism using HTML and CSS.
HTML
<!DOCTYPE html><html lang="en" dir="ltr">  <head>  <meta charset="utf-8">    <style>      *{        padding: 0;        margin: 0;        box-sizing: border-box;      }      .container {        height: 100vh;        display: flex;        flex-direction: row;        justify-content: center;        align-items: center;        padding: 30px;        background: #dde1e7;      }      .neu-1 {        height: 300px;        width: 300px;        background: #dde1e7;        border-radius: 6px;        box-shadow: -3px -3px 7px #ffffffb2,          3px 3px 5px rgba(94, 104, 121, 0.945);      }      .neu-2 {        margin: 50px;        height: 300px;        width: 300px;        background: #dde1e7;        border-radius: 6px;        box-shadow: inset -3px -3px 7px #ffffffb0,          inset 3px 3px 5px rgba(94, 104, 121, 0.692);      }  </style> </head>  <body>    <div class="container">        <div class="neu-1"> GeeksForGeeks</div>        <div class="neu-2">GeeksForGeeks</div>    </div></body>    </html>
Output:
CSS-Misc
HTML-Misc
Technical Scripter 2020
CSS
HTML
Technical Scripter
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
w command in Linux with Examples

27 May, 2019
w command in Linux is used to show who is logged on and what they are doing. This command shows the information about the users currently on the machine and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes. The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU, PCPU, and the command line of their current process. The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs but does include currently running background jobs. The PCPU time is the time used by the current process, named in the “what” field.
Syntax:
w [options] user [...]

Example:
Options:
w -h: This option don’t print the header.w -h
w -h
w -u: This option will ignore the username while figuring out the current process and cpu times.w -u
w -u
w -s : This option uses the short format. It will not print the login time, JCPU or PCPU times.w -s
w -s
w -f : This option will toggle printing the from (remote hostname) field. The default as released is from field which not be printed. Although your system administrator or your distribution maintainer may have compiled a version in which the from field is shown by default.w -f
w -f
w –help: This option will display help message and exit.w --help
w --help
w -i : This option will display IP address instead of hostname for from field.w -i
w -i
w -V : This option will display version information.w -V
w -V
w -o : This option will print blank space for idle times less than one minute.w -o
w -o
w user : This option will show information about the specified user only.w user
w user
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
Introduction to Linux Operating System
nohup Command in Linux with Examples
Array Basics in Shell Scripting | Set 1
mv command in Linux with examples
chmod command in Linux with examples
screen command in Linux with Examples
PyQt5 | How to get the text of Push Button ?

19 Aug, 2021
In this article, we will see how to get the text of push button. When we create push button we set some text to it which will be visible on main window, we can retrieve the text using text method.
Syntax : button.text()Argument : It takes no argument.Return : It returns string.
Code :  
Python3
# importing librariesfrom PyQt5.QtWidgets import *from PyQt5.QtGui import *from PyQt5.QtCore import *import sys  class Window(QMainWindow):    def __init__(self):        super().__init__()         # setting title        self.setWindowTitle("Python ")         # setting geometry        self.setGeometry(100, 100, 600, 400)         # calling method        self.UiComponents()         # showing all the widgets        self.show()     # method for widgets    def UiComponents(self):         # creating a push button        button = QPushButton("CLICK", self)         # setting geometry of button        button.setGeometry(200, 150, 100, 40)         # adding action to a button        button.clicked.connect(self.clickme)         # getting text in button        text = button.text()         # creating label to print text        label = QLabel(text, self)        label.move(200, 200)     # action method    def clickme(self):         # printing pressed        print("pressed") # create pyqt5 appApp = QApplication(sys.argv) # create the instance of our Windowwindow = Window() # start the appsys.exit(App.exec())
Output : 
 
sagar0719kumar
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
sum command in Linux with Examples

27 May, 2019
sum command in Linux is used to find checksum and count the blocks in a file. Basically, this command is used to show the checksum and block count for each specified file. When no file is specified then it will read the standard input.
Syntax:
sum [OPTION]... [FILE]...

Example: It will ask for the input of the file we want to calculate the checksum. In the following example, we are calculating the checksum for myfile.txt.
Options:
sum -r: This option will use BSD sum algorithm, use 1K blocks.Example:sum -r myfile.txt
Example:
sum -r myfile.txt
sum -s: This option will use System V sum algorithm, use 512 bytes blocks.Example:sum -s myfile.txt 
Example:
sum -s myfile.txt 
sum –help : This option displays the help text and exit.sum --help
sum --help
sum –version : This option will show the version information and exit.sum --version
sum --version
linux-command
Linux-file-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
Introduction to Linux Operating System
Basic Operators in Shell Scripting
Splitting string into array of substrings in Julia – split() and rsplit() Method

26 Mar, 2020
The split() is an inbuilt function in julia which is used to split a specified string into an array of substrings on occurrences of the specified delimiter(s).
Syntax:split(str::AbstractString, dlm; limit::Integer, keepempty::Bool)orsplit(str::AbstractString; limit::Integer, keepempty::Bool)
Parameters:
str::AbstractString: Specified string.
Dlm: Specified delimiter.
Below arguments are optional:
limit::Integer: It is the maximum size of the result. It’s default value is zero (0).
keepempty::Bool: It says whether the empty fields should be kept in the result or not. Its Default value is false.
Returns: It returns an array of substrings of the specified string.
Example:
# Julia program to illustrate # the use of String split() method   # Splitting of the specified stringsPrintln(split("Gee.ks", "."))Println(split("Geeks, for, Geeks", ", "))Println(split("GFG-gfg", "-", limit = 1))Println(split("GFG-gfg", "-", limit = 2))
Output:
rsplit() method works exactly like split() method but starting from the end of the string.
Syntax:rsplit(s::AbstractString; limit::Integer, keepempty::Bool)orrsplit(s::AbstractString, chars; limit::Integer, keepempty::Bool)
Parameters:
str::AbstractString: Specified string.
chars: Specified characters.
Below arguments are optional:
limit::Integer: It is the maximum size of the result. It’s default value is zero (0).
keepempty::Bool: It says whether the empty fields should be kept in the result or not. Its Default value is false.
Returns: It returns an array of substrings of the specified string.
Example:
# Julia program to illustrate # the use of String rsplit() method   # Splitting of the specified stringsPrintln(rsplit("Gee.ks", "."))Println(rsplit("Geeks, for, Geeks", ", "))Println(rsplit("GFG-gfg", "-"; limit = 1))Println(rsplit("GFG-gfg", "-"; limit = 2))Println(rsplit("G-F-G-g-f-g", "-"; limit = 4))
Output:
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.chunk() Method

28 Jun, 2022
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers etc. Lodash.chunk() function is used to break the array in to small chunks. Each chunk is an array of size as given.
Syntax:
chunk(array, size)
Parameters: This function accepts two parameters as mentioned above and describe below.
array: An array to be processed by chunk function.
size: This describes the size of chunk.
Return Value: It returns the array of chunks that is also an array
Note: Please install lodash module by using command npm install lodash before using the code given below.
Example 1:
Javascript
// Requiring the lodash module// in the scriptconst _ = require("lodash");let arr = [1, 2, 3, 4, 5, 6]; // Making chunks of size 1console.log(_.chunk(arr, 1))
Output: 
OUTPUT EXAMPLE 1
Example 2: The size of chunk can be varied and array of different data type can be used with chunk function.
Javascript
// Requiring the lodash module// in the scriptlet _ = require("lodash");let arr = [1, 2, 3, 4, 5, 6,        "a", "b", "c", "d"];console.log("Before: ", arr) // Making chunks of size 3console.log("After: ", _.chunk(arr, 3))
Output: 
Example 3: Using array of array with chunk.
Javascript
// Requiring the lodash module// in the script.let lodash = require("lodash");let arr = [    [1, 2, 3],    [4, 5, 6, 7, 8],    [9, 10, 1, 2]]; console.log("Before: ", arr)console.log("After: ", lodash.chunk(arr, 2))
Output: 
Example 4: Using array of Objects with chunk.
Javascript
let lodash = require("lodash");let arr = [    { "a": 1, "b": 2, "c": 3 },    { "d": 1, "e": 2, "f": 3 },    { "d": 1, "e": 2, "f": 3 }]; // Array before breaking in to chunksconsole.log("Before: ", arr) // Printing the first element// of the chunk as size 1console.log("After: ",    lodash.chunk(arr, 1)[0]);
Output :
mohamedyasser99999
JavaScript-Lodash
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
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Lodash _.sample() Method

10 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, collection, strings, objects, numbers etc.The _.sample() method will provide a random element from collection.
Syntax:
_.sample(collection)
Parameters: This method accepts single parameter as mentioned above and described below:
collection: This parameter holds the collection to sample.
Return Value: This method is used to return the random element.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array var array1 = ([ 3, 6, 9, 12 ]);   // Use of _.sample() methodlet gfg = _.sample(array1);  // Printing original Array console.log("original array1: ", array1)  // Printing the output console.log(gfg);
Output:
original array1: [ 3, 6, 9, 12 ]
12

Example 2:
javascript
// Requiring the lodash library const _ = require("lodash");        // Original array var array1 = ([ 'mon', 'tue', 'wed',     'thu', 'fri', 'sat', 'sun']);   // Use of _.sample() methodlet gfg = _.sample(array1);  // Printing original Array console.log("original array1: ", array1)  // Printing the output console.log(gfg);
Output:
original array1: [ 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
mon

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Return a Matrix with Upper Triangle as TRUE values in R Programming – upper.tri() Function

16 Jun, 2020
upper.tri() function in R Language is used to return a matrix of logical values with upper triangle as TRUE.
Syntax: upper.tri(x, diag)
Parameters:x: Matrix objectdiag: Boolean value to include diagonal
Example 1:
# R program to print the # upper triangle of a matrix  # Creating a matrixmat <- matrix(c(1:9), 3, 3, byrow = T)  # Calling upper.tri() Function# Excluding diagonal elementsupper.tri(mat, diag = F)
Output:
      [, 1]  [, 2]  [, 3]
[1, ] FALSE  TRUE  TRUE
[2, ] FALSE FALSE  TRUE
[3, ] FALSE FALSE FALSE

Example 2:
# R program to print the # upper triangle of a matrix  # Creating a matrixmat <- matrix(c(1:9), 3, 3, byrow = T)  # Calling upper.tri() Function# including diagonal elementsupper.tri(mat, diag = T)
Output:
      [, 1]  [, 2] [, 3]
[1, ]  TRUE  TRUE TRUE
[2, ] FALSE  TRUE TRUE
[3, ] FALSE FALSE TRUE

R Matrix-Function
R Language
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
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
Bool data type in C++

05 Jun, 2017
The ISO/ANSI C++ Standard has added certain new data types to the original C++ specifications.They are provided to provide better control in certain situations as well as for providing conveniences to C++ programmers.One of the new data type is: boolSyntax:
bool b1 = true;      // declaring a boolean variable with true value   
In C++, the data type bool has been introduced to hold a boolean value, true or false.The values true or false have been added as keywords in the C++ language.Important Points:
The default numeric value of true is 1 and false is 0.
We can use bool type variables or values true and false in mathematical expressions also.For instance,int x = false + true + 6;is valid and the expression on right will evaluate to 7 as false has value 0 and true will have value 1.
int x = false + true + 6;
is valid and the expression on right will evaluate to 7 as false has value 0 and true will have value 1.
It is also possible to convert implicitly the data type integers or floating point values to bool type. For example, the statements-bool x = 0;  // falsebool y = 100;  // truebool z = 15.75;  // true
bool x = 0;  // falsebool y = 100;  // truebool z = 15.75;  // true
// CPP program to illustrate bool // data type in C++#include<iostream>using namespace std;int main(){    int x1 = 10, x2 = 20, m = 2;    bool b1, b2;    b1 = x1 == x2; // false          b2 = x1 < x2; // true          cout << "b1 is = " << b1 << "\n";    cout << "b2 is = " << b2 << "\n";    bool b3 = true;          if (b3)        cout << "Yes" << "\n";    else        cout << "No" << "\n";              int x3 = false + 5 * m - b3;    cout << x3;      return 0;      }
Output:
b1 is = 0
b2 is = 1
Yes
9

Related article: How to use Bool in C? 
This article is contributed by Mrigendra Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-data-types
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Priority Queue in C++ Standard Template Library (STL)
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++
Substring in C++
unordered_map in C++ STL
C++ Classes and Objects
Sorting a vector in C++
2D Vector In C++ With User Defined Size
C++ Data Types
Virtual Function in C++
How to Install FFmpeg on Windows?

05 Oct, 2021
The ffmpeg is a  cross-platform & open-source software utility to record, convert and stream video/audio files. It can be used to:
Change the  format of a video/audio file
Extract audio from video file
Merge audio and video streams
Change the bitrate of a video/audio file
Create GIF from a video file
Extract still images from a video file
To embed subtitles into a video file
To compress or resize a video/audio file
Record a live stream
In this article, we will show you how to install ffmpeg in Windows.
Follow the below steps to install FFmpeg on windows:
Step 1: Click here to download the zip file of the latest version. (As of September 2021, version 4.4 is the latest)
Step 2: Unzip this file by using any file archiver such as Winrar or 7z.
Step 3: Rename the extracted folder to ffmpeg and move it into the root of C: drive.
Step 4: Now, run cmd as an administrator and set the environment path variable for ffmpeg by running the following command:
setx /m PATH "C:\ffmpeg\bin;%PATH%"
Step 5: Restart your computer and verify the installation by running:
ffmpeg -version
how-to-install
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular Material 7 - Slide Toggle

The <mat-slide-toggle>, an Angular Directive, is used as a on/off switch with material design styling and animation capabilities.
In this chapter, we will showcase the configuration required to draw a slide toggle 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 {MatSlideToggleModule, MatCheckboxModule} from '@angular/material'
@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule,
      BrowserAnimationsModule,
      MatSlideToggleModule, MatCheckboxModule,
      FormsModule,
      ReactiveFormsModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
export class AppModule { }
Following is the content of the modified HTML host file app.component.html.
<mat-slide-toggle
   class = "tp-margin"         
   [checked] = "checked"
   [disabled] = "disabled">
   Slide!
</mat-slide-toggle>
<section class = "tp-section">
   <mat-checkbox class = "tp-margin" [(ngModel)] = "checked">Checked</mat-checkbox>
   <mat-checkbox class = "tp-margin" [(ngModel)] = "disabled">Disabled</mat-checkbox>
</section>
Following is the content of the modified CSS file app.component.css.
.tp-section {
   display: flex;
   align-content: center;
   align-items: center;
   height: 60px;
}
.tp-margin {
   margin: 30px;
}
Following is the content of the modified ts file app.component.ts.
import { Component } from '@angular/core';
@Component({
   selector: 'app-root',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css']
})
export class AppComponent {
   title = 'materialApp'; 
   disabled = false;
   checked = false; 
}
Verify the result.
As first, we've created two check boxes using mat-checkbox and bind them using ngModel with variables. These properties will be used to handle the slide toggle.
As first, we've created two check boxes using mat-checkbox and bind them using ngModel with variables. These properties will be used to handle the slide toggle.
Then, we've created the slide toggle and showcased its various attributes bound with variables in .ts file.
Then, we've created the slide toggle and showcased its various attributes bound with variables in .ts file.
Scientific Calculator Using awk Command in Linux

19 Feb, 2020
The awk command in Linux allows the user to use the numeric functions, variables, logical operators and string functions. Basically, it is a utility that allows the user to write small and effective programs in the form the statements. It is mostly used in pattern scanning and processing. Here, we are using the awk command to perform the following operations:
Floating-point calculations
Trigonometric operations
Logarithms
Exponent
Syntax for awk Command
awk options 'pattern{action }' input-file > output-file

Program: Here, we are using Ubuntu. We are saving the below program in file named scientificcalculator.sh. To execute this program, you can use the below command:
sh  scientificcalculator.sh

pi=`echo "scale=10;4*a(1)" | bc -l`  while truedo  cat << MENU        Menu:    a) Floating Point Calculations    b) Trigonometric Operations    c) Logarithmic Operations    d) Exponential Operations      MENUecho 'Enter your Choice: \c'read choice  case $choice in          a)  echo "\nEnter expression: "        read exp            cal()            awk "BEGIN{print $*}";            echo "Answer: " `cal $exp`        ;;      b)  echo "\nEnter Trigonometric function : "            read exp            echo "Degree: "            read degree           e=$(awk "BEGIN{print $exp($degree*atan2(0,-1)/180)}")            echo "            $exp($degree)= $e"             ;;          c)  echo "\nEnter the logarithmic value: "            read value            echo $value | awk '{printf "%11.9f\n",log($1)/log(10)}'             ;;          d)  echo "\nEnter the base number x: "            read x        echo "Enter exponent number y: "        read y        E=$(echo "$x 1" | awk "{print (($x/1)^$y)}")        echo "$x^$y = $E"                 ;;                    *)              break;;              *)              break;;esacdone
Output:
Technical Scripter 2019
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
Cat command in Linux with examples
echo command in Linux with Examples
touch command in Linux with Examples
chown command in Linux with Examples
Python | Pandas Series.dt.to_period

11 Mar, 2022
Series.dt can be used to access the values of the series as datetimelike and return several properties. Pandas Series.dt.to_period() function cast the underlying data of the given Series object to PeriodArray/Index at a particular frequency. 
Syntax: Series.dt.to_period(*args, **kwargs)Parameter : freq : string or Offset, optionalReturns : PeriodArray/Index 
Example #1: Use Series.dt.to_period() function to cast the underlying data of the given series object to Index at Weekly frequency. 
Python3
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(['2012-12-31', '2019-1-1 12:30', '2008-02-2 10:30',               '2010-1-1 09:25', '2019-12-31 00:00']) # Creating the indexidx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] # set the indexsr.index = idx # Convert the underlying data to datetimesr = pd.to_datetime(sr) # Print the seriesprint(sr)
Output :  
Now we will use Series.dt.to_period() function to cast the underlying data of the given series object to Index at Weekly frequency. 
Python3
# cast to target frequencyresult = sr.dt.to_period(freq = 'W') # print the resultprint(result)
Output :  
As we can see in the output, the Series.dt.to_period() function has successfully cast the data to the target frequency.Example #2 : Use Series.dt.to_period() function to cast the underlying data of the given series object to Index at two year frequency. 
Python3
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(pd.date_range('2012-12-31 00:00', periods = 5, freq = 'D',                            tz = 'US / Central')) # Creating the indexidx = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'] # set the indexsr.index = idx # Print the seriesprint(sr)
Output :  
Now we will use Series.dt.to_period() function to cast the underlying data of the given series object to Index at two year frequency. 
Python3
# cast to target frequencyresult = sr.dt.to_period(freq = '2Y') # print the resultprint(result)
Output :  
As we can see in the output, the Series.dt.to_period() function has successfully cast the data to the target frequency. 
varshagumber28
Python pandas-series-datetime
Python-pandas
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
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
Naming Rows and Columns of a Matrix in R Programming – rownames() and colnames() Function

05 Jun, 2020
rownames() function in R Language is used to set the names to rows of a matrix.
Syntax:rownames(x) <- value
Parameters:x: Matrixvalue: Vector of names to be set
Example:
# R program to provide a name# to rows of a Matrix     # Creating a 3X3 MatrixA = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)   # Calling rownames() Functionrownames(A) <- letters[1:3]  print(A) 
Output:
  [, 1] [, 2] [, 3]
a    1    2    3
b    4    5    6
c    7    8    9

colnames() function in R Language is used to set the names to columns of a matrix.
Syntax:colnames(x) <- value
Parameters:x: Matrixvalue: Vector of names to be set
Example:
# R program to provide a name# to columns of a Matrix     # Creating a 3X3 MatrixA = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)   # Calling colnames() Functioncolnames(A) <- letters[1:3]  print(A) 
Output:
      a    b    c
[1, ] 1    2    3
[2, ] 4    5    6
[3, ] 7    8    9

R Matrix-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
How to Replace specific values in column in R DataFrame ?
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Loops in R (for, while, repeat)
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
Printing Output of an R Program
How to Change Axis Scales in R Plots?
R - if statement
How to reverse a vector in R?

Sometimes the vector values are recorded in the reverse order in R, therefore, we need to again reverse those vectors to get the actual order we want. For example, a sequence of numbers might be recorded as 1 to 20 but we wanted it to be from 20 to 1. The reversing of order of the vector values can be easily done with the help of rev function.
x1<-1:20
x1
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
rev(x1)
[1] 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
x2<-letters[1:26]
x2
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"
rev(x2)
[1] "z" "y" "x" "w" "v" "u" "t" "s" "r" "q" "p" "o" "n" "m" "l" "k" "j" "i" "h"
[20] "g" "f" "e" "d" "c" "b" "a"
x3<-LETTERS[1:26]
x3
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
[20] "T" "U" "V" "W" "X" "Y" "Z"
rev(x3)
[1] "Z" "Y" "X" "W" "V" "U" "T" "S" "R" "Q" "P" "O" "N" "M" "L" "K" "J" "I" "H"
[20] "G" "F" "E" "D" "C" "B" "A"
x4<-rep(c(1,2,3),each=10)
x4
[1] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3
rev(x4)
[1] 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
x5<-c("USA","Canada","United Kingdom","Australia","New Zealand")
x5
[1] "USA" "Canada" "United Kingdom" "Australia"
[5] "New Zealand"
rev(x5)
[1] "New Zealand" "Australia" "United Kingdom" "Canada"
[5] "USA"
x6<-c("Name10","Name9","Name8","Name7","Name6","Name5","Name4","Name3","Name2","Name1")
x6
[1] "Name10" "Name9" "Name8" "Name7" "Name6" "Name5" "Name4" "Name3"
[9] "Name2" "Name1"
rev(x6)
[1] "Name1" "Name2" "Name3" "Name4" "Name5" "Name6" "Name7" "Name8"
[9] "Name9" "Name10"
x7<-c(TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,TRUE,TRUE)
x7
[1] TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE
[13] TRUE
rev(x7)
[1] TRUE TRUE FALSE TRUE TRUE FALSE FALSE FALSE FALSE TRUE TRUE FALSE
[13] TRUE
x8<-c(14,78,25,17,12,19,17,35,26,17,84,45,14,23,52,7,2,19,18,25,65,74,78)
x8
[1] 14 78 25 17 12 19 17 35 26 17 84 45 14 23 52 7 2 19 18 25 65 74 78
rev(x8)
[1] 78 74 65 25 18 19 2 7 52 23 14 45 84 17 26 35 17 19 12 17 25 78 14
x9<-c(1.05,3.21,10.4,7.01,5.02,3.6,5.01,8.2,5.9,4.3,4.58,1.57,2.48)
x9
[1] 1.05 3.21 10.40 7.01 5.02 3.60 5.01 8.20 5.90 4.30 4.58 1.57
[13] 2.48
rev(x9)
[1] 2.48 1.57 4.58 4.30 5.90 8.20 5.01 3.60 5.02 7.01 10.40 3.21
[13] 1.05
x10<-c(5,NA,25,36,TRUE,17,"",65,18,"Class")
x10
[1] "5" NA "25" "36" "TRUE" "17" "" "65" "18"
[10] "Class"
rev(x10)
[1] "Class" "18" "65" "" "17" "TRUE" "36" "25" NA
[10] "5"
Perl use Function

This function imports all the functions exported by MODULE, or only those referred to by LIST, into the name space of the current package. Effectively equivalent to −
BEGIN {
require "Module.pm";
Module->import();
}

Also used to impose compiler directives (pragmas) on the current script, although essentially these are just modules anyway.
Note that a use statement is evaluated at compile time. A require statement is evaluated at execution time.
If the VERSION argument is present between Module and LIST, then the use will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class.
Following is the simple syntax for this function −
use MODULE LIST

use MODULE

use VERSION

This function does not return any value.
Following is the example code showing its basic usage −
use constant;
   use diagnostics;
   use integer;
   use sigtrap  qw(SEGV BUS);
   use strict   qw(subs vars refs);
   use subs     qw(afunc blurfl);
   use warnings qw(all);
   use sort     qw(stable _quicksort _mergesort);
   use v5.6.1;		# compile time version check
   use 5.6.1;		# ditto
   use 5.006_001;	# ditto	

    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to add a base URL for all the links in a page in HTML?

To add a base URL, use the <base> tag in HTML. For example, you can set the base URL once at the top of your page in the header section, then all subsequent relative links will use that URL as a starting point.
You can try to run the following code to learn how to add a base URL for all the links in a page in HTML −
<!DOCTYPE html>
<html>
   <head>
      <title>HTML base Tag</title>
      <base href = "https://www.qries.com" />
   </head>
   <body>
      Qries.com <img src = "/images/banner_logo.png" />
   </body>
</html>
printf(), sprintf() and fprintf() in C

The function printf() is used to print the message along with the values of variables.
Here is the syntax of printf() in C language,
printf(const char *str, ...);
Here is an example of printf() in C language,
 Live Demo
#include<stdio.h>
int main() {
   int a = 24;
   printf("Welcome! \n");
   printf("The value of a : %d",a);
   getchar();
   return 0;
}
Welcome!
The value of a : 24
The function sprintf() is also known as string print function. It do not print the string. It stores the character stream on char buffer. It formats and stores the series of characters and values in an array.
Here is the syntax of sprintf() in C language,
int sprintf(char *str, const char *string,...);
Here is an example of sprintf() in C language,
 Live Demo
#include<stdio.h>
int main() {
   char buf[20];
   int x = 15, y = 25, z;
   z = x + y;
   sprintf(buf, "Sum of values : %d", z);
   printf("%s", buf);
   return 0;
}
Sum of values : 40
The function fprintf() is known as format print function. It writes and formats the output to a stream. It is used to print the message but not on stdout console.
Here is the syntax of fprintf() in C language,
int fprintf(FILE *fptr, const char *str, ...);
Here is an example of fprintf() in C language,
 Live Demo
#include<stdio.h>
int main() {
   int i, x = 4;
   char s[20];
   FILE *f = fopen("new.txt", "w");
   if (f == NULL) {
      printf("Could not open file");
      return 0;
   }
   for (i=0; i<x; i++) {
      puts("Enter text");
      gets(s);
      fprintf(f,"%d.%s\n", i, s);
   }
   fclose(f);
   return 0;
}
Enter text
Hello world!
Enter text
Demo
The output will modify the “new.txt” file. The following text is the modified text of the file.
0,Hello world!
1,Demo
C | File Handling | Question 1 - GeeksforGeeks

28 Jun, 2021

Which of the following true about FILE *fp
(A) FILE is a keyword in C for representing files and fp is a variable of FILE type.
(B) FILE is a structure and fp is a pointer to the structure of FILE type
(C) FILE is a stream
(D) FILE is a buffered stream
 Answer: (B) Explanation: fp is a pointer of FILE type and FILE is a structure that store following information about opened file.  
 

 
 










typedef struct { 
  int level; /* fill/empty level of buffer */
  unsigned flags; /* File status flags */
  char fd; /* File descriptor */
  unsigned char hold; /* Ungetc char if no buffer */
  int bsize; /* Buffer size */
  unsigned char *buffer; /* Data transfer buffer */
  unsigned char *curp; /* Current active pointer */
  unsigned istemp; /* Temporary file indicator */
  short token; /* Used for validity checking */
}FILE; 






Quiz of this Question

C-File Handling


File Handling


C Language


C Quiz

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Multidimensional Arrays in C / C++
Command line arguments in C/C++
rand() and srand() in C/C++
Core Dump (Segmentation fault) in C/C++
fork() in C
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Advanced Pointer | Question 1
C | Structure & Union | Question 10
C | Structure & Union | Question 2
Remove an element from a Queue in Java

To remove an element from a Queue, use the remove() method.
First, set a Queue and insert some elements −
Queue<String> q = new LinkedList<String>();
q.offer("abc");
q.offer("def");
q.offer("ghi");
q.offer("jkl");
q.offer("mno");
q.offer("pqr");
q.offer("stu");
q.offer("vwx");
Remove the first element −
System.out.println("Queue head = " + q.element());
System.out.println("Removing element from queue = " + q.remove());
The following is an example −
 Live Demo
import java.util.LinkedList;
import java.util.Queue;
public class Demo {
   public static void main(String[] args) {
      Queue<String> q = new LinkedList<String>();
      q.offer("abc");
      q.offer("def");
      q.offer("ghi");
      q.offer("jkl");
      q.offer("mno");
      q.offer("pqr");
      q.offer("stu");
      q.offer("vwx");
      System.out.println("Queue head = " + q.element());
      System.out.println("Removing element from queue = " + q.remove());
      System.out.println("\nRemaining Queue elements...");
      Object ob;
      while ((ob = q.poll()) != null) {
         System.out.println(ob);
      }
   }
}
Queue head = abc
Removing element from queue = abc
Queue head now = abc
Remaining Queue elements...
def
ghi
jkl
mno
pqr
stu
vwx
Python | Numpy ndarray.item() - GeeksforGeeks

27 Mar, 2019
With the help of numpy.ndarray.item() method, we can fetch the data elements that is found at the given index on numpy array. Remember we can give index as one dimensional parameter or can be two dimensional.
Parameters:*args : Arguments (variable number and type)-> none: This argument only works when size of an array is 1.-> int_type: This argument is interpreted as a flat index into the array, specifying which element to return.-> tuple of int_types: This argument is interpreted as a two dimensional array, by specifying which element to return.
Returns: Copy of an Item
Example #1 :In this example we can see that by specifying the argument in ndarray.item() method, we can have the element if it existed on this index.
# import the important module in pythonimport numpy as np       # make an array with numpygfg = np.array([1, 2, 3, 4, 5])       # applying ndarray.item() methodprint(gfg.item(2))
3

Example #2 :
# import the important module in pythonimport numpy as np       # make an array with numpygfg = np.array([[1, 2, 3, 4, 5],                [6, 5, 4, 3, 2]])       # applying ndarray.item() methodprint(gfg.item((1, 2)))
4

Python numpy-ndarray
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 ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
How to fetch fields with multiple values set using MySQL LIKE?

To fetch fields with multiple values, use LIKE with OR in MySQL −
select *from yourTableName where yourColumnName like ‘%AnyStringValue’ or yourColumnName like ‘%AnyStringValue’ or yourColumnName like ‘%AnyStringValue’ .........N;
You can understand with the help of a table −
mysql> create table LikeDemo
   −> (
      −> Hobby varchar(200)
   −> );
Query OK, 0 rows affected (1.71 sec)
Insert some records in the table with the help of insert command. The query to insert records in the table is as follows −
mysql> insert into LikeDemo values('Reading Book');
Query OK, 1 row affected (0.13 sec)

mysql> insert into LikeDemo values('Playing Cricket Match');
Query OK, 1 row affected (0.16 sec)

mysql> insert into LikeDemo values('Playing Hockey Match');
Query OK, 1 row affected (0.27 sec)

mysql> insert into LikeDemo values('Reading Novel');
Query OK, 1 row affected (0.14 sec)

mysql> insert into LikeDemo values('Swimming');
Query OK, 1 row affected (0.10 sec)

Displaying all records with the help of select statement. The query is as follows:

mysql> select *from LikeDemo;
The following is the output −
+-----------------------+
| Hobby                 |
+-----------------------+
| Reading Book          |
| Playing Cricket Match |
| Playing Hockey Match  |
| Reading Novel         |
| Swimming              |
+-----------------------+
5 rows in set (0.00 sec)
The query to fetch fields with multiple values using LIKE is as follows −
mysql> select *from LikeDemo where Hobby like '%Cricket%' or Hobby like '%Reading%';
The following is the output −
+-----------------------+
| Hobby                 |
+-----------------------+
| Reading Book          |
| Playing Cricket Match |
| Reading Novel         |
+-----------------------+
3 rows in set (0.00 sec)
Select Drop-down list using select_by_index() in Selenium - Python - GeeksforGeeks

11 Oct, 2020
Prerequisite: Browser Automation Using Selenium
Selenium is an effective device for controlling an internet browser through the program. It is purposeful for all browsers, works on all fundamental OS and its scripts are written in numerous languages i.e Python, Java, C#, etc, we will be using Python.
Requirement:
You need to download install chrome driver from here Click Here and set path. 
Working with Drop-down list:
Initially you have to import the Select class and afterward you have to make the case of Select class. After making the case of Select class, you can perform select strategies on that occasion to choose the choices from dropdown list.
Importing Select class:
from selenium.webdriver.support.ui import Select

For selection:
drop=Select(driver.find_element_by_id(' ')

drop.select_by_index()

Step-by-step approach:
Import webdriver from selenium module.
Python3
# Import required modulefrom selenium import webdriver
Import Select class module.
Python3
# Importing Select classfrom selenium.webdriver.support.ui import Select
Using a web page for drop down list(example: URL).
Navigate the id of option bar.
In html, index starts from 0. Here we will select index value 2 for id RESULT_RadioButton-9.
Python3
# Select by indexdrop.select_by_index(2)
Below is the complete program of the above approach:
Python3
# Import required moduleimport timefrom selenium import webdriver  # Import Select classfrom selenium.webdriver.support.ui import Select      # Using chrome driverdriver = webdriver.Chrome()  # Web page urldriver.get("https://fs2.formsite.com/meherpavan/form2/index.html?1537702596407")      # Find id of optionx = driver.find_element_by_id('RESULT_RadioButton-9')drop = Select(x)  # Select by indexdrop.select_by_index(2)time.sleep(4)driver.close()
Output:
Python-selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()