code-rag-bench/online-tutorials huggingface dataset:
How place a checkbox into the center of a table cell?

23 Jun, 2020
A checkbox can be placed in the center of the table cell by either using the plain CSS stylesheet or with the help of bootstrap. Here we will be seeing different ways to center the checkbox in a cell of the table using pure CSS.
Method 1:
In this method, we are using the display FlexBox property to center the checkbox in the cell of the table. 
Note: This method will not make the text after the checkbox to be treated as the block element and text entered after the check will be visible
Example:
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"         content="width=device-width, initial-scale=1.0">  <title>Document</title></head><style>/* Stylesheet*/  table{    border-collapse: collapse;    padding: 20px;  }  td{    border: 1px solid #000;    padding: 20px;  }  .checkbox{    width: 200px;    background-color:#098043;    color:#fff;    margin: auto;  }  input{    margin: auto;     /*setting margin to auto of the cheeckbox*/    display: flex;/*Flex box property*/  }</style><body>  <!-- Table start-->  <table>  <!-- row start-->    <tr>  <!-- column start-->      <td class="checkbox">Geeks for Geeks</td>      <td class="checkbox">Geeks for Geeks</td>  <!-- Column closed-->    </tr>  <!-- row closed-->    <tr>      <td class="checkbox">        <input type="checkbox">      </td>      <td class="checkbox">        <input type="checkbox">      </td>    </tr>  </table>    </body></html>
Output:
Method 2:
In this method, we will be using Text align center property of the CSS to center the checkbox in the cell.
Note: This method will center everything in the td of the table.
Example:
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"         content="width=device-width, initial-scale=1.0">  <title>Document</title></head><style>  table, td{    border-collapse: collapse;    border: 1px solid #000;    padding: 10px;  }  .checkbox{    text-align: center; /*Centering the text in a td of the table*/  }</style><body>  <table>    <tr>      <td>        Geeks for Geeks      </td>      <td>        Geeks for Geeks      </td>    </tr>    <tr>      <td class="checkbox">        <input type="checkbox">      </td>      <td class="checkbox">        <input type="checkbox">      </td>    </tr>  </table>    </body></html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
Types of CSS (Cascading Style Sheet)
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Design a Tribute Page using HTML & CSS
Write a program to reverse digits of a number in C++

A program to reverse digits of a number will interchange the position of the digits and reverse there order.
Let’s suppose be a number abcde the reverse will be edcba.
Let’s take an example to understand the problem,
n = 786521
125687
To reverse digits of the number, we will take each digit of the number from MSB(unit digit) and add it to reverse number variable, after this divide the original number by 10 and the reverse_number is multiplied by 10. This will be done until the number becomes 0.
This repetitive process can be accomplished by two methods, iteration, and recursion, we will create a program to create illustrate both the method.
 Live Demo
#include <iostream>
using namespace std;
int reversDigitsIt(int n) {
   int reverseNumber = 0;
   while(n > 0){
      reverseNumber = reverseNumber*10 + n%10;
      n /= 10;
   }
   return reverseNumber;
}
int main() {
   int n = 4562;
   cout<<"The number is : "<<n<<endl;
   cout<<"Reverse of number is "<<reversDigitsIt(n);
   return 0;
}
The number is : 4562
Reverse of number is 2654
 Live Demo
#include <iostream>
using namespace std;
int reverseNumber = 0;
int numPos = 1;
void reversDigitsRec(int n) {
   if(n > 0){
      reversDigitsRec(n/10);
      reverseNumber += (n%10)*numPos;
      numPos *= 10;
   }
}
int main() {
   int n = 4562;
   cout<<"The number is : "<<n<<endl;
   reversDigitsRec(n);
   cout<<"Reverse of number is "<<reverseNumber;
   return 0;
}
The number is : 4562
Reverse of number is 2654
Remove Nth Node From End of List in Python

Suppose we have a linked list. We have to remove the Nth node from the end of the list, then return its head. So if the list is like [1, 2, 3, 4, 5, 6] and n = 3, then the returned list will be [1, 2, 3, 5, 6].
To solve this, we will follow these steps −
If there is no node after head, then return None
front := head, back := head, counter := 0 and fount := false
while counter <= nif front is not present, then set flag as true, and come out from the loopfront := next of front, and increase counter by 1
if front is not present, then set flag as true, and come out from the loop
front := next of front, and increase counter by 1
while front is presentfront := next of frontback := next of back
front := next of front
back := next of back
if flag is false, thentemp := next of backnext of back := next of tempnext of temp := None
temp := next of back
next of back := next of temp
next of temp := None
otherwise head := next of head
Return head
Let us see the following implementation to get a better understanding −
 Live Demo
class ListNode:
   def __init__(self, data, next = None):
      self.val = data
      self.next = next
def make_list(elements):
   head = ListNode(elements[0])
   for element in elements[1:]:
      ptr = head
      while ptr.next:
         ptr = ptr.next
      ptr.next = ListNode(element)
   return head
def print_list(head):
   ptr = head
   print('[', end = "")
   while ptr:
      print(ptr.val, end = ", ")
      ptr = ptr.next
   print(']')
class Solution(object):
   def removeNthFromEnd(self, head, n):
      if not head.next:
         return None
      front=head
      back = head
      counter = 0
      flag = False
      while counter<=n:
         if(not front):
            flag = True
            break
         front = front.next
         counter+=1
      while front:
         front = front.next
         back = back.next
      if not flag:
         temp = back.next
         back.next = temp.next
         temp.next = None
      else:
         head = head.next
      return head
head = make_list([1,2,3,4,5,6])
ob1 = Solution()
print_list(ob1.removeNthFromEnd(head, 3))
[1,2,3,4,5,6]
3
[1,2,3,5,6]
Event scheduler in Python

Python gives us a generic scheduler to run tasks at specific times. We will use a module called schedule. In this module we use the every function to get the desired schedules. Below is the features available with the every function..
Schedule.every(n).[timeframe]
Here n is the time interval.
Timeframe can be – seconds, hours, days or even name of the
Weekdays like – Sunday , Monday etc.
In the below example we will see fetch the price of bitcon in every few seconds by using the schedule module. We also use the api provided by coindesk. For that purpose we will use the requests module. We will also need the time module as we need to allow the sleep function to keep the program running and wait for the api to respond, when there is delay in reponse.
import schedule
import time
import requests
Uniform_Resource_Locator="http://api.coindesk.com/v1/bpi/currentprice.json"
data=requests.get(Uniform_Resource_Locator)
input=data.json()
def fetch_bitcoin():
   print("Getting Bitcoin Price")
   result = input['bpi']['USD']
   print(result)
def fetch_bitcoin_by_currency(x):
   print("Getting bitcoin price in: ",x)
   result=input['bpi'][x]
   print(result)
#time
schedule.every(4).seconds.do(fetch_bitcoin)
schedule.every(7).seconds.do(fetch_bitcoin_by_currency,'GBP')
schedule.every(9).seconds.do(fetch_bitcoin_by_currency,'EUR')
while True:
   schedule.run_pending()
   time.sleep(1)
Running the above code gives us the following result
Getting Bitcoin Price
{'code': 'USD', 'symbol': '$', 'rate': '7,069.1967', 'description': 'United States Dollar', 'rate_float': 7069.1967}
Getting bitcoin price in: GBP
{'code': 'GBP', 'symbol': '£', 'rate': '5,279.3962', 'description': 'British Pound Sterling', 'rate_float': 5279.3962}
Getting Bitcoin Price
{'code': 'USD', 'symbol': '$', 'rate': '7,069.1967', 'description': 'United States Dollar', 'rate_float': 7069.1967}
Getting bitcoin price in: EUR
{'code': 'EUR', 'symbol': '€', 'rate': '6,342.4196', 'description': 'Euro', 'rate_float': 6342.4196}
Getting Bitcoin Price
{'code': 'USD', 'symbol': '$', 'rate': '7,069.1967', 'description': 'United States Dollar', 'rate_float': 7069.1967}
DAX Basics in Power BI

In this chapter, you will learn how to use various DAX functions in Power BI.
DAX (Data Analysis Expressions) is a formula expression language and can be used in different BI and visualization tools. DAX is also known as function language, where the full code is kept inside a function. DAX programming formula contains two data types: Numeric and Other. Numeric includes - integers, currency and decimals, while Other includes: string and binary object.
Following is an example of DAX formula, which uses a function to calculate a column in a table.
DAX function can also include other functions, conditional statements, and value references.
In Power BI, you can use different function types to analyze data, and create new columns and measures. It includes functions from different categories such as −
Aggregate
Text
Date
Logical
Counting
Information
Power BI provides an easy way to see the list of all functions. When you start typing your function in the formula bar, you can see the list of all functions starting with that alphabet.
DAX has a number of aggregate functions.
MIN
MAX
Average
SUM
SUMX
Other counting functions in DAX include −
DISTINCTCOUNT
COUNT
COUNTA
COUNTROWS
COUNTBLANK
Following are the collection of Logical functions −
AND
OR
NOT
IF
IFERROR
REPLACE
SEARCH
UPPER
FIXED
CONCATENATE
DATE
HOUR
WEEKDAY
NOW
EOMONTH
ISBLANK
ISNUMBER
ISTEXT
ISNONTEXT
ISERROR
In Power BI, you can create two primary calculations using DAX −
Calculated columns
Calculated measures
When you navigate to the Modeling tab, you can see a New Column option at the top of the screen. This also opens the formula bar where you can enter DAX formula to perform the calculation. DAX - Data Analysis Expression is a powerful language used in Excel to perform calculations. You can also rename the column by changing the Column text in the formula bar.
In the following example, we have created a new column: Product Code (Product_C), which is derived from the last 3 characters of Prod_Id column. Following is the formula −
Product_C = RIGHT( Sheet1[Prod_Id],3)

To create a calculated measure, navigate to New Measure tab under Modeling. This will add a new object under the Fields tab with the name Measure.
You can write DAX formula to calculate the value of the new measure, as we did for the new calculated column.

    42 Lectures 
     3.5 hours 

 Pavan Lalwani

    139 Lectures 
     14 hours 

 Er. Himanshu Vasishta

    40 Lectures 
     4 hours 

 Akshay Magre

    18 Lectures 
     3 hours 

 Mr. Pradeep Kshetrapal

    15 Lectures 
     2.5 hours 

 Richa Maheshwari

    10 Lectures 
     1.5 hours 

 Richa Maheshwari
 Print
 Add Notes
 Bookmark this page
How to delete a column from an existing table in a database using JDBC API?

You can delete a column in a table using the ALTER TABLE command.
ALTER TABLE table_name DROP COLUMN column_name;
Assume we have a table named Sales in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location as shown below:
+----+-------------+--------------+--------------+--------------+-------+----------------+
| id | productname | CustomerName | DispatchDate | DeliveryTime | Price | Location       |
+----+-------------+--------------+--------------+--------------+-------+----------------+
| 1  | Key-Board   | Raja         | 2019-09-01   | 08:51:36     | 7000  | Hyderabad      |
| 2  | Earphones   | Roja         | 2019-05-01   | 05:54:28     | 2000  | Vishakhapatnam |
| 3  | Mouse       | Puja         | 2019-03-01   | 04:26:38     | 3000  | Vijayawada     |
| 4  | Mobile      | Vanaja       | 2019-03-01   | 04:26:35     | 9000  | Chennai        |
| 5  | Headset     | Jalaja       | 2019-04-06   | 05:19:16     | 6000  | Delhi          |
+----+-------------+--------------+--------------+--------------+-------+----------------+
Following JDBC program establishes connection with MySQL database, and deletes the column named ID to from the Sales table.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class DeletingColumn {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Creating the Statement
      Statement stmt = con.createStatement();
      //Query to alter the table
      String query = "ALTER TABLE Sales Drop ID";
      //Executing the query
      stmt.executeUpdate(query);
      System.out.println("Column Deleted......");
   }
}
Connection established......
Column Deleted......
Since we have deleted one column, if you retrieve the contents of the Sales table using the SELECT command you can observe only 6 (no column named id) columns as:
mysql> select * from Sales;
+-------------+--------------+--------------+--------------+-------+----------------+
| ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location       |
+-------------+--------------+--------------+--------------+-------+----------------+
| Key-Board   | Raja         | 2019-09-01   | 05:30:00     | 7000 | Hyderabad       |
| Earphones   | Roja         | 2019-05-01   | 05:54:28     | 2000 | Vishakhapatnam  |
| Mouse       | Puja         | 2019-03-01   | 04:26:38     | 3000 | Vijayawada      |
| Mobile      | Vanaja       | 2019-03-01   | 04:26:35     | 9000 | Chennai         |
| Headset     | Jalaja       | 2019-04-06   | 05:19:16     | 6000 | Delhi           |
+-------------+--------------+--------------+--------------+-------+----------------+
5 rows in set (0.00 sec)
Display the limits of DataTypes in Java

Every data type in Java has a minimum as well as maximum range, for example, for Integer.
Minimum = -2147483648
Maximum = 2147483647
Let’s say for Integer, if the value extends the maximum range display above, it leads to Overflow. However, if the value is less than the minimum range displayed above, it leads to Underflow.
The following program displays the limits on datatypes in Java.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      System.out.println("Limits of primitive DataTypes");
      System.out.println("Byte Datatype values...");
      System.out.println("Min = " + Byte.MIN_VALUE);
      System.out.println("Max = " + Byte.MAX_VALUE);
      System.out.println("Short Datatype values...");
      System.out.println("Min = " + Short.MIN_VALUE);
      System.out.println("Max = " + Short.MAX_VALUE);
      System.out.println("Integer Datatype values...");
      System.out.println("Min = " + Integer.MIN_VALUE);
      System.out.println("Max = " + Integer.MAX_VALUE);
      System.out.println("Float Datatype values...");
      System.out.println("Min = " + Float.MIN_VALUE);
      System.out.println("Max = " + Float.MAX_VALUE);
      System.out.println("Double Datatype values...");
      System.out.println("Min = " + Double.MIN_VALUE);
      System.out.println("Max = " + Double.MAX_VALUE);
   }
}
Limits of primitive DataTypes
Byte Datatype values...
Min = -128
Max = 127
Short Datatype values...
Min = -32768
Max = 32767
Integer Datatype values...
Min = -2147483648
Max = 2147483647
Float Datatype values...
Min = 1.4E-45
Max = 3.4028235E38
Double Datatype values...
Min = 4.9E-324
Max = 1.7976931348623157E308
In the above program, we have taken each datatype one by one and used the following properties to get the minimum and maximum values. For example, datatype Byte.
Byte.MIN_VALUE;
Byte.MAX_VALUE
The above returns the minimum and maximum value of Byte datatype. In the same way, it works for other datatypes.
Min = -128
Max = 127
Design and Analysis Vertex Cover

A vertex-cover of an undirected graph G = (V, E) is a subset of vertices V'  ⊆ V such that if edge (u, v) is an edge of G, then either u in V or v in V' or both.
Find a vertex-cover of maximum size in a given undirected graph. This optimal vertexcover is the optimization version of an NP-complete problem. However, it is not too hard to find a vertex-cover that is near optimal.
APPROX-VERTEX_COVER (G: Graph) c ← { } E' ← E[G] 
while E' is not empty do 
   Let (u, v) be an arbitrary edge of E' c ← c U {u, v} 
   Remove from E' every edge incident on either u or v 
return c

The set of edges of the given graph is −
{(1,6),(1,2),(1,4),(2,3),(2,4),(6,7),(4,7),(7,8),(3,8),(3,5),(8,5)}
Now, we start by selecting an arbitrary edge (1,6). We eliminate all the edges, which are either incident to vertex 1 or 6 and we add edge (1,6) to cover.
In the next step, we have chosen another edge (2,3) at random
Now we select another edge (4,7).
We select another edge (8,5).
Hence, the vertex cover of this graph is {1,2,4,5}.
It is easy to see that the running time of this algorithm is O(V + E), using adjacency list to represent E'.

    102 Lectures 
     10 hours 

 Arnab Chakraborty

    30 Lectures 
     3 hours 

 Arnab Chakraborty

    31 Lectures 
     4 hours 

 Arnab Chakraborty

    43 Lectures 
     1.5 hours 

 Manoj Kumar

    7 Lectures 
     1 hours 

 Zach Miller

    54 Lectures 
     4 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Functional Programming with Java - Parallelism

Parallelism is a key concept of functional programming where a big task is accomplished by breaking in smaller independent tasks and then these small tasks are completed in a parallel fashion and later combined to give the complete result. With the advent of multi-core processors, this technique helps in faster code execution. Java has Thread based programming support for parallel processing but it is quite tedious to learn and difficult to implement without bugs. Java 8 onwards, stream have parallel method and collections has parallelStream() method to complete tasks in parallel fashion. See the example below:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FunctionTester {
   public static void main(String[] args) {

      Integer[] intArray = {1, 2, 3, 4, 5, 6, 7, 8 };
      List<Integer> listOfIntegers = new ArrayList<>(Arrays.asList(intArray));

      System.out.println("List using Serial Stream:");
      listOfIntegers
         .stream()
         .forEach(e -> System.out.print(e + " "));
      System.out.println("");

      System.out.println("List using Parallel Stream:");
      listOfIntegers
         .parallelStream()
         .forEach(e -> System.out.print(e + " "));
      System.out.println("");

      System.out.println("List using Another Parallel Stream:");
      listOfIntegers
         .stream()
         .parallel()
         .forEach(e -> System.out.print(e + " "));
      System.out.println("");

      System.out.println("List using Parallel Stream but Ordered:");
      listOfIntegers
         .parallelStream()
         .forEachOrdered(e -> System.out.print(e + " "));
         System.out.println(""); 
   } 
}
List using Serial Stream:
1 2 3 4 5 6 7 8 
List using Parallel Stream:
6 5 8 7 3 4 2 1 
List using Another Parallel Stream:
6 2 1 7 4 3 8 5 
List using Parallel Stream but Ordered:
1 2 3 4 5 6 7 8 


    32 Lectures 
     3.5 hours 

 Pavan Lalwani

    11 Lectures 
     1 hours 

 Prof. Paul Cline, Ed.D

    72 Lectures 
     10.5 hours 

 Arun Ammasai

    51 Lectures 
     2 hours 

 Skillbakerystudios

    43 Lectures 
     4 hours 

 Mohammad Nauman

    8 Lectures 
     1 hours 

 Santharam Sivalenka
 Print
 Add Notes
 Bookmark this page
How to execute a Python file in Python shell?

To execute a Python file in the python shell, you could use either the execfile method or the exec method.
For example, you want to run a script called my_script.py that only contains the line:
print("Greetings from my_script")
from the python shell, you could simply enter:
>>> execfile('my_script.py')
Greetings from my_script
Or you could use the exec method as follows:
>>> exec(open("my_script.py").read())
Greetings from my_script
Understanding blocking and unblocking of code execution in Node

Now, we have a file writing function writeFileSync in fs module as shown below −
const requestBody = [];
req.on('data', (chunks)=>{
   requestBody.push(chunks);
});
return req.on('end', ()=>{
   const parsedData = Buffer.concat(requestBody).toString();
   const username = parsedData.split('=')[1];
   fs.writeFileSync('username.txt', username);
   //redirect res.statusCode=302;
   res.setHeader('Location','/');
   return res.end();
});
Sync means synchronized. It’s a blocking code example. Once file write is completed then only code execution for rest of the file starts. Above code is simpler but if we have a large file handling operation it will result into slow performance of app.
This way of code execution will slow down the other requests and eventually performance of application.
Solution to this problem is to use asynchronous function of file writing. We have writeFile in fs module which is asynchronous. Below is the example for it −
return req.on('end', ()=>{
   const parsedData = Buffer.concat(requestBody).toString();
   const username = parsedData.split('=')[1];
   fs.writeFile('username.txt', username, (error)=>{
      console.log(error);
   });
   //redirect res.statusCode=302;
   res.setHeader('Location','/');
   return res.end();
});
writeFile takes one more argument i.e. error object. If there is any error in completing the file handling function we can check it with error in console.
This way we can avoid the code blocking. In file handling Node js can use the operating systems multithreading approach to give better performance. It just registers the events and executes them later at specific points.
Asynchronous is most used way of handling operations in node.js like fetching data from server , manipulating the data , pagination etc.
readFile and readFileSync −
similar to write file functions we have read files functions which are also categorized into blocking and non-blocking way.
readFile is non-blocking and readFileSync is blocking. We can use promises to handle operations which are yet to complete but will respond with some resolve once done .
PromiseOperationFunction()
.then( ()=> console.log(‘completed with succes’); )
.catch((err)=> console.log(‘completed with failure’); );
Python datetime.tzname() Method with Example - GeeksforGeeks

23 Aug, 2021
tzname() method is used in the DateTime class of module DateTime. This method is used to return the time zone name of the DateTime object passed, as a string.
Syntax:
tzname()
Return type:
It will return the time zone name of the DateTime object passed, as a string.
So first we need to import the module DateTime, and to get the timezone of the exact place we will simply pass the DateTime stamp generated by datetime.now() function to the tzname() function.
Example 1: Python program that will return the tzinfo() which is none
Python3
# import datetime modulefrom datetime import datetime  # import pytz moduleimport pytz  # get the datetime of the presentdt = datetime.now()  # Tzinfo is missing from the time objectprint(dt)  # display tz info for the dtprint(dt.tzinfo)print("Timezone:", dt.tzname())print()
Output:
2021-08-06 02:58:15.162869
None
Timezone: None
It is also possible to get the timezone of some other place by explicitly adding the timezone. 
Example 2: Python program to add timezone for Asia/Kolkata and get the timezone details
Python3
# import datetime modulefrom datetime import datetime  # import pytz moduleimport pytz  # get the datetime of the presentdt = datetime.now()  # Tzinfo is missing from the time objectprint(dt)  # display tz info for the dtprint(dt.tzinfo)print("Timezone:", dt.tzname())print()  # Adding a timezone for asia /kolkatetimezone = pytz.timezone("Asia/Kolkata")  # getting the timezone using localize methodmydt = timezone.localize(dt)  print(mydt)  # getting the time zone info using tzinfo methodprint("Tzinfo:", mydt.tzinfo)  # display time zone name using tznameprint("Timezone name:", mydt.tzname())
Output:
2021-08-06 03:00:44.949286
None
Timezone: None
2021-08-06 03:00:44.949286+05:30
Tzinfo: Asia/Kolkata
Timezone name: IST
Example 3: Getting the timezone details for asia/Tokyo
Python3
# import datetime modulefrom datetime import datetime  # import pytz moduleimport pytz  # get the datetime of the presentdt = datetime.now()  # Tzinfo is missing from the time objectprint(dt)  # display tz info for the dtprint(dt.tzinfo)print("Timezone:", dt.tzname())print()  # Adding a timezone for asia /Tokyotimezone = pytz.timezone("Asia/Tokyo")  # getting the timezone using localize methodmydt = timezone.localize(dt)  print(mydt)  # getting the time zone info using tzinfo methodprint("Tzinfo:", mydt.tzinfo)  # display time zone name using tznameprint("Timezone name:", mydt.tzname())
Output:
2021-08-06 03:02:02.569770
None
Timezone: None
2021-08-06 03:02:02.569770+09:00
Tzinfo: Asia/Tokyo
Timezone name: JST
Picked
Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Create multiple barplots in R side by side - GeeksforGeeks

30 May, 2021
In R programming language, barplot is a graphical representation of linear data which is one-dimensional. Bar plot is used for statistical analysis for easy understanding of the data. It represents the given data in the form of bars. It can give bar graphs along x-axis and y-axis. Where x-axis represents the name of the data and y-axis represents the bar graph values from 0 to n range.
In this article, we are going to create multiple bar plots side by side in R Programming. If we want to create multiple bar plots side by side then we have to specify the parameter in the above syntax i.e. beside=T. It will specify True. This will place the second, third, ., so on to the next of the bar plots
Syntax:
barplot(data,beside=T)
Where, beside is to place bar plots side by side
Hence, to draw multiple barplots side by side the data for each barplot is initialized and combined using cbind(). Then it is actually plotted using barplot() with beside set to TRUE(T).
Example 1:
R
# college1 vectorcollege1=c(98,89,89.0,78,98,89)  # college2 vectorcollege2=c(88,91,100,78,98,80)  # combine two vectors using cbind # functioncollege_data=cbind(college1,college2)  # pass this college_data to the # barplotbarplot(college_data,beside=T)
Output:
Example 2:
R
# college1 vectorcollege1=c(98,89,89.0,78,98,89)  # college2 vectorcollege2=c(88,91,100,78,98,80)  # college3 vectorcollege3=c(98,89,89.0,100,67,56)    # combine three college vectors # using cbind functioncollege_data=cbind(college1,college2,college3)  # pass this college_data to the barplotbarplot(college_data,beside=T)
Output:
Picked
R-Charts
R-Graphs
R-plots
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 Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Printing Output of an R Program
K-Means Clustering in R Programming
Output of C Programs | Set 2 - GeeksforGeeks

23 Sep, 2020
Predict the output of below programs. Question 1 
c
#include<stdio.h>char *getString(){    char str[] = "Will I be printed?";       return str;}int main(){    printf("%s", getString());    getchar();}
Output: Some garbage value The above program doesn’t work because array variables are stored in Stack Section. So, when getString returns values at str are deleted and str becomes dangling pointer.Question 2  
C
#include<stdio.h>int main(){    static int i=5;    if(--i){        main();        printf("%d ",i);    }  }
0 0 0 0 
Explanation: Since i is a static variable and is stored in Data Section, all calls to main share same i. Question 3  
c
#include<stdio.h>int main(){    static int var = 5;    printf("%d ",var--);    if(var)        main();                  }
5 4 3 2 1 
 Explanation: Same as previous question. The only difference here is, sequence of calling main and printf is changed, therefore different output.Question 4  
C
#include<stdio.h>int main(){    int x;    printf("%d",scanf("%d",&x));    /* Suppose that input value given        for above scanf is 20 */    return 1;}
1
scanf returns the no. of inputs it has successfully read.Question 5  
C
# include <stdio.h>int main(){   int i=0;   for(i=0; i<20; i++)   {     switch(i)     {       case 0:         i+=5;       case 1:         i+=2;       case 5:         i+=5;       default:                       i+=4;         break;     }     printf("%d  ", i);   }    getchar();   return 0;}  
16  21  
Explanation: Initially i = 0. Since case 0 is true i becomes 5, and since there is no break statement till last statement of switch block, i becomes 16. Before starting the next iteration, i becomes 17 due to i++. Now in next iteration no case is true, so execution goes to default and i becomes 21.In C, if one case is true switch block is executed until it finds break statement. If no break statement is present all cases are executed after the true case. If you want to know why switch is implemented like this, well this implementation is useful for situations like below. 
 switch (c)
 {
    case 'a':
    case 'e':
    case 'i' :
    case 'o':
    case 'u':
      printf(" Vowel character");
      break;
    default : 
      printf("Not a Vowel character"); 
      break;    
  } 
Garvit Anand
GAYATRIDIGAMBAR
Sudheer Kumar 12
algobeast
pradeepreddygujjula
C-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of Java program | Set 18 (Overriding)
Output of Java Program | Set 11
Output of Java programs | Set 13 (Collections)
Output of C++ programs | Set 34 (File Handling)
Different ways to copy a string in C/C++
Output of Java Program | Set 3
Runtime Errors
Output of Java program | Set 28
Output of Java program | Set 5
Output of Java Programs | Set 12
How to Set the Gap Between Text and Underlining using CSS ? - GeeksforGeeks

11 Jun, 2021
Introduction: CSS is used to make the website visually more appealing and more readable. It can be used to format the text on the website in various ways like color, font-size, font-family, etc. In this article, we are going to see how in the case of underlined text, increase the gap between text and underline.Approach: The trick that we are going to use to achieve this by using border-bottom-style and padding-bottom property. Instead of using the built-in text-decoration: underline; we are going to create our own underline using border-bottom-style property and then we can add padding-bottom to push it away as much amount we want.Syntax:  
.class_name {
    padding-bottom: value;
    border-bottom-style: solid;
}
Example: We can increase the gap between the text and underlining using CSS. 
html
<!DOCTYPE html><html>  <head>    <title>        How to Set the Gap Between Text        and Underlining using CSS ?    </title>         <style>        .line {                         /* Increase this as per requirement */            padding-bottom: 15px;            border-bottom-style: solid;            border-bottom-width: 3.1px;            width: fit-content;        }                  .normal-underline {            text-decoration: underline;        }    </style></head>  <body>    <h1 class="normal-underline">        GeeksforGeeks: with normal underline    </h1>         <h1 class="line">        GeeksforGeeks: with spaced underline    </h1></body>  </html>
Output:  
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
blalverma92
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
How to apply style to parent if it has child with CSS?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
How to set space between the flexbox ?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
What are C++ Character Constants?

Character constants are one or more members of the “source character set,” the character set in which a program is written, surrounded by single quotation marks ('). They are used to represent characters in the “execution character set,” the character set on the machine where the program executes. These are sometimes also called character literals.
In C++, A character literal is composed of a constant character. It is represented by the character surrounded by single quotation marks. There are two kinds of character literals −
 Narrow-character literals of type char, for example, 'a'
 Wide-character literals of type wchar_t, for example, L'a'
The character used for a character literal may be any graphic character, except for reserved characters such as newline ('\n'), backslash ('\'), single quotation mark ('), and double quotation mark ("). Reserved characters are be specified with an escape sequence. 
Live Demo
#include <iostream>
using namespace std;
int main() {
   char newline = '\n';
   char tab = '\t';
   char backspace = '\b';
   char backslash = '\\';
   char nullChar = '\0';

   cout << "Newline character: " << newline << "ending" << endl;
   cout << "Tab character: " << tab << "ending" << endl;
   cout << "Backspace character: " << backspace << "ending" << endl;
   cout << "Backslash character: " << backslash << "ending" << endl;
   cout << "Null character: " << nullChar << "ending" << endl;
}
This gives the output −
Newline character:
ending
Tab character:  ending
Backspace character: ending
Backslash character: \ending
Null character:  ending
Rexx - Arithmetic Operators

The Rexx language supports the normal Arithmetic Operators as any the language. Following are the Arithmetic Operators available in Rexx.
The following program shows how the various operators can be used.
/* Main program*/ 
X = 40 
Y = 50 

Res1 = X + Y 
Res2 = X - Y 
Res3 = X * Y 
Res4 = X / Y 
Res5 = X % Y 
Res6 = X // Y 

say Res1 
say Res2 
say Res3 
say Res4 
say Res5 
say Res6 
The output of the above program will be −
90
-10
2000
0.8
0
40

 Print
 Add Notes
 Bookmark this page
Program to convert Linked list representing binary number to decimal integer in Python

Suppose we have a singly linked list. the linked list is representing a binary number with most significant digits first, we have to return it as decimal number.
So, if the input is like [1,0,1,1,0], then the output will be 22
To solve this, we will follow these steps −
l := a new list
while node is not null, doinsert value of node at the end of lnode:= next of node
insert value of node at the end of l
node:= next of node
k := 0, v:= 0
for i in range size of l - 1 to 0, decrease by 1, doif l[i] is same as 1, thenv := v + 2^kk := k + 1
if l[i] is same as 1, thenv := v + 2^k
v := v + 2^k
k := k + 1
return v
Let us see the following implementation to get better understanding −
 Live Demo
class ListNode:
   def __init__(self, data, next = None):
      self.val = data
      self.next = next
def make_list(elements):
   head = ListNode(elements[0])
   for element in elements[1:]:
      ptr = head
      while ptr.next:
         ptr = ptr.next
         ptr.next = ListNode(element)
   return head
class Solution:
   def solve(self, node):
      l = []
      while node:
         l.append(node.val)
         node=node.next
         k = 0
         v=0
         for i in range(len(l)-1,-1,-1):
            if (l[i]==1):
            v += (2**k)
k+=1
return v
ob = Solution()
head = make_list([1,0,1,1,0])
print(ob.solve(head))
[1,0,1,1,0]
22
Constants of Maths in Python - GeeksforGeeks

17 May, 2020
Math module is a standard in-built module in Python that can be used for performing the mathematical tasks. The math module has a set of methods and constants.
Note: For more information, refer to Math-library-functions
1. Python math.e constant: The math.e constant returns the Euler’s number: 2.71828182846.
Syntax: math.e
Returns: Return a float value, 2.71828182846, representing the mathematical constant e
Example:
# Import math Libraryimport math  # Print the value of Euler eprint (math.e)
Output:
2.718281828459045

2. Python math.pi constant: The math.pi constant returns the value pi: 3.14159265359. It is defined as the ratio of the circumference to the diameter of a circle.
Syntax: math.pi
Returns: A float value, 3.14159265359, representing the mathematical constant PI
Example:
# Import math Libraryimport math  # Print the value of piprint (math.pi)
Output:
3.141592653589793

3. Python math.tau constant: The math.tau constant returns the value tau: 6.283185307179586. It is defined as the ratio of the circumference to the radius of a circle.
Syntax: math.tau
Returns: A float value, 6.283185307179586, representing the mathematical constant tau
Example:
# Import math Libraryimport math  # Print the value of tauprint (math.tau)
Output:
6.283185307179586

4. Python math.inf constant: The math.inf constant returns of positive infinity.For negative infinity, use -math.inf.The inf constant is equivalent to float(“inf”).
Syntax: math.inf
Returns: A float value, returns the value of positive infinity.
Example:
# Import math Libraryimport math  # Print the positive infinityprint (math.inf)  # Print the negative infinityprint (-math.inf)
Output:
inf
-inf

5. Python math.nan constant: The math.nan constant returns a floating-point nan (Not a Number) value. This value is not a legal number.The nan constant is equivalent to float(“nan”).
Syntax: math.nan
Returns: A float value, nan (Not a Number)
Example:
# Import math Libraryimport math  # Print the value of nanprint (math.nan)
Output:
nan

Python math-library
Python math-library-functions
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Matplotlib.pyplot.title() in Python
Factory method design pattern in Java
Objective-C Protocols

Objective-C allows you to define protocols, which declare the methods expected to be used for a particular situation. Protocols are implemented in the classes conforming to the protocol.
A simple example would be a network URL handling class, it will have a protocol with methods like processCompleted delegate method that intimates the calling class once the network URL fetching operation is over.
A syntax of protocol is shown below.
@protocol ProtocolName
@required
// list of required methods
@optional
// list of optional methods
@end

The methods under keyword @required must be implemented in the classes that conforms to the protocol and the methods under @optional keyword are optional to implement.
Here is the syntax for class conforming to protocol
@interface MyClass : NSObject <MyProtocol>
...
@end

This means that any instance of MyClass will respond not only to the methods declared specifically in the interface, but that MyClass also provides implementations for the required methods in MyProtocol. There's no need to redeclare the protocol methods in the class interface - the adoption of the protocol is sufficient.
If you need a class to adopt multiple protocols, you can specify them as a comma-separated list. We have a delegate object that holds the reference of the calling object that implements the protocol.
An example is shown below.
#import <Foundation/Foundation.h>

@protocol PrintProtocolDelegate
- (void)processCompleted;

@end

@interface PrintClass :NSObject {
   id delegate;
}

- (void) printDetails;
- (void) setDelegate:(id)newDelegate;
@end

@implementation PrintClass
- (void)printDetails {
   NSLog(@"Printing Details");
   [delegate processCompleted];
}

- (void) setDelegate:(id)newDelegate {
   delegate = newDelegate;
}

@end

@interface SampleClass:NSObject<PrintProtocolDelegate>
- (void)startAction;

@end

@implementation SampleClass
- (void)startAction {
   PrintClass *printClass = [[PrintClass alloc]init];
   [printClass setDelegate:self];
   [printClass printDetails];
}

-(void)processCompleted {
   NSLog(@"Printing Process Completed");
}

@end

int main(int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   SampleClass *sampleClass = [[SampleClass alloc]init];
   [sampleClass startAction];
   [pool drain];
   return 0;
}
Now when we compile and run the program, we will get the following result.
2013-09-22 21:15:50.362 Protocols[275:303] Printing Details
2013-09-22 21:15:50.364 Protocols[275:303] Printing Process Completed

In the above example we have seen how the delgate methods are called and executed. Its starts with startAction, once the process is completed, the delegate method processCompleted is called to intimate the operation is completed.
In any iOS or Mac app, we will never have a program implemented without a delegate. So its important we understand the usage of delegates. Delegates objects should use unsafe_unretained property type to avoid memory leaks.

    18 Lectures 
     1 hours 

 PARTHA MAJUMDAR

    6 Lectures 
     25 mins

 Ken Burke
 Print
 Add Notes
 Bookmark this page
java.time.Period.between() Method Example

The java.time.Period.between() method obtains a Period representing the Period between two LocalDate objects.
Following is the declaration for java.time.Period.between() method.
public static Period between(LocalDate startInclusive, LocalDate endExclusive)

startInclusive − the start date, inclusive, not null.
startInclusive − the start date, inclusive, not null.
endExclusive − the end date, exclusive, not null.
endExclusive − the end date, exclusive, not null.
a Period, not null.
The following example shows the usage of java.time.Period.between() method.
package com.tutorialspoint;

import java.time.LocalDate;
import java.time.Period;

public class PeriodDemo {
   public static void main(String[] args) {

      Period period = Period.between(LocalDate.ofYearDay(2017, 200), 
         LocalDate.ofYearDay(2017, 300));

      System.out.println(period);  
   }
}
Let us compile and run the above program, this will produce the following result −
P3M8D

 Print
 Add Notes
 Bookmark this page
What are the uses of generic collections in Java?

The generic collections are introduced in Java 5 Version. The generic collections disable the type-casting and there is no use of type-casting when it is used in generics. The generic collections are type-safe and checked at compile-time. These generic collections allow the datatypes to pass as parameters to classes. The Compiler is responsible for checking the compatibility of the types.
class<type>, interface<type>
Generics allows a single type of object.
List list = new ArrayList(); // before generics
list.add(10);
list.add("100");
List<Integer> list1 = new ArrayList<Integer>(); // adding generics
list1.add(10);
list1.add("100"); // compile-time error.
No need for type-casting while using generics.
List<String> list = new ArrayList<String>();
list.add("Adithya");
String str = list.get(0); // no need of type-casting
The errors are checked at compile-time in generics.
List list = new ArrayList(); // before generics
list.add(10);
list.add("100");
List<Integer> list1 = new ArrayList<Integer>(); // adding generics
list1.add(10);
list1.add("100");// compile-time error
chown - Unix, Linux Command

chown - To change owner, change the user and/or group ownership of each given File to a new Owner. Chown can also change the ownership of a file to match the user/group of an existing reference file.
chown [Options]... NewOwner File...
chown [Options]... :Group File...
chown [Options]... --reference=RFILE File...
If used, NewOwner specifies the new owner and/or group as follows(with no embedded white space):
chown [OWNER] [ [:.] [GROUP] ]
Following are the examples of how the owner/group can be specified:
If only an OWNER (a user name or numeric user id) is given, that user is made the owner of each given file, and the files' group is not changed.
chown OWNER

If only an OWNER (a user name or numeric user id) is given, that user is made the owner of each given file, and the files' group is not changed.
chown OWNER
If the OWNER is followed by a colon or dot and a GROUP (a group name or numeric group id), with no spaces between them, the group ownership of the files is changed as well (to GROUP).
chown OWNER.GROUP
chown OWNER:GROUP

If the OWNER is followed by a colon or dot and a GROUP (a group name or numeric group id), with no spaces between them, the group ownership of the files is changed as well (to GROUP).
chown OWNER.GROUP
chown OWNER:GROUP
If a colon or dot but no group name follows OWNER, that user is made the owner of the files and the group of the files is changed to OWNER's login group.
chown OWNER.
chown OWNER:

If a colon or dot but no group name follows OWNER, that user is made the owner of the files and the group of the files is changed to OWNER's login group.
chown OWNER.
chown OWNER:
If the colon or dot and following GROUP are given, but the owner is omitted, only the group of the files is changed; in this case, 'chown' performs the same function as 'chgrp'.
chown .GROUP
chown :GROUP

If the colon or dot and following GROUP are given, but the owner is omitted, only the group of the files is changed; in this case, 'chown' performs the same function as 'chgrp'.
chown .GROUP
chown :GROUP
Change the owner of file.
$ chown user1 sample.txt
Change the group of file.
$ chown :mygroup file.txt
Change both the owner and group of file in single command.
$ chown user1:mygroup file.txt

    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page