code-rag-bench/online-tutorials huggingface dataset:
userdel command in Linux with Examples

27 May, 2019
userdel command in Linux system is used to delete a user account and related files. This command basically modifies the system account files, deleting all the entries which refer to the username LOGIN. It is a low-level utility for removing the users.
Syntax:
userdel [options] LOGIN

Options:
userdel -f: This option forces the removal of the specified user account. It doesn’t matter that the user is still logged in. It also forces the userdel to remove the user’s home directory and mail spool, even if another user is using the same home directory or even if the mail spool is not owned by the specified user.Example:sudo userdel -f neuser
Example:
sudo userdel -f neuser
userdel -r: Whenever we are deleting a user using this option then the files in the user’s home directory will be removed along with the home directory itself and the user’s mail spool. All the files located in other file systems will have to be searched for and deleted manually.Example:sudo userdel -r newuser2
Example:
sudo userdel -r newuser2
userdel -h : This option display help message and exit.Example:userdel -h
Example:
userdel -h
userdel -R: This option apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.Example:sudo userdel -R newuser2
Example:
sudo userdel -R newuser2
userdel -Z : This option remove any SELinux(Security-Enhanced Linux) user mapping for the user’s login.Example:sudo userdel -Z newuser2
Example:
sudo userdel -Z newuser2
userdel command with help option: The userdel command throws an error if no options, filename or arguments are passed. So, when we use the -h option, it gives the general syntax along with the various options that can be used with the userdel command.Example:
Example:
linux-command
Linux-system-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
'crontab' in Linux with Examples
Tail command in Linux with examples
Conditional Statements | Shell Script
Docker - COPY Instruction
scp command in Linux with Examples
UDP Server-Client implementation in C
echo command in Linux with Examples
Cat command in Linux with examples
touch command in Linux with Examples
Python | Calendar Module

02 Jul, 2021
Python defines an inbuilt module calendar that handles operations related to the calendar. The calendar module allows output calendars like the program and provides additional useful functions related to the calendar. Functions and classes defined in the Calendar module use an idealized calendar, the current Gregorian calendar extended indefinitely in both directions. By default, these calendars have Monday as the first day of the week, and Sunday as the last (the European convention).Example #1: Display the Calendar of a given month. 
Python3
# Python program to display calendar of# given month of the year   # import moduleimport calendar   yy = 2017mm = 11   # display the calendarprint(calendar.month(yy, mm))
Output:  
Example #2: Display calendar of the given year. 
Python3
# Python code to demonstrate the working of# calendar() function to print calendar   # importing calendar module# for calendar operationsimport calendar   # using calendar to print calendar of year# prints calendar of 2018print ("The calendar of year 2018 is : ")print (calendar.calendar(2018, 2, 1, 6))
Output:  
  class calendar.Calendar : The calendar class creates a Calendar object. A Calendar object provides several methods that can be used for preparing the calendar data for formatting. This class doesn’t do any formatting itself. This is the job of subclasses. Calendar class allows the calculations for various tasks based on date, month, and year. Calendar class provides the following methods:
 
  class calendar.TextCalendar : TextCalendar class can be used to generate plain text calendars. TextCalendar class in Python allows you to edit the calendar and use it as per your requirement. 
 
  class calendar.HTMLCalendar : HTMLCalendar class can be used to generate HTML calendars. HTMLCalendar class in Python allows you to edit the calendar and use as per your requirement. 
 
  Simple TextCalendar class :For simple text calendars calendar module provides the following functions : 
 
 
clintra
python-modules
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
MoviePy – Getting Sub Clip

01 Aug, 2020
In this article we will see how we can show a video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. A subclip is a section of a master (source) clip that you want to edit and manage separately in your project. You can use subclips to organize long media files. You work with subclips in a Timeline panel as you do with master clips. Trimming and editing a subclip is constrained by its start and end points. Clipping helps in overcome the the memory error occur while showing large video at a single time.
In order to do this we will use subclip method with the VideoFileClip object
Syntax : clip.subclip(i, j)
Argument : It takes two integer argument which are starting and ending value in seconds
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video dsa gfg intro videoclip = VideoFileClip("dsa_geek.webm")  # getting subclip as video is largeclip = clip.subclip(55, 65)  # showing clipclip.ipython_display(width = 480)
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4
Another example
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")  # getting subclip clip = clip.subclip(0, 7)  # showing clipclip.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp
Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML - <hr> Tag

The HTML <hr> tag is used for creating a horizontal line. This is also called Horizontal Rule in HTML.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML hr Tag</title>
   </head>

   <body>
      <p>This text will be followed by a horizontal line <hr /></p>
   </body>

</html>
This will produce the following result −
This text will be followed by a horizontal line 
This tag supports all the global attributes described in − HTML Attribute Reference
The HTML <hr> tag also supports following additional attributes −
This tag supports all the event attributes described in − HTML Events Reference
R – while loop

27 Oct, 2021
While loop in R programming language is used when the exact number of iterations of loop is not known beforehand. It executes the same code again and again until a stop condition is met. While loop checks for the condition to be true or false n+1 times rather than n times. This is because the while loop checks for the condition before entering the body of the loop.
while (test_expression) {
   statement
   update_expression
}  
Control falls into the while loop.
The flow jumps to Condition
Condition is tested. If Condition yields true, the flow goes into the Body.If Condition yields false, the flow goes outside the loop
If Condition yields true, the flow goes into the Body.
If Condition yields false, the flow goes outside the loop
The statements inside the body of the loop get executed.
Updation takes place.
Control flows back to Step 2.
The while loop has ended and the flow has gone outside.
It seems to be that while loop will run forever but it is not true, condition is provided to stop it.
When the condition is tested and the result is false then loop is terminated.
And when the tested result is True, then loop will continue its execution.
Example 1: 
R
# R program to illustrate while loop result <- c("Hello World")i <- 1 # test expressionwhile (i < 6) {    print(result)       # update expression   i = i + 1}
Output: 
[1] "Hello World"
[1] "Hello World"
[1] "Hello World"
[1] "Hello World"
[1] "Hello World"
Example 2:  
R
# R program to illustrate while loop result <- 1i <- 1 # test expressionwhile (i < 6) {    print(result)       # update expression   i = i + 1   result = result + 1}
Output: 
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
Here we will use the break statement in the R programming language. Break statement in R is used to bring the control out of the loop when some external condition is triggered.
R
# R program to illustrate while loop result <- c("Hello World")i <- 1 # test expressionwhile (i < 6) {     print(result)         if( i == 3){        break}    # update expression    i = i + 1}
Output:
[1] "Hello World"
[1] "Hello World"
[1] "Hello World"
kumar_satyam
Picked
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change column name of a given DataFrame in R
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)
Adding elements in a vector in R programming - append() method
Group by function in R using Dplyr
How to change Row Names of DataFrame in R ?
Convert Factor to Numeric and Numeric to Factor in R Programming
Dart – Date and Time

23 Feb, 2021
A DateTime object is a point in time. The time zone is either UTC or the local time zone. Accurate date-time handling is required in almost every data context. Dart has the marvelous built-in classes DateTime and Duration in dart:core.Some of its uses are:
Compare and calculate with date times
Get every part of a date-time
Work with different time zones
Measure time spans
Example:
Dart
void main(){    // Get the current date and time.var now = DateTime.now();print(now);  // Create a new DateTime with the local time zone.var y2k = DateTime(2000); // January 1, 2000print(y2k);  // Specify the month and day.y2k = DateTime(2000, 1, 2); // January 2, 2000print(y2k);    // Specify the date as a UTC time.y2k = DateTime.utc(2000); // 1/1/2000, UTCprint(y2k);    // Specify a date and time in ms since the Unix epoch.y2k = DateTime.fromMillisecondsSinceEpoch(946684800000,    isUtc: true);print(y2k);  // Parse an ISO 8601 date.y2k = DateTime.parse('2000-01-01T00:00:00Z');print(y2k);}
Output:
2020-08-25 11:58:56.257
2000-01-01 00:00:00.000
2000-01-02 00:00:00.000
2000-01-01 00:00:00.000Z
2000-01-01 00:00:00.000Z
2000-01-01 00:00:00.000Z
The millisecondsSinceEpoch property of a date returns the number of milliseconds since the “Unix epoch”—January 1, 1970, UTC.
Example:
Dart
void main(){    // 1/1/2000, UTCvar y2k = DateTime.utc(2000);print(y2k.millisecondsSinceEpoch == 946684800000);  // 1/1/1970, UTCvar unixEpoch = DateTime.utc(1970);print(unixEpoch.millisecondsSinceEpoch == 0);}
Output:
true
true
The Duration class can be used to calculate the difference between two dates and to move date forward or backward.
Example:
Dart
void main(){        var y2k = DateTime.utc(2000);  // Add one year.var y2001 = y2k.add(Duration(days: 366));print(y2001.year == 2001);  // Subtract 30 days.var december2000 = y2001.subtract(Duration(days: 30));assert(december2000.year == 2000);print(december2000.month == 12);  // Calculate the difference between two dates.// Returns a Duration object.var duration = y2001.difference(y2k);print(duration.inDays == 366); // y2k was a leap year.  }
Output:
true
true
true

Dart-Date
Dart-Time
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use a specific chrome profile in selenium?

We can use a specific Chrome profile in Selenium. This can be done with the help of the ChromeOptions class. We need to create an object of this class and then apply addArguments method on it.
The path of the specific Chrome profile that we want to use is passed as a parameter to this method. We can open Chrome’s default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter.
Syntax
o = webdriver.ChromeOptions()
o.add_argument = {'user-data-dir':'/Users/Application/Chrome/Default'}
Code Implementation
from selenium import webdriver
#object of ChromeOptions class
o = webdriver.ChromeOptions()
#adding specific Chrome Profile Path
o.add_arguments = {'user-data-dir':'<path of specific Chrome profile>'}
#set chromedriver.exe path
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe", options=o)
#maximize browser
driver.maximize_window()
#launch URL
driver.get("https://www.tutorialspoint.com/index.htm")
#get browser title
print(driver.title)
#close browser
driver.close()
How to Send WhatsApp Message to an Unsaved Number?

28 Feb, 2021
Generally, if we want to send a WhatsApp message to any number registered on WhatsApp we have to start a chat from the contacts page. This requires us to have that particular contact already saved in our phone. Unlike the traditional SMS service, using the WhatsApp app, we cannot just enter a number and start a chat with an unknown/unsaved contact, while the reverse works, i.e. we can receive chats from an unknown number.
However, there is a trick using which this can be made possible.
Enter this URL in a browser, replacing the CC with the country dialing code without any symbol (91 for India) and the XXXXXXXXXX with the 10-digit phone number you wish to start a conversation with.
wa.me/CCXXXXXXXXXX
for eg:
wa.me/919876543210
This URL then expands to :
https://api.whatsapp.com/send/?phone=919876543210
This is basically a WhatsApp API, so this method is completely safe and not a 3rd party plugin.
If this URL is sent as a WhatsApp message, then simply clicking on it will start a chat with the desired number.
If doing this from a PC 
Make sure you are logged on to web.whatsapp.com or the WhatsApp desktop app.
Then click on the Continue to Chat (if using WhatsApp web) or Open WhatsApp Desktop (if logged on the Desktop App) button and you are good to go.
Whatsapp Send Message to Unknown Number
Using this you can send a message to yourselves too for making a grocery list or creating such draft messages.
Technical Scripter 2020
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP 7 - Constant Arrays

Array constants can now be defined using the define() function. In PHP 5.6, they could only be defined using const keyword.
<?php
   //define a array using define function
   define('animals', [
      'dog',
      'cat',
      'bird'
   ]);
   print(animals[1]);
?>
It produces the following browser output −
cat


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
What does Interface consist of in Java

An interface can be defined using the interface keyword. It contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. An interface is primarily used to implement abstraction and it cannot be instantiated.
A program that demonstrates an interface in Java is given as follows:
 Live Demo
interface AnimalSound {
   abstract void sound();
}
class CatSound implements AnimalSound {
   public void sound() {
      System.out.println("Cat Sound: Meow");
   }
}
class DogSound implements AnimalSound {
   public void sound() {
      System.out.println("Dog Sound: Bark");
   }
}
class CowSound implements AnimalSound {
   public void sound() {
      System.out.println("Cow Sound: Moo");
   }
}

public class Demo {
   public static void main(String[] args) {
      AnimalSound a = new CatSound();
      a.sound();
   }
}
Cat Sound: Meow
Jupyter - Converting Notebooks

Jupyter notebook files have .ipynb extension. Notebook is rendered in web browser by the notebook app. It can be exported to various file formats by using download as an option in the file menu. Jupyter also has a command line interface in the form of nbconvert option. By default, nbconvert exports the notebook to HTML format. You can use the following command for tis purpose −
jupyter nbconvert mynotebook.ipynb

This will convert mynotebook.ipynb to the mynotebook.html. Other export format is specified with `--to` clause.
Note that other options include ['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides']
HTML includes 'basic' and 'full' templates. You can specify that in the command line as shown below −
jupyter nbconvert --to html --template basic mynotebook.ipynb

LaTex is a document preparation format used specially in scientific typesetting. Jupyter includes 'base', 'article' and 'report' templates.
jupyter nbconvert --to latex –template report mynotebook.ipynb

To generate PDF via latex, use the following command −
jupyter nbconvert mynotebook.ipynb --to pdf

Notebook can be exported to HTML slideshow. The conversion uses Reveal.js in the background. To serve the slides by an HTTP server, add --postserve on the command-line. To make slides that does not require an internet connection, just place the Reveal.js library in the same directory where your_talk.slides.html is located.
jupyter nbconvert myslides.ipynb --to slides --post serve

The markdown option converts notebook to simple markdown output. Markdown cells are unaffected, and code cells indented 4 spaces.
--to markdown

You can use rst option to convert notebook to Basic reStructuredText output. It is useful as a starting point for embedding notebooks in Sphinx docs.
--to rst

This is the simplest way to get a Python (or other language, depending on the kernel) script out of a notebook.
--to script


    22 Lectures 
     49 mins

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
HTML | Marquee height attribute - GeeksforGeeks

14 Feb, 2022
The Marquee height attribute in HTML is used to set the height of marquee in pixels or percentage value.Syntax:  
<marquee height="px/%" >
Attribute value:  
px: Define the height value of marquee.
%: Define the height value of marquee.
Note : The <marquee> height attribute is not supported by HTML5.
Example:  
html
<!DOCTYPE html><html> <head>    <title>HTML | Marquee height attribute</title>    <style>        .main {            text-align: center;        }    </style></head> <body>    <h1 style="color:green; text-align:center;">      GeeksforGeeks  </h1>    <div class="main">        <marquee height=25px                 bgcolor="Green"                 direction="left"                 loop="">            Left        </marquee>        <marquee height=50px                 bgcolor="Green"                 direction="right"                 loop="">            Right        </marquee>    </div></body> </html>
Output:  
Supported Browsers: The browsers supported by HTML Marquee height attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
ManasChhabra2
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Top 10 Angular Libraries For Web Developers
Difference between process.stdout.write and console.log in Node.js - GeeksforGeeks

07 Oct, 2021
Both process.stdout.write and console.log in NodeJS have basic functionality to display messages on the console. Basically console.log implement process.stdout.write while process.stdout.write is a buffer/stream that will directly output in our console.
Difference between process.stdout.write and console.log in Node.js are:
We can not write more than one string. For example:process.stdout.write("Hello","World");Output: This will give a type error.
We can write more than one string. For example:console.log("Hello", "World");Output: This will print Hello World in the console.
We can not make associations. For example:process.stdout.write("Hello %s", "All");Output: This will give a type error.
We can make associations. For example:console.log("Hello %s", "All");Output: This will print Hello All in the console.
Example: Below example is to show to use of process.stdout.write
Javascript
<script>    // For process.std.out     process.stdout.write("Hello");    process.stdout.write("World");    process.stdout.write("!!!");</script>
Output:
HelloWorld!!!
Example: Below example is to show to use of console.log
Javascript
<script>    // For console.log     console.log("Hello");    console.log("World");    console.log("!!!");</script>
Output:
Hello
World
!!!
Node.js-Basics
Picked
Technical Scripter 2020
Node.js
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to build a basic CRUD app with Node.js and ReactJS ?
How to connect Node.js with React.js ?
Mongoose Populate() Method
Express.js req.params Property
How to Convert CSV to JSON file having Comma Separated values in Node.js ?
Node.js Export Module
JWT Authentication with Node.js
Mongoose find() Function
How to Install a local module using npm?
Difference between dependencies, devDependencies and peerDependencies
Vim - Registers

Vim provides many registers. We can use these registers as multiple clipboards. This feature is really useful while working with multiple files. In this chapter, we will discuss following items −
Copy text in register
Paste text from register
List available registers
Register types
For copying, we can use normal yank command i.e. yy and to store it in register we can use following syntax −
“<register-name><command>

For instance, to copy text in register “a” use following command −
“ayy

To paste text from register use −
“<register-name>p

For instance, below command copies text from register “a” −
“ap

To list all available registers use following command
:registers

Vim supports following types of registers −
Unnamed register is denoted by “”. Vim stores deleted or copied text in this register
We can use 26 named registers; we can use a-z or A-Z. By default vim doesn’t uses these registers.
If we use lower case register name then contents will be overwritten and if we use uppercase name then contents will be appended in that register.
We can use 0 to 9 named registers. Vim fills these registers with text from yank and delete command.
Numbered register 0 contains the text from the most recent yank command.
Numbered register 1 contains the text deleted by the most recent delete or change command
Following are the default registers −
Name of the current file
Name of the alternate file for the current window
Most recently executed command
Contains the last inserted text
Last used register

    46 Lectures 
     5.5 hours 

 Jason Cannon
 Print
 Add Notes
 Bookmark this page
How to group an array of objects by key in JavaScript

Suppose, we have an array of objects containing data about some cars like this −
const arr = [
   {
      'make': 'audi',
      'model': 'r8',
      'year': '2012'
   }, {
      'make': 'audi',
      'model': 'rs5',
      'year': '2013'
   }, {
      'make': 'ford',
      'model': 'mustang',
      'year': '2012'
   }, {
      'make': 'ford',
      'model': 'fusion',
      'year': '2015'
   }, {
      'make': 'kia',
      'model': 'optima',
      'year': '2012'
   },
];
We are required to write a JavaScript function that takes in one such array of objects. The function should then group the objects together based on their 'make' property.
Therefore, the output should look something like this −
const output = {
   'audi': [
   {
      'model': 'r8',
      'year': '2012'
   }, {
      'model': 'rs5',
      'year': '2013'
   },
],
'ford': [
   {
      'model': 'mustang',
      'year': '2012'
   }, {
      'model': 'fusion',
      'year': '2015'
   }
],
'kia': [
   {
      'model': 'optima',
      'year': '2012'
   }
   ]
};
The code for this will be −
const arr = [
   {
      'make': 'audi',
      'model': 'r8',
      'year': '2012'
   }, {
      'make': 'audi',
      'model': 'rs5',
      'year': '2013'
   }, {
      'make': 'ford',
      'model': 'mustang',
      'year': '2012'
   }, {
      'make': 'ford',
      'model': 'fusion',
      'year': '2015'
   }, {
      'make': 'kia',
      'model': 'optima',
      'year': '2012'
   },
];
const groupByMake = (arr = []) => {
   let result = [];
   result = arr.reduce((r, a) => {
      r[a.make] = r[a.make] || [];
      r[a.make].push(a);
      return r;
   }, Object.create(null));
   return result;
};
console.log(groupByMake(arr));
And the output in the console will be −
{
   audi: [
      { make: 'audi', model: 'r8', year: '2012' },
      { make: 'audi', model: 'rs5', year: '2013' }
   ],
   ford: [
      { make: 'ford', model: 'mustang', year: '2012' },
      { make: 'ford', model: 'fusion', year: '2015' }
   ],
   kia: [ { make: 'kia', model: 'optima', year: '2012' } ]
}
Check if element is present in tuple of tuples in Python

Python Tuples can be nested. We can have a tuple whose elements are also tuples. In this article we will see how to find out if a given value is present as an element in a tuple of tuples.
The any function can be used to check if a given value is present as an element in any of the subtuples that are present in the tuple with help of for loop. We put the entire condition for checking in an if and else clause.
 Live Demo
Atuple = [('Mon',10),('Tue',8),('Wed',8),('Thu',5)]

#Given tuple
print("Given tuple: ",Atuple)

# Use any
if any('Tue' in i for i in Atuple):
   print("present")
else :
   print("Not present")


if any(3 in i for i in Atuple):
   print("present")
else :
   print("Not present")
Running the above code gives us the following result −
Given tuple: [('Mon', 10), ('Tue', 8), ('Wed', 8), ('Thu', 5)]
present
Not present
The chain function in itertools module returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted. So we use it with the given tuple expanding all its content and checking for the presence of the required value using the if clause.
 Live Demo
import itertools
Atuple = (('Mon',10),('Tue',8),('Wed',8),('Thu',5))

#Given tuple
print("Given tuple: ",Atuple)

# Use chain
if ('Wed' in itertools.chain(*Atuple)) :
print("Wed is present")
else :
   print("Wed is not present")


if (11 in itertools.chain(*Atuple)) :
   print("11 is present")
else :
   print("11 is not present")
Running the above code gives us the following result −
Given tuple: (('Mon', 10), ('Tue', 8), ('Wed', 8), ('Thu', 5))
Wed is present
11 is not present
How to Sort CSV by a single column in Python ?

To sort CSV by a single column, use the sort_values() method. Set the column using which you want to sort in the sort_values() method.
At first, let’s read our CSV file “SalesRecords.csv”with DataFrame −
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesRecords.csv")
Sort according to a single column “Car” −
dataFrame.sort_values("Car", axis=0, ascending=True,inplace=True, na_position='first')
Next, sort according to a single column “Reg_Price” −
dataFrame.sort_values("Reg_Price", axis=0, ascending=True,inplace=True, na_position='first')
Following is the code
import pandas as pd

# DataFrame to read our input CS file
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesRecords.csv")
print("\nInput CSV file = \n", dataFrame)

# sorting according to Car column
dataFrame.sort_values("Car", axis=0, ascending=True,inplace=True, na_position='first')

print("\nSorted CSV file (according to Car Names) = \n", dataFrame)

# sorting according to Reg_Price column
dataFrame.sort_values("Reg_Price", axis=0, ascending=True,inplace=True, na_position='first')

print("\nSorted CSV file (according to Registration Price) = \n", dataFrame)
This will produce the following output
Input CSV file =
           Car   Date_of_Purchase   Reg_Price
0          BMW         10/10/2020        1000
1         Audi         10/12/2020         750
2        Lexus         10/17/2020        1250
3       Jaguar         10/16/2020        1500
4      Mustang         10/19/2020        1100
5  Lamborghini         10/22/2020        1000

Sorted CSV file (according to Car Names) =
           Car   Date_of_Purchase   Reg_Price
1         Audi         10/12/2020         750
0          BMW         10/10/2020        1000
3       Jaguar         10/16/2020        1500
5  Lamborghini         10/22/2020        1000
2        Lexus         10/17/2020        1250
4      Mustang         10/19/2020        1100

Sorted CSV file (according to Registration Price) =
           Car   Date_of_Purchase   Reg_Price
1         Audi         10/12/2020         750
0          BMW         10/10/2020        1000
5  Lamborghini         10/22/2020        1000
4      Mustang         10/19/2020        1100
2        Lexus         10/17/2020        1250
3       Jaguar         10/16/2020        1500
Convert double primitive type to a Double object in Java

To convert double primitive type to a Double object, you need to use Double constructor.
Let’s say the following is our double primitive.
// double primitive
double val = 23.78;
To convert it to a Double object, use Double constructor.
// Double object
Double ob = new Double(val);
 Live Demo
public class Demo {
   public static void main(String args[]) {
      // double primitive
      double val = 23.78;
      // Double object
      Double ob = new Double(val);
      System.out.println(ob);
   }
}
23.78
Elias Delta Decoding in Python - GeeksforGeeks

28 Nov, 2021
In this article, we are going to implement Elias Delta Decoding using python.
Peter Elias devised the Elias delta code, which is a universal system for encoding positive integers.
Syntax:
Elias Delta Encoding(X)= Elias Gamma encoding (1+floor(log2(X))) + Binary representation of X without MSB.   
Import required libraries and read the encoded binary string from the user.
Read/Count the number of zero’s from the most significant bit until you see the first ‘1’  and store it in a variable named ‘L’
Syntax:
L=0
while True:
   if not x[L] == '0':
       break
   L= L + 1
Consider that ‘L’ as 1st digit and read L more bits and drop all bits until current L bit.
Take out the remaining bits and prepend ‘1’ in the Most significant bit.
Syntax:
x.insert(0,’1′) 
Convert the final binary into integer which gives us the original number.
Let the input encoded string is 01111
Step1: Read/Count the number of zeros from most significant bit until you see the first ‘1’ and store it in ‘L’ until you see the first ‘1’
In our case, L=1
Step2: Consider that ‘1’ as first digit read L more bits (1 more bit) and drop everything.
01111= 11
Step3: Takeout the remaining bits and prepend with ‘1’ in MSB.
111
Step4: Convert the final binary string into integer which gives us 7.
Below is the implementation.
Example 1: Example to produce Elias Delta Decoding value corresponding to some value.
Python3
import math    def Elias_Delta_Decoding(x):    x = list(x)    L = 0    while True:        if not x[L] == '0':            break        L = L + 1              # Reading L more bits and dropping ALL        x = x[2*L+1:]            # Prepending with 1 in MSB    x.reverse()    x.insert(0, '1')      n = 0          # Converting binary to integer    for i in range(len(x)):          if x[i] == '1':            n = n+math.pow(2, i)    return int(n)    x = '01111'print(Elias_Delta_Decoding(x))
Output:
7
Example 2: Example to produce Elias Delta Decoding value corresponding to some value.p
Python
import math  def  Elias_Delta_Decoding(x):    x = list(x)    L=0    while True:        if not x[L] == '0':            break        L= L + 1          # Reading L more bits and dropping ALL    x=x[2*L+1:]           # Prepending with 1 in MSB    x.insert(0,'1')     x.reverse()    n=0          # Converting binary to integer    for i in range(len(x)):         if x[i]=='1':            n=n+math.pow(2,i)    return int(n)  x = '0111100'print(Elias_Delta_Decoding(x))
Output:
28
Picked
python-utility
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
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Creating Tables in SQL. Understanding the syntax is very simple... | by Jason Lee | Towards Data Science

Understanding the syntax is very simple in SQL. It follows an easy structure that allows us to reuse syntax for different variables. Here are some basic syntax for creating tables.
CREATE DATABASE database_name;
CREATE TABLE movies(     movie_name   VARCHAR(200),     movie_year   INTEGER,     country      VARCHAR(100),      genre        VARCHAR NOT NULL,      PRIMARY KEY  (movie_name, movie_year));
State column name, the type of the column and length within the parenthesis. You can state NOT NULL to make sure it is always filled.
INSERT INTO movies VALUES('SE7EN', 1995, 'USA', 'Mystic, Crime'),('INSTERSTELLAR', 2014, 'USA', 'Science Fiction'),('The Green Mile', 1999, 'USA', 'Drama'),('The Godfather', 1972, 'USA', 'CRIME')
If you enter a value which is not the correct type or if empty, and it is NOT NULL, SQL will throw an error.
If you forgot to add a value you can update it, with UPDATE.
UPDATE moviesSET country = 'USA'WHERE movie_name = 'The Godfather' AND movie_year = 1972;
You can update and set an item to a default.
ALTER TABLE moviesALTER COLUMN country SET DEFAULT 'USA';
Test the DEFAULT option. Now, whenever you reference DEFAULT you will get the USA.
INSERT INTO movies VALUES('test', 2010, DEFAULT, 'test')
ALTER TABLE moviesADD COLUMN director VARCHAR(150)
If you want to add a new value for any column you can use UPDATE.
UPDATE moviesSET director = 'Christopher Nolan'WHERE movie_name = 'Interstellar';
If you want to delete a row you can reference it by using WHERE.
DELETE FROM moviesWHERE movie_name = 'test'
ALTER TABLE moviesDROP director;
There is another way you can drop an item and it’s called DROP CASCADE.
DROP CASCADE → Drops the item selected and everything else that is dependent on it. For example, if we used DROP CASCADE on the entire movie's database everything will be deleted.
Working with Documents - Python .docx Module - GeeksforGeeks

03 Jan, 2021
Prerequisite: Working with .docx module
Word documents contain formatted text wrapped within three object levels. The lowest level- run objects, middle level- paragraph objects, and highest level- document object. So, we cannot work with these documents using normal text editors. But, we can manipulate these word documents in python using the python-docx module. Pip command to install this module is:
pip install python-docx
Python docx module allows users to manipulate docs by either manipulating the existing one or creating a new empty document and manipulating it. It is a powerful tool as it helps you to manipulate the document to a very large extend.
Now, to use the python-docx module you have to import it as docx.
# Import docx NOT python-docx
import docx
Then to create an instance of the word document. We will use the Document() method of the docx module.
Syntax: docx.Document(String path)
Parameter:
String path: It is an optional parameter. It specifies the path of the file to be open. If it is left empty then a new empty document file is created.
And to save the document we will use save() method of the docx module.
Syntax: doc.save(String path_to_document)
Parameter:
String path_to_document: It is the file name by which document will be saved. You can even put the path to where you want to save it.
Example 1: Opening a new document.
Python3
# Import docx NOT python-docximport docx  # Create an instance of a word documentdoc = docx.Document()  # Now save the document to a location doc.save('gfg.docx')
Output:
Example 2: Opening a previously created document and again saving it with a different name.
Python3
# Import docx NOT python-docximport docx  # Opening a previously created documentdoc = docx.Document('gfg.docx')  # Now save the document to a location doc.save('gfg-copy.docx')
Output:
Python Docx-module
Technical Scripter 2020
Python
Technical Scripter
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
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
PyQt5 QDateEdit - Getting Style Sheet - GeeksforGeeks

07 Jul, 2020
In this article we will see how we can get the style sheet to the date edit. Setting style sheet makes the date edit look unique with the help of style sheet we can set color, border and many other things to the date edit. We can set style sheet with the help of setStyleSheet method.
In order to do this we use styleSheet method with the QDateEdit object
Syntax : date.styleSheet()
Argument : It takes no argument
Return : It returns string
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom 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, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for components    def UiComponents(self):          # creating a QDateEdit widget        date = QDateEdit(self)          # setting geometry of the date edit        date.setGeometry(100, 100, 200, 40)          # alignment        a_flag = Qt.AlignCenter          # setting alignment of date        date.setAlignment(a_flag)          # setting style sheet        date.setStyleSheet("QDateEdit"                           "{"                           "border : 2px solid black;"                           "background : white;"                           "padding : 5px;"                           "}"                           "QDateEdit::up-arrow"                           "{"                           "border : 2px solid black;"                           "background-color : lightgreen;"                           "}"                           "QDateEdit::down-arrow"                           "{"                           "border : 2px solid black;"                           "background-color : red;"                           "}"                           )          # creating a label        label = QLabel("GeeksforGeeks", self)          # setting geometry        label.setGeometry(100, 150, 250, 60)          # making label multiline        label.setWordWrap(True)          # getting style sheet        value = date.styleSheet()            # setting text to the label        label.setText("Style Sheet : " + str(value))    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QDateEdit
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
How to assign multiple values to a same variable in Python?

In Python, if you try to do something like
a = b = c = [0,3,5]
a[0] = 10
You'll end up with the same values in
a, b, and c: [10, 3, 5]
This is because all three variables here point to the same value. If you modify this value, you'll get the change reflected in all names, ie, a,b and c. To create a new object and assign it, you can use the copy module. 
a = [0,3,5]
import copy
b = copy.deepcopy(a)
a[0] = 5

print(a)
print(b)
This will give the output −
[5,3,5]
[0,3,5]
C | Operators | Question 10 - GeeksforGeeks

10 Nov, 2020
What is the output of following program?
#include <stdio.h>  int main(){   int a = 1;   int b = 1;   int c = a || --b;   int d = a-- && --b;   printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d);   return 0;}
(A) a = 0, b = 1, c = 1, d = 0(B) a = 0, b = 0, c = 1, d = 0
(C) a = 1, b = 1, c = 1, d = 1(D) a = 0, b = 0, c = 0, d = 0Answer: (B)Explanation: Let us understand the execution line by line.Initial values of a and b are 1.
   // Since a is 1, the expression --b 
   // is not executed because
   // of the short-circuit property 
   // of logical or operator
   // So c becomes 1, a and b remain 1
   int c = a || --b;

   // The post decrement operator -- 
   // returns the old value in current expression 
   // and then updates the value. So the 
   // value of expression a-- is 1.  Since the 
   // first operand of logical and is 1, 
   // shortcircuiting doesn't happen here.  So 
   // the expression --b is executed and --b 
   // returns 0 because it is pre-increment.
   // The values of a and b become 0, and 
   // the value of d also becomes 0.
   int d = a-- && --b;

Quiz of this Question
akhil11199914
C-Operators
Operators
C Quiz
Operators
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C | Dynamic Memory Allocation | Question 5
C | Advanced Pointer | Question 2
C | Advanced Pointer | Question 1
C Quiz - 107 | Question 2
C | Data Types | Question 2
C Quiz - 101 | Question 5
C Quiz - 104 | Question 5
C | Structure & Union | Question 2
C Quiz - 110 | Question 5
C | Structure & Union | Question 5
iconv command in Linux with Examples - GeeksforGeeks

15 Apr, 2019
iconv command is used to convert some text in one encoding into another encoding. If no input file is provided then it reads from standard input. Similarly, if no output file is given then it writes to standard output. If no from-encoding or to-encoding is provided then it uses current local’s character encoding.
Syntax:
iconv [options] [-f from-encoding] [-t to-encoding] [inputfile]...
Options:
-f from-encoding, –from-code=from-encoding : Use from-encoding for input characters.
-t to-encoding, –to-code=to-encoding : Use to-encoding for output characters.
-l, –list : List all known character set encodings.
-c : Silently discard characters that cannot be converted instead of terminating when encountering such characters.
-o outputfile, –output=outputfile : Use outputfile for output.
–verbose : Print progress information on standard error when processing multiple files.
Note:
If the string //IGNORE is appended to to-encoding, characters that cannot be converted are discarded and an error is printed after conversion.
If the string //TRANSLIT is appended to to-encoding, characters that cannot be represented in the target character set, it can be approximated through one or several similar looking characters.
Examples:
To convert from UTF-8 to ASCII :echo abc ß ? € à?ç | iconv -f UTF-8 -t ASCII//TRANSLIT
echo abc ß ? € à?ç | iconv -f UTF-8 -t ASCII//TRANSLIT
Print the list of all character set encodings :iconv -l
iconv -l
Reading and writing from a file :iconv -f UTF-8 -t ASCII//TRANSLIT -o out.txt in.txt
iconv -f UTF-8 -t ASCII//TRANSLIT -o out.txt in.txt
linux-command
Linux-text-processing-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
nohup Command in Linux with Examples
scp command in Linux with Examples
chown command in Linux with Examples
Array Basics in Shell Scripting | Set 1
mv command in Linux with examples
Basic Operators in Shell Scripting
SED command in Linux | Set 2
Docker - COPY Instruction
Named Pipe or FIFO with example C program
Tryit Editor v3.7

HTML Input types
Tryit: input type = checkbox
Batch Script - Local Variables in Functions

Local variables in functions can be used to avoid name conflicts and keep variable changes local to the function. The SETLOCAL command is first used to ensure the command processor takes a backup of all environment variables. The variables can be restored by calling ENDLOCAL command. Changes made in between are local to the current batch script. ENDLOCAL is automatically called when the end of the batch file is reached, i.e. by calling GOTO:EOF.
Localizing variables with SETLOCAL allows using variable names within a function freely without worrying about name conflicts with variables used outside the function.
Following example shows how local variables can be used in functions.
@echo off
set str = Outer
echo %str%
CALL :SetValue str
echo %str%
EXIT /B %ERRORLEVEL%
:SetValue
SETLOCAL
set str = Inner
set "%~1 = %str%"
ENDLOCAL
EXIT /B 0
In the above program, the variable ‘str’ is being localized in the function SetValue. Thus even though the str value is being returned back to the main function, the value of str in the main function will not be replaced by the value being returned from the function.
The above command produces the following output.
Outer
Outer

 Print
 Add Notes
 Bookmark this page
Python 3 - String isnumeric() Method

The isnumeric() method checks whether the string consists of only numeric characters. This method is present only on unicode objects.
Note − Unlike Python 2, all strings are represented in Unicode in Python 3. Given below is an example illustrating it.
Following is the syntax for isnumeric() method −
str.isnumeric()

NA
This method returns true if all characters in the string are numeric, false otherwise.
The following example shows the usage of isnumeric() method.
#!/usr/bin/python3

str = "this2016"  
print (str.isnumeric())

str = "23443434"
print (str.isnumeric())
When we run above program, it produces the following result −
False
True


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page