code-rag-bench/online-tutorials huggingface dataset:
Write an Efficient C Program to Reverse Bits of a Number in C++

In this problem, we are given an unsigned integer n. Our task is to create a program that returns the number which is generated by reversing all the bits of the number.
Let’s take an example to understand the problem,
n = 1
2147483648
binary of 1 is 000...0001, the reverse is 100...0000.
To solve this problem, we simple solution will be using a simple formula. We will loop through the binary of the number. And find the position of the set bit in the number lets say it i. The result will be calculated using the formula, ((total_number_of_bits) - 1) - i
Program to show the implementation of this algorithm,
 Live Demo
#include<iostream>
using namespace std;
unsigned int reverseBitNumber(unsigned int num) {
   unsigned int totalNumberOfBits = sizeof(num) * 8;
   unsigned int reverseNumber = 0, temp;
   for (int i = 0; i < totalNumberOfBits; i++){
      if((num & (1 << i)))
         reverseNumber |= (1 << ((totalNumberOfBits - 1) - i));
   }
   return reverseNumber;
}
int main() {
   unsigned int n = 21;
   cout<<"The number is "<<n<<endl;
   cout<<"The number which has reverse bits of the number is :"<<reverseBitNumber(n);
   return 0;
}
The number is 2
The number which has reverse bits of the number is :2818572288
Another method is using shifting, we will shift the bits of the number until it become zero and the shift them in reverse number and then shift the bits remaining number of times to get the result.
Program to show the implementation of our solution,
 Live Demo
#include<iostream>
using namespace std;
unsigned int reverseBitNumber(unsigned int n){
   unsigned int rem_shift = sizeof(n) * 8 - 1;
   unsigned int reverseNubmer = n;
   n >>= 1;
   while(n){
      reverseNubmer <<= 1;
      reverseNubmer |= n & 1;
      n >>= 1;
      rem_shift--;
   }
   reverseNubmer <<= rem_shift;
   return reverseNubmer;
}
int main(){
   unsigned int n = 21;
   cout<<"The number is "<<n<<endl;
   cout<<"The number which has reverse bits of the number is :"<<reverseBitNumber(n);
   return 0;
}
The number is 21
The number which has reverse bits of the number is :2818572288
How to join or concatenate two lists in C#?

To concatenate two lists, use AddRange() method.
Set the first list −
var products1 = new List < string > ();
products1.Add("Belts");
products1.Add("Tshirt");
products1.Add("Trousers");
Set the second list −
var products2 = new List < string > ();
products2.Add("Footwear");
products2.Add("Electronics");
To concatenate both the lists −
products1.AddRange(products2);
The following is the complete code −
 Live Demo
using System.Collections.Generic;
using System;

namespace Demo {
   public static class Program {
      public static void Main() {
         var products1 = new List < string > ();
         products1.Add("Belts");
         products1.Add("Tshirt");
         products1.Add("Trousers");

         Console.WriteLine("Our list1....");
         foreach(var p in products1) {
            Console.WriteLine(p);
         }

         var products2 = new List < string > ();
         products2.Add("Footwear");
         products2.Add("Electronics");

         Console.WriteLine("Our list2....");
         foreach(var p in products2) {
            Console.WriteLine(p);
         }
         products1.AddRange(products2);
         Console.WriteLine("Concatenated list....");
         foreach(var p in products1) {
            Console.WriteLine(p);
         }
      }
   }
}
Our list1....
Belts
Tshirt
Trousers
Our list2....
Footwear
Electronics
Concatenated list....
Belts
Tshirt
Trousers
Footwear
Electronics
GATE | GATE-CS-2007 | Question 85 - GeeksforGeeks

14 Sep, 2021
Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?(A) Both P and Q are true(B) P is true and Q is false(C) P is false and Q is true(D) Both P and Q are falseAnswer: (C)Explanation:
A regular grammar can also be ambiguous also
For example, consider the following grammar,                             
S → aA/a
A → aA/ε
In above grammar, string 'a' has two leftmost
derivations. 
(1)   S → aA                      (2)   S → a
      S->a (using A->ε)
And LL(1) parses only unambiguous grammar,
so statement P is False.
Statement Q is true is for every regular set, we can have a regular
grammar which is unambiguous so it can be parse by LR parser. 

So option C is correct choice 
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersPYQ - Parsing and SDT (Continued) Part 4 with Joyojyoti Acharya | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0027:46 / 58:40•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=LdMTs93sekg" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 1) | Question 42
Writing to CSV files in R - GeeksforGeeks

26 Mar, 2021
For Data Analysis sometimes creating CSV data file is required and do some operations on it as per our requirement. So, In this article we are going to learn that how to write data to CSV File using R Programming Language.
To write to csv file write.csv() function is used.
Syntax: write.csv(data, path)
Parameter:
data: data to be added to csv
path: pathname of the file
Approach:
Create a DataFrame
Pass required values to the function
Write to file
Let us first create a data frame.
Example:
R
Country <- c("China", "India", "United States", "Indonesia", "Pakistan")  Population_1_july_2018 <- c("1,427,647,786", "1,352,642,280",                             "327,096,265", "267,670,543", "212,228,286")  Population_1_july_2019 <- c("1,433,783,686", "1,366,417,754",                             "329,064,917", "270,625,568", "216,565,318")  change_in_percents <- c("+0.43%", "+1.02%", "+0.60%", "+1.10%", "+2.04%")    data <- data.frame(Country, Population_1_july_2018, Population_1_july_2019, change_in_percents)print(data)
Output:
Our Data in console
Now let us write this data to a csv file and save it to a required location.
Example:
R
Country <- c("China", "India", "United States", "Indonesia", "Pakistan")  Population_1_july_2018 <- c("1,427,647,786", "1,352,642,280",                             "327,096,265", "267,670,543", "212,228,286")  Population_1_july_2019 <- c("1,433,783,686", "1,366,417,754",                             "329,064,917", "270,625,568", "216,565,318")  change_in_percents <- c("+0.43%", "+1.02%", "+0.60%", "+1.10%", "+2.04%")    data <- data.frame(Country, Population_1_july_2018, Population_1_july_2019, change_in_percents)print(data)  write.csv(data,"C:\\Users\\...YOUR PATH...\\population.csv")print ('CSV file written Successfully :)')
Output:
CSV File with data
Picked
R-CSV
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
K-Means Clustering in R Programming
Creating a Data Frame from Vectors in R Programming
PyQt5 - Create circular Push Button - GeeksforGeeks

22 Apr, 2020
In this article we will see how to create circular push button. By default, when we create a push button it is in rectangular form although we can also change it size to square.
In order to create circular button we have to do following steps:
1. Create a push button.2. Change its size to make it square.3. Set radius of button to half of length or square button.
Note : If we set radius greater then the half of the length then no change will occur as that shape would not be possible.
Syntax : button.setStyleSheet(“border-radius : 50;”)
Argument : It takes string as argument.
Action performed : It sets the radius of button.
Code :
# 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, 100)          # setting radius and border        button.setStyleSheet("border-radius : 50;                               border : 2px solid black")          # adding action to a button        button.clicked.connect(self.clickme)      # 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 :
Python-gui
Python-PyQt
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 ?
Python OOPs Concepts
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Python Classes and Objects
Stack in Python
Graph Plotting in Python | Set 1
Convert integer to string in Python
How to remove characters except digits from string in Python?

We have a variety of ways to achieve this. We can filter out non digit characters using for ... if statement. For example:
>>> s = "H3ll0 P30P13"
>>> ''.join(i for i in s if i.isdigit())
'303013'
We can also use filter and a lambda function to filter out the characters. For example:
>>> s = "H3ll0 P30P13"
>>> filter(lambda x: x.isdigit(), s)
'303013'
Though an overkill for such a simple task, we can also use a regex for achieving the same thing. The \D character(non digit) can be replaced by an empty string. For example:
>>> import re
>>> s = "H3ll0 P30P13"
>>> re.sub("\D", "", s)
'303013'
Creating Baseline Machine Learning Models | by Himanshu Sharma | Towards Data Science

Creating a Machine Learning model includes a lot of preprocessing where we manipulate features and target variables to make data ready for a machine learning model. This preprocessing includes checking the data for any missing values, cleaning the junk values, and also visualizing the data for exploratory data analysis.
After performing all these operations on the data we begin with a new hustle to create a machine learning model that has higher accuracy and good performance. In order to do this, we start by creating different machine learning models and after that, we select the best performing model as the baseline model.
What if I tell you that you can do all these in a few lines of code and save your time and effort to optimize your model? Yes, Dabl can do all this. It is an open-source python library that is used to perform data preprocessing, data visualization, and creating the baseline model.
Let’s get started...
We will start by installing Dabl using pip. The command given below will do that.
pip install dabl
In this step, we will import the required libraries for loading the data, performing EDA, and creating a baseline model for that dataset.
import dablimport pandas as pdfrom sklearn.model_selection import train_test_splitfrom sklearn.datasets import load_digits
For this article, we will be using the famous Diabetes dataset which can be downloaded easily from online sources.
df = pd.read_csv("Diabetes.csv")
In this step, we will clean the data using the clean function of the Dabl and also find out the data types of all the features and target variables.
dia_clean = dabl.clean(df, verbose=0)
types = dabl.detect_types(dia_clean)types
In this step, we will create visualizations to see data patterns and gather some initial insights about the data.
dabl.plot(dia_clean, 'Outcome')
This is the final step, where we will find out a baseline model for our data in a single line of code. Dabl runs different models in the backend and finds out the best-performing model.
features = ['Pregnancies', 'Glucose','BloodPressure','SkinThickness','Insulin','BMI','DiabetesPedigreeFunction','Age']Y = df['Outcome']X =  df[features]X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2)sc = dabl.SimpleClassifier().fit(X_train, Y_train)print("Accuracy score", sc.score(X_test, Y_test))
Here you can see how Dabl shows us the best performing model with its accuracy score. We can select this model for further tuning and optimization.
In this article, we saw how Dabl is useful for Data preprocessing, performing EDA, and creating a baseline model. Go ahead try this with a different dataset and let me know your comments in the response section.
This article is in collaboration with Piyush Ingale.
Thanks for reading! If you want to get in touch with me, feel free to reach me at hmix13@gmail.com or my LinkedIn Profile. You can view my Github profile for different data science projects and packages tutorials. Also, feel free to explore my profile and read different articles I have written related to Data Science.
What are user defined data types in C#?

The User defined data types in C# are structures and enumeration.
In C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.
The C# structures have the following features −
Structures can have methods, fields, indexers, properties, operator methods, and events.
Structures can have defined constructors, but not destructors. However, you cannot define a default constructor for a structure. The default constructor is automatically defined and cannot be changed.
Unlike classes, structures cannot inherit other structures or classes.
Structures cannot be used as a base for other structures or classes.
A structure can implement one or more interfaces.
Structure members cannot be specified as abstract, virtual, or protected.
Enum is Enumeration to store a set of named constants like year, product, month, season, etc.
The default value of Enum constants starts from 0 and increments. It has fixed set of constants and can be traversed easily.
Let us see an example.
We have set the enum like this −
public enum Vehicle { Car, Bus, Truck }
C++ Program to Implement Sorted Array

A sorted array is an array in which each of the elements are sorted in some order such as numerical, alphabetical etc. There are many algorithms to sort a numerical array such as bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort etc. More details about sorting the array using selection sort are given below.
The selection sort is a sorting method that yields a sorted array. It does so by repeatedly finding the smallest element in the array and interchanging it with the element at the starting of the unsorted part.
A program that implements a sorted array using selection sort is given as follows.
 Live Demo
#include<iostream>
using namespace std;
void selectionSort(int a[], int n) {
   int i, j, min, temp;
   for (i = 0; i < n - 1; i++) {
      min = i;
      for (j = i + 1; j < n; j++)
      if (a[j] < a[min])
      min = j;
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
   }
}
int main() {
   int a[] = { 22, 91, 35, 78, 10, 8, 75, 99, 1, 67 };
   int n = sizeof(a)/ sizeof(a[0]);
   int i;
   cout<<"Given array is:"<<endl;
   for (i = 0; i < n; i++)
   cout<< a[i] <<" ";
   cout<<endl;
   selectionSort(a, n);
   printf("\nSorted array is: \n");
   for (i = 0; i < n; i++)
   cout<< a[i] <<" ";
   return 0;
}
Given array is:
22 91 35 78 10 8 75 99 1 67
Sorted array is:
1 8 10 22 35 67 75 78 91 99
In the above program, selectionSort() is a function that sorts the array a[] using selection sort. There are two for loops in selectionSort(). In each iteration of the outer for loop, the minimum element in the remaining array after i is found and then interchanged with the element currently at i. This is repeated until the array is sorted. This is shown below.
void selectionSort(int a[], int n) {
   int i, j, min, temp;
   for (i = 0; i < n - 1; i++) {
      min = i;
      for (j = i + 1; j < n; j++)
      if (a[j] < a[min])
      min = j;
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
   }
}
In the main() function, the array a[] is defined. Then the function selectionSort() is called with the array a[] and its size n. Finally, the sorted array is displayed. This is shown below.
int main() {
   int a[] = { 22, 91, 35, 78, 10, 8, 75, 99, 1, 67 };
   int n = sizeof(a)/ sizeof(a[0]);
   int i;
   cout<<"Given array is:"<<endl;
   for (i = 0; i < n; i++)
   cout<< a[i] <<" ";
   cout<<endl;
   selectionSort(a, n);
   printf("\nSorted array is: \n");
   for (i = 0; i < n; i++)
   cout<< a[i] <<" ";
   return 0;
}
Deleting from temporary table in SAP HANA

The temporary tables are session specific. So you would require to use truncate instead of delete as follows
truncate table #temptable;
Also, could you please check your release? In the recent releases, delete also works fine. Here is an example:
Drop table #temptable;
Create local temporary table #temptable(id integer, str nvarchar(30));
Insert into #temptable values (1,'abc');
Insert into #temptable values (2,'xyz');
Select * from #temptable;  --> returns 3 rows
Delete from #temptable;
Select * from #temptable;--> returns 0 rows
How to disable a MenuItem in Java?

To disable a MenuItem, use the setEnabled() method and set it to FALSE. Let’s say we have the following MenuBar −
JMenuBar menuBar = new JMenuBar();
Now, create a Menu −
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
menuBar.add(fileMenu);
We will now create two MenuItems inside the above Menu −
JMenuItem menuItem1 = new JMenuItem("New", KeyEvent.VK_N);
fileMenu.add(menuItem1);
JMenuItem menuItem2 = new JMenuItem("Open File", KeyEvent.VK_O);
fileMenu.add(menuItem2);
Now, let us disable the 2nd MenuItem −
menuItem2.setEnabled(false);
The following is an example to disable a MenuItem in Java −
package my;
import java.awt.Color;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
public class SwingDemo {
   public static void main(final String args[]) {
      JFrame frame = new JFrame("MenuBar Demo");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JMenuBar menuBar = new JMenuBar();
      UIManager.put("MenuBar.background", Color.ORANGE);
      JMenu fileMenu = new JMenu("File");
      fileMenu.setMnemonic(KeyEvent.VK_F);
      menuBar.add(fileMenu);
      JMenuItem menuItem1 = new JMenuItem("New", KeyEvent.VK_N);
      fileMenu.add(menuItem1);
      JMenuItem menuItem2 = new JMenuItem("Open File", KeyEvent.VK_O);
      fileMenu.add(menuItem2);
      menuItem2.setEnabled(false);
      JMenu editMenu = new JMenu("Edit");
      editMenu.setMnemonic(KeyEvent.VK_E);
      menuBar.add(editMenu);
      JMenuItem menuItem3 = new JMenuItem("Cut", KeyEvent.VK_C);
      editMenu.add(menuItem3);
      JMenu searchMenu = new JMenu("Search");
      searchMenu.setMnemonic(KeyEvent.VK_S);
      menuBar.add(searchMenu);
      JMenu projectMenu = new JMenu("Project");
      projectMenu.setMnemonic(KeyEvent.VK_P);
      menuBar.add(projectMenu);
      JMenu runMenu = new JMenu("Run");
      runMenu.setMnemonic(KeyEvent.VK_R);
      menuBar.add(runMenu);
      menuBar.revalidate();
      frame.setJMenuBar(menuBar);
      frame.setSize(550, 350);
      frame.setVisible(true);
   }
}
The output is as follows. Here, we have disabled the “Open File” MenuItem −
Python Program to print element with maximum vowels from a List

08 Dec, 2020
Given a list containing string elements, the task is to write a Python program to print string with maximum vowels.
Input : test_list = [“gfg”, “best”, “for”, “geeks”] Output : geeks Explanation : geeks has 2 e’s which is a maximum number of vowels compared to other strings.
Input : test_list = [“gfg”, “best”] Output : best Explanation : best has 1 e which is a maximum number of vowels compared to other strings.  
Approach : Using loop
In this, we iterate for all the strings and keep a counter to check number of vowel in each string. Then, return the string with maximum vowels at end of the loop.
Python3
# initializing Matrixtest_list = ["gfg", "best", "for", "geeks"]  # printing original listprint("The original list is : " + str(test_list))  res = ""max_len = 0for ele in test_list:      # getting maximum length and element    # iteratively    vow_len = len([el for el in ele if el in ['a', 'e', 'o', 'u', 'i']])    if vow_len > max_len:        max_len = vow_len        res = ele  # printing resultprint("Maximum vowels word : " + str(res))
 Output:
The original list is : [‘gfg’, ‘best’, ‘for’, ‘geeks’]
Maximum vowels word : geeks 
Python list-programs
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala | REPL

09 Apr, 2019
Scala REPL is an interactive command line interpreter shell, where REPL stands for Read-Evaluate-Print-Loop. It works like it stands for only. It first Read expression provided as input on Scala command line and then it Evaluate given expression and Print expression’s outcome on screen and then it is again ready to Read and this thing goes in loop. In the scope of the current expression as required, previous results are automatically imported. The REPL reads expressions at the prompt In interactive mode, then wraps them into an executable template, and after that compiles and executes the result.
Either an object Or a class can be wrapped by user code the switch used is -Yrepl-class-based.
Each and every line of input is compiled separately.
The Dependencies on previous lines are included by automatically generated imports.
The implicit import of scala.Predef can be controlled by inputting an explicit import.
We can start Scala REPL by typing scala command in console/terminal.
$scala
Let’s understand how we can add two variable using Scala REPL.In first line we initialized two variable in Scala REPL. Then Scala REPL printed these. In this we can see that internally it create two variable of type Int with value. Then we executed expression of sum with defined two variable. with this Scala REPL printed sum of expression on screen again. Here it did not have any variable so it showed it with its temporary variable only with prefix res. We can use these variable as same like we created it.
We can get more information of these temporary variable by calling getClass function over these variable like below.
We can do lots of experiments like this with scala REPL on run time which would have been time consuming if we were using some IDE. With scala2.0 we can also list down all function suggestion that we can apply on variable by pressing TAB key.
IMain of REPL is bound to $intp.
The tab key is used for completion.
lastException binds REPL’s last exception.
:load is used to load a REPL input file.
:javap is used to inspect class artifacts.
-Yrepl-outdir is used to inspect class artifacts with external tools.
:power imports compiler components after entering compiler mode.
:help is used to get a list of commands to help the user.
Picked
Scala
Scala-Basics
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scheduling Python Scripts on Linux

31 Aug, 2021
Sometimes we need to do a task every day, and we can do these repetitive tasks every day by ourselves, or we can use the art of programming to automate these repetitive tasks by scheduling the task. And today in this article we are going to learn how to schedule a python script on Linux to do the repetitive tasks.
We are going to a utility called cron to schedule the python script. Cron is driven by crontab which is also referred to as timetable because the word cron is derived from the Greek word Chronos which means time and tab is simply table.
Syntax: * * * * * command
In Crontab there are six fields. The first five are reserved for the date and time of scheduled execution, and the last field is reserved for a command to be executed.
Python3
#!/usr/bin/env python3  # importing librariesimport osimport random  # setting up folder namefolder_name = "geeksforgeeks"  # entering into the loop# to create 2 folder every time this script runsfor i in range(2):      # generating random number between 0 and 9    number = int(random.randrange(0, 10))      print("Creating folder {}".format(number))      # creating directories    os.mkdir(folder_name+" {}".format(number))
Output:
Now following are the steps we need to be followed to schedule python scripts in Linux:
Step 1: Firstly, we have to create a python script that we will be going to schedule.  Above is the python script that we are going to use in this article.
Step 2: Open up the crontab to create a configuration file for scheduling the python script.
Step 3: Run the following command in the terminal to open up the crontab configuration file.
crontab -e
This should open up an editor to edit the configuration file and the output should look like this:
Step 4: Scroll to the end of the file and write down the timing and the command to be executed.
* * * * * /usr/bin/env python3 /home/amninder/Desktop/Geeks/cron/schedule.py >> /home/amninder/Desktop/Geeks/cron/output.txt
Here, “/usr/bin/env python3 /home/amninder/Desktop/Geeks/cron/schedule.py ” is the path to the script that we are going to schedule and “/home/amninder/Desktop/Geeks/cron/output.txt” is the path to the file where we are going to save our output. Asterisks (*) on all first 5 fields indicate that the script is going to execute after every minute, every hour.
To check logs to see if It’s working or not run the following command:
sudo tail -f /var/log/syslog
Output:
To remove the job from the crontab, run this command.
crontab -r : This will delete the current cron jobs.
Picked
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Stack | Question 4

09 Feb, 2013
Consider the following pseudocode that uses a stack
declare a stack of characterswhile ( there are more characters in the word to read ){   read a character   push the character on the stack}while ( the stack is not empty ){   pop a character off the stack   write the character to the screen}
What is output for input “geeksquiz”?
(A) geeksquizgeeksquiz(B) ziuqskeeg(C) geeksquiz(D) ziuqskeegziuqskeegAnswer: (B)Explanation: Since the stack data structure follows LIFO order. When we pop() items from stack, they are popped in reverse order of their insertion (or push())
Data Structures
Data Structures-Stack
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | os.getuid() and os.setuid() method

25 Jun, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
All functions in os module raise OSError in the case of invalid or inaccessible file names and paths, or other arguments that have the correct type, but are not accepted by the operating system.
os.getuid() method in Python is used to get the current process’s real user id while os.setuid() method is used to set the current process’s real user id.
User ID: In Unix-like operating systems, a user is identified by a unique value called user ID. User ID is used to determine which system resource a user is authorized to access.
Note: os.setuid() and os.getuid() methods are available only on UNIX platforms and functionality of os.setuid() method is typically available only to the superuser as only superuser can change user id.Superuser means a root user or an administrative user who has all the permissions to run or execute any program in the operating system.
os.getuid() method
Syntax: os.getuid()
Parameter: No parameter is required
Return Type: This method returns an integer value which represents the current process’s real user id.
# Python program to explain os.getuid() method   # importing os module import os  # Get the real user ID# of the current process# using os.getuid() methoduid = os.getuid()  # Print the real user ID# of the current processprint("Real user ID of the current process:", uid)
Real user ID of the current process: 1000

os.setuid() method
Syntax: os.setuid(uid)
Parameter:uid: An integer value representing new user ID for the current process.
Return Type: This method does not return any value.
# Python program to explain os.setuid() method   # importing os module import os  # Get the real user ID# of the current process# using os.getuid() methoduid = os.getuid()  # Print the real user ID# of the current processprint("Real user ID of the current process:", uid)  # Set real user ID# of the current process# using os.setuid() methoduid = 1500os.setuid(uid)print("Real user ID changed")    # Print the real user ID# of the current processprint("Real user ID of the current process:", os.getuid())
Real user ID of the current process: 0
Real user ID changed
Real user ID of the current process: 1500

python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert CSV to HTML Table in Python

01 Jun, 2021
CSV file is a Comma Separated Value file that uses a comma to separate values. It is basically used for exchanging data between different applications. In this, individual rows are separated by a newline. Fields of data in each row are delimited with a comma.Example :  
Name, Salary, Age, No.of years employed
Akriti, 90000, 20, 1
Shreya, 100000, 21, 2
Priyanka, 25000, 45, 7
Neha, 46000, 25, 4
Note: For more information, refer to Working with csv files in Python 
Method 1 Using pandas: One of the easiest way to convert CSV file to HTML table is using pandas. Type the below code in the command prompt to install pandas. 
pip install pandas 
Example: Suppose the CSV file looks like this –  
 
Python3
# Python program to convert# CSV to HTML Table  import pandas as pd # to read csv file named "samplee"a = pd.read_csv("read_file.csv") # to save as html file# named as "Table"a.to_html("Table.htm") # assign it to a# variable (string)html_file = a.to_html()
Output: 
Method 2 Using PrettyTable: PrettyTable is a simple Python library designed to make it quick and easy to represent tabular data in visually appealing ASCII tables. Type the below command to install this module. 
pip install PrettyTable
Example: The above CSV file is used. 
Python3
from prettytable import PrettyTable  # open csv filea = open("read_file.csv", 'r') # read the csv filea = a.readlines() # Separating the Headersl1 = a[0]l1 = l1.split(',') # headers for tablet = PrettyTable([l1[0], l1[1]]) # Adding the datafor i in range(1, len(a)) :    t.add_row(a[i].split(',')) code = t.get_html_string()html_file = open('Tablee.html', 'w')html_file = html_file.write(code)
Output :  
 
saurabh1990aror
Python-pandas
python-utility
Technical Scripter 2019
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert PDF file to Excel file using Python?

28 Jan, 2021
In this article, we will see how to convert a PDF to Excel or CSV File Using Python. It can be done with various methods, here are we are going to use some methods.
Method 1: Using pdftables_api 
Here will use the pdftables_api Module for converting the PDF file into any other format. It’s a simple web-based API, so can be called from any programming language.
Installation:
pip install git+https://github.com/pdftables/python-pdftables-api.git
After Installation, you need an API KEY. Go to PDFTables.com and signup, then visit the API Page to see your API KEY.
For Converting PDF File Into excel File we will use xml() method.
Syntax:
xml(pdf_path, xml_path)
Below is the Implementation:
PDF File Used:
PDF FILE
Python3
# Import Moduleimport pdftables_api  # API KEY VERIFICATIONconversion = pdftables_api.Client('API KEY')  # PDf to Excel # (Hello.pdf, Hello)conversion.xlsx("pdf_file_path", "output_file_path")
Output:
EXCEL FILE
Method 2: Using tabula-py
Here will use the tabula-py Module for converting the PDF file into any other format.
Installation:
pip install tabula-py
Before we start, first we need to install java and add a java installation folder to the PATH variable.
Install java click here
Add java installation folder (C:\Program Files (x86)\Java\jre1.8.0_251\bin) to the environment path variable
Approach:
Read PDF file using read_pdf() method.
Then we will convert the PDF files into an Excel file using the to_excel() method.
Syntax:
read_pdf(PDF File Path, pages = Number of pages, **agrs)
Below is the Implementation:
PDF File Used:
PDF FILE
Python3
# Import Module import tabula  # Read PDF File# this contain a listdf = tabula.read_pdf("PDF File Path", pages = 1)[0]  # Convert into Excel Filedf.to_excel('Excel File Path')
Output:
EXCEL FILE
Picked
Python-excel
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
\varsigma - Tex Command

\varsigma - Used to create varsigma symbol.
{ \varsigma}
\varsigma command draws varsigma symbol.

\varsigma

ς



\varsigma

ς


\varsigma

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Ruby | Time usec function

06 Jan, 2020
Time#usec() is a Time class method which returns the number of microseconds for time.
Syntax: Time.usec()
Parameter: Time values
Return: the number of microseconds for time.
Example #1 :
# Ruby code for Time.usec() method  # loading libraryrequire 'time'  # declaring time a = Time.new(2019)  # declaring timeb = Time.new(2019, 10)  # declaring timec = Time.new(2019, 12, 31)  # Time puts "Time a : #{a}\n\n"puts "Time b : #{b}\n\n"puts "Time c : #{c}\n\n\n\n"    # usec form puts "Time a usec form : #{a.usec}\n\n"puts "Time b usec form : #{b.usec}\n\n"puts "Time c usec form : #{c.usec}\n\n"
Output :
Time a : 2019-01-01 00:00:00 +0000

Time b : 2019-10-01 00:00:00 +0000

Time c : 2019-12-31 00:00:00 +0000



Time a usec form : 0

Time b usec form : 0

Time c usec form : 0



Example #2 :
# Ruby code for Time.usec() method  # loading libraryrequire 'time'  # declaring time a = Time.now  # declaring timeb = Time.new(1000, 10, 10)  # declaring timec = Time.new(2020, 12)  # Time puts "Time a : #{a}\n\n"puts "Time b : #{b}\n\n"puts "Time c : #{c}\n\n\n\n"    # usec form puts "Time a usec form : #{a.usec}\n\n"puts "Time b usec form : #{b.usec}\n\n"puts "Time c usec form : #{c.usec}\n\n"
Output :
Time a : 2019-08-27 09:16:21 +0000

Time b : 1000-10-10 00:00:00 +0000

Time c : 2020-12-01 00:00:00 +0000



Time a usec form : 673126

Time b usec form : 0

Time c usec form : 0


Ruby Time-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Array count() operation
Ruby | Array slice() function
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | unless Statement and unless Modifier
Ruby | Data Types
How to get form data using POST method in PHP ?

02 Jun, 2020
PHP provides a way to read raw POST data of an HTML Form using php:// which is used for accessing PHP’s input and output streams. In this article, we will use the mentioned way in three different ways. We will use php://input, which is a read-only PHP stream.
We will create a basic HTML form page where we can use all the possible approaches one at a time.HTML Code:
<!DOCTYPE html><html><head>    <title>POST Body</title>    <style>        form {            margin: 30px 0px;        }        input {            display: block;            margin: 10px 15px;            padding: 8px 10px;            font-size: 16px;        }        div {            font-size: 20px;            margin: 0px 15px;        }        h2 {            color: green;            margin: 20px 15px;        }    </style></head><body>    <h2>GeeksforGeeks</h2>    <form method="post">        <input type="text" name="username"                             placeholder="Enter Username">        <input type="password" name="password"                               placeholder="Enter Password">        <input type="submit" name="submit-btn"                              value="submit">    </form>    <br></body></html>
Below examples illustrate the approach:Example 1: In this example, we will use file_get_contents() Function. The file_get_contents() function is used to get the data in string format.
Syntax:file_get_contents('php://input');
file_get_contents('php://input');
PHP Code:<?php     if (isset($_POST["submit-btn"])) {        $post_data = file_get_contents('php://input');        echo "<div> POST BODY <br>".$post_data."</div>";            }?>
<?php     if (isset($_POST["submit-btn"])) {        $post_data = file_get_contents('php://input');        echo "<div> POST BODY <br>".$post_data."</div>";            }?>
Output:
Example 2: In this example, we will use print_r() Function. It is a much simpler way to get the POST data and that is using the print_r() function. This will give the output in the form of an array.
Syntax:print_r($_POST);
print_r($_POST);
PHP Code:<?php     if (isset($_POST["submit-btn"])) {        echo "<div> POST BODY <br>";        print_r($_POST);        echo "</div>";    }?>
<?php     if (isset($_POST["submit-btn"])) {        echo "<div> POST BODY <br>";        print_r($_POST);        echo "</div>";    }?>
Output:
Example 3: We can also use var_dump() function which will give us an array as well but with a bit more information.
Syntax:var_dump($_POST);
var_dump($_POST);
PHP Code:<?php     if (isset($_POST["submit-btn"])) {        echo "<div> POST BODY <br>";        var_dump($_POST);        echo "</div>";    }?>
<?php     if (isset($_POST["submit-btn"])) {        echo "<div> POST BODY <br>";        var_dump($_POST);        echo "</div>";    }?>
Output:
Akanksha_Rai
PHP-Misc
Picked
PHP
Technical Scripter
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.bfill()

13 Feb, 2020
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.bfill() is used to backward fill the missing values in the dataset. It will backward fill the NaN values that are present in the pandas dataframe.
Syntax: DataFrame.bfill(axis=None, inplace=False, limit=None, downcast=None)
Parameters:axis : ‘rows’ or ‘columns’inplace : boolean, default Falselimit : integer value, No. of consecutive na cells to be populated.
Example #1: Use bfill() function to populate missing values na values in the dataframe across rows.
# importing pandas as pdimport pandas as pd  # Creating a dataframe with "na" values.  df = pd.DataFrame({"A":[None, 1, 2, 3, None, None],                    "B":[11, 5, None, None, None, 8],                   "C":[None, 5, 10, 11, None, 8]})  # Printing the dataframedf
When axis='rows', then value in current na cells are filled from the corresponding value in the next row. If the next row is also na value then it won’t be populated.
# Fill across the rowdf.bfill(axis ='rows')
Output :
 Example #2: Use bfill() function to populate missing values na values in the dataframe across columns.
when axis='columns', then the current na cells will be filled from the value present in the next column in the same row. If the next column is also na cell then it won’t be filled.
# importing pandas as pdimport pandas as pd  # Creating a dataframe with "na" values.  df = pd.DataFrame({"A":[None, 1, 2, 3, None, None],                   "B":[11, 5, None, None, None, 8],                   "C":[None, 5, 10, 11, None, 8]})  # bfill values using values from next columndf.bfill(axis ='columns')
Output :
Notice the 4th row. All values are na because the rightmost cell was originally na and there is no cell to its right from which it can populate itself. So, it could not populate the previous na cells as well.
smbrtprmnkreg
Python pandas-dataFrame
Python pandas-dataFrame-methods
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
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
numpy.dtype.kind() function – Python

18 Jun, 2020
numpy.dtype.kind() function determine the character code by identifying the general kind of data.
Syntax : numpy.dtype.kind(type)
Parameters :type : [dtype] The input data-type.Return : Return the character code by identifying the general kind of data.
Code #1 :
# Python program explaining# numpy.dtype.kind() function            # importing numpy as geek import numpy as geek   dtype = geek.dtype('f4')  gfg = dtype.kind  print (gfg)
Output :
f

 Code #2 :
# Python program explaining# numpy.dtype.kind() function            # importing numpy as geek import numpy as geek   dtype = geek.dtype('i4')  gfg = dtype.kind  print (gfg)
Output :
i

Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript Ternary Operator

11 Feb, 2021
Below is the example of the Ternary Operator.
Example:Program 1:<script>      function gfg() {       //JavaScript to illustrate     //Conditional operator       let PMarks = 40     let result = (PMarks > 39)?         "Pass":"Fail";       document.write(result);     }      gfg();  </script> 
<script>      function gfg() {       //JavaScript to illustrate     //Conditional operator       let PMarks = 40     let result = (PMarks > 39)?         "Pass":"Fail";       document.write(result);     }      gfg();  </script> 
Output:Pass
Pass
“Question mark” or “conditional” operator in JavaScript is a ternary operator that has three operands.
The expression consists of three operands: the condition, value if true and value if false.
The evaluation of the condition should result in either true/false or a boolean value.
The true value lies between “?” & “:” and is executed if the condition returns true. Similarly, the false value lies after “:” and is executed if the condition returns false.
Syntax:
condition ? value if true : value if false
Expression to be evaluated which returns a boolean value.
value if true:
Value to be executed if condition results in true state.
value if false:
Value to be executed if condition results in false state.
Examples:
Input: let result = (10 > 0) ? true : false;
Output: true

Input: let message = (20 > 15) ? "Yes" : "No";
Output: Yes

The following programs will illustrate conditional operator more extensively:
Program 1:
<script>      function gfg() {       //JavaScript to illustrate     //Conditional operator       let age = 60     let result = (age > 59)?         "Senior Citizen":"Not a Senior Citizen";       document.write(result);     }      gfg();  </script>                  
Output:
Senior Citizen
An example of multiple conditional operators.Program 2:
<script>      function gfg() {      //JavaScript to illustrate    //multiple Conditional operators      let marks = 95;    let result = (marks < 40) ? "Unsatisfactory" :              (marks < 60) ? "Average" :             (marks < 80) ? "Good" : "Excellent" ;      document.write(result);    }      gfg();  </script> 
Output:
Excellent
javascript-operators
Picked
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 ?
AWK - Increment and Decrement Operators

AWK supports the following increment and decrement operators −
It is represented by ++. It increments the value of an operand by 1. This operator first increments the value of the operand, then returns the incremented value. For instance, in the following example, this operator sets the value of both the operands, a and b, to 11.
awk 'BEGIN { a = 10; b = ++a; printf "a = %d, b = %d\n", a, b }'
On executing this code, you get the following result −
a = 11, b = 11

It is represented by --. It decrements the value of an operand by 1. This operator first decrements the value of the operand, then returns the decremented value. For instance, in the following example, this operator sets the value of both the operands, a and b, to 9.
[jerry]$ awk 'BEGIN { a = 10; b = --a; printf "a = %d, b = %d\n", a, b }'
On executing the above code, you get the following result −
a = 9, b = 9

It is represented by ++. It increments the value of an operand by 1. This operator first returns the value of the operand, then it increments its value. For instance, the following code sets the value of operand a to 11 and b to 10.
[jerry]$ awk 'BEGIN { a = 10; b = a++; printf "a = %d, b = %d\n", a, b }'
On executing this code, you get the following result −
a = 11, b = 10

It is represented by --. It decrements the value of an operand by 1. This operator first returns the value of the operand, then it decrements its value. For instance, the following code sets the value of the operand a to 9 and b to 10.
[jerry]$ awk 'BEGIN { a = 10; b = a--; printf "a = %d, b = %d\n", a, b }'
On executing this code, you get the following result −
a = 9, b = 10

 Print
 Add Notes
 Bookmark this page