code-rag-bench/online-tutorials huggingface dataset:
Find the memory size of a NumPy array - GeeksforGeeks

02 Sep, 2020
In this post, we will see how to find the memory size of a NumPy array. So for finding the memory size we are using following methods:
Method 1: Using size and itemsize attributes of NumPy array.
size: This attribute gives the number of elements present in the NumPy array.
itemsize: This attribute gives the memory size of one element of NumPy array in bytes.
Let’s see the examples:
Example 1:
Python3
# import libraryimport numpy as np  # create a numpy 1d-arrayx = np.array([100,20,34])  print("Size of the array: ",      x.size)  print("Memory size of one array element in bytes: ",      x.itemsize)  # memory size of numpy array in bytesprint("Memory size of numpy array in bytes:",      x.size * x.itemsize)
Output:
Size of the array:  3
Memory size of one array element in bytes:  4
Memory size of numpy array in bytes: 12

Example 2:
Python3
# import libraryimport numpy as np  # create a numpy 2d-arrayx = np.array([[100, 20, 34],              [300, 400, 600]])  print("Size of the array: ",      x.size)  print("Memory size of one array element in bytes: ",      x.itemsize)  # memory size of numpy arrayprint("Memory size of numpy array in bytes:",      x.size * x.itemsize)
Output:
Size of the array:  6
Length of one array element in bytes:  4
Memory size of numpy array in bytes: 24

Method 2: Using nbytes attribute of NumPy array.
nbytes: This attribute gives the total bytes consumed by the elements of the NumPy array.
Let’s see the examples:
Example 1:
Python3
# import libraryimport numpy as np  # create numpy 1d-arrayx = np.array([100, 20, 34])  print("Memory size of a NumPy array:",      x.nbytes)
Output:
Memory size of a NumPy array: 12

Example 2:
Python3
# import libraryimport numpy as np  # create numpy 2d-arrayx = np.array([[100, 20, 34],              [300, 400, 600]])  print("Memory size of a NumPy array:",      x.nbytes)
Output:
Memory size of a NumPy array: 24

Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Scala - Default Parameter Values for a Function

Scala lets you specify default values for function parameters. The argument for such a parameter can optionally be omitted from a function call, in which case the corresponding argument will be filled in with the default. If you specify one of the parameters, then first argument will be passed using that parameter and second will be taken from default value.
Try the following example, it is an example of specifying default parameters for a function −
object Demo {
   def main(args: Array[String]) {
      println( "Returned Value : " + addInt() );
   }
   
   def addInt( a:Int = 5, b:Int = 7 ) : Int = {
      var sum:Int = 0
      sum = a + b

      return sum
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

Returned Value : 12


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to remove rows in an R data frame column that has duplicate values greater than or equal to a certain number of times?

To remove rows from the data frame that duplicate values greater than a certain number of times, we can create a subset for rows having duplicate values less than the certain number of times. For this purpose, we first need to extract the rows and then subset the data frame with the particular column as shown in the below examples.
Consider the below data frame −
Live Demo
> x1<-rpois(20,1)
> x2<-rpois(20,1)
> df1<-data.frame(x1,x2)
> df1
   x1 x2
1  0  0
2  0  0
3  1  0
4  0  1
5  0  0
6  1  1
7  0  1
8  1  1
9  1  2
10 0  0
11 1  1
12 0  0
13 1  1
14 2  2
15 1  1
16 1  0
17 1  1
18 0  3
19 2  0
20 0  0
Removing rows based on x1 that has number of duplicate values greater than or equal to 3 −
df1[df1$x1 %in% names(which(table(df1$x1)<3)),]
   x1 x2
14 2  2
19 2  0
Live Demo
> y1<-rpois(20,2)
> y2<-rpois(20,2)
> y3<-rpois(20,2)
> df2<-data.frame(y1,y2,y3)
> df2
   y1 y2 y3
1  2  2  1
2  1  2  0
3  1  2  3
4  3  1  4
5  2  1  1
6  2  1  2
7  1  0  1
8  0  3  5
9  6  1  3
10 2  2  2
11 0  3  0
12 2  2  3
13 3  2  0
14 2  2  4
15 1  0  1
16 1  1  2
17 3  1  3
18 2  4  1
19 0  1  2
20 0  0  0
Removing rows based on y2 that has number of duplicate values greater than or equal to 2 −
> df2[df2$y2 %in% names(which(table(df2$y2)<2)),]
   y1 y2 y3
18 2  4  1
Live Demo
> z1<-rpois(20,2)
> z2<-rpois(20,2)
> z3<-rpois(20,2)
> z4<-rpois(20,2)
> df3<-data.frame(z1,z2,z3,z4)
> df3
   z1 z2 z3 z4
1  5  1  3  3
2  1  1  3  3
3  1  1  2  5
4  1  1  2  6
5  3  5  0  1
6  1  3  1  1
7  0  2  0  0
8  2  0  1  2
9  4  1  3  1
10 3  2  1  1
11 1  0  1  1
12 2  3  0  4
13 0  1  2  1
14 2  3  3  2
15 4  2  0  4
16 1  4  2  2
17 0  2  2  3
18 2  1  2  1
19 4  3  4  1
20 3  3  5  2
Removing rows based on z1 that has number of duplicate values greater than or equal to 2 −
> df3[df3$z1 %in% names(which(table(df3$z1)<2)),]
  z1 z2 z3 z4
1 5  1  3  3
Java Examples - Use of enum & switch statement

How to use enum & switch statement ?
This example displays how to check which enum member is selected using Switch statements.
enum Car {
   lamborghini,tata,audi,fiat,honda
}
public class Main {
   public static void main(String args[]){
      Car c;
      c = Car.tata;
      switch(c) {
         case lamborghini:
            System.out.println("You choose lamborghini!");
            break;
         case tata:
            System.out.println("You choose tata!");
            break;
         case audi:
            System.out.println("You choose audi!");
            break;
         case fiat:
            System.out.println("You choose fiat!");
            break;
         case honda:
            System.out.println("You choose honda!");
            break;
         default:
            System.out.println("I don't know your car.");
            break;
      }
   }
}
The above code sample will produce the following result.
You choose tata!

The following is an another example of enum & switch statement
public class MainClass {
   enum Choice { Choice1, Choice2, Choice3 }
   public static void main(String[] args) {
      Choice ch = Choice.Choice1;

      switch(ch) {
         case Choice1:
            System.out.println("Choice1 selected");
            break;
         case Choice2:
            System.out.println("Choice2 selected");
            break;
         case Choice3:
            System.out.println("Choice3 selected");
             break;
      }
   }
}
The above code sample will produce the following result.
Choice1 selected

 Print
 Add Notes
 Bookmark this page
Important Topics for GATE 2020 Computer Science

16 Sep, 2021
GATE CS 2022 TS
These topics are categorized based on the previous GATE CS Papers:
Propositional logic and predicate logic
Matrix determinant and eigen values
Conditional probability
Graph connectivity
Relations
Mathematical logic
Linear algebra
Propositional logic
Linear algebra
Graph theory
Probability
Predicate logic
Groups
functions
Lattice theory
Counting
Algorithm Analysis
Heap trees
Sorting
Graph Algorithms
Sorting algorithms
Searching and sorting algorithms
Divide and conquer
Greedy algorithms
Divide and conquer
Dynamic programming algorithms
Recursive programs
Trees and graphs
Trees
Stacks and Queues
Trees
Recursive functions, and pointers
CPU Scheduling Algorithms
Paging
Semaphores
Page replacement algorithms
Page replacement algorithms
Paging
CPU Scheduling
Page replacement
Semaphore
Paging and Segmentation
Disk scheduling algorithms
Deadlock
Relational Algebra
SQL
Serializability
Relational
Tuple
SQL queries
Normalization
Relational algebra
Transactions
SQL
ER-diagrams
IP Addressing
TCP and UDP
Application protocols
Congestion control
IP Addressing
TCP
Ethernet
IP addressing
Routing Algorithms
Encryption and Decryption algorithms
Pipelining
Cache organization
Addressing modes
Cache organization
Addressing modes and Machine cycles
Cache organization
Pipelining
I/O Data transfer
DFA and Regular expression
Closure properties and Undecidability
Regular languages
Undecidability
Regular expressions
Closure properties
Undecidability
CFL and DCFL
Formal grammars and CNF
LL(1) and LR parsers
Parsing
Lexical Analysis and syntax Analysis
Intermediate code generation
Syntax directed translations(SDTs)
Run time environments
Combinational circuits: Multiplexer, decoder and demultiplexer
Minimization
Counters
Combinational circuits
Minimization
Combinational circuits
Sequential circuits
Number system, fixed and floating point numbers
Registers
Numerical computation
Data interpretation
Sentence completion
Word analogies
GATE CS 2019 topic wise notesGATE CS Previous Year Solved PapersLast minutes notes for GATE CS
GATE CS 2019 topic wise notes
GATE CS Previous Year Solved Papers
Last minutes notes for GATE CS
If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
nnr223442
Articles
GATE
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to capitalize first character of string in Python

29 Jun, 2022
The problem of case changes in a string is quite common and has been discussed many times. Sometimes, we might have a problem like this in which we need to convert the initial character of the string to the upper case. Let’s discuss certain ways in which this can be performed.
Method #1: Using string slicing + upper() This task can easily be performed using the upper method which uppercases the characters provided to it and slicing can be used to add the remaining string after the lowercase first character. 
Python3
# Python3 code to demonstrate working of# Initial character upper case# Using upper() + string slicing # initializing stringtest_str = "geeksforgeeks & quot # printing original stringprint(& quot       The original string is : & quot       + str(test_str)) # Using upper() + string slicing# Initial character upper caseres = test_str[0].upper() + test_str[1:] # printing resultprint(& quot       The string after uppercasing initial character : & quot       + str(res))
The original string is : geeksforgeeks
The string after uppercasing initial character : Geeksforgeeks
Method #2 : Using capitalize() We can use the inbuilt method to perform this task. This method is recommended to solve this problem and performs the task of converting to upper case internally. 
Python3
# Python3 code to demonstrate working of# Initial character upper case# Using capitalize() + string slicing # initializing stringtest_str = "geeksforgeeks & quot # printing original stringprint(& quot       The original string is : & quot       + str(test_str)) # Using capitalize() + string slicing# Initial character upper caseres = test_str.capitalize() # printing resultprint(& quot       The string after uppercasing initial character : & quot       + str(res))
The original string is : geeksforgeeks
The string after uppercasing initial character : Geeksforgeeks
Method #3: Using str.title() method We can use string title function to perform this task. Title function convert the first letter of word to upper case and remaining to lower case. 
Python3
# Python3 code to demonstrate working of# Initial character upper case# Using title function of string # initializing stringtest_str = "geeksforgeeks" # printing original stringprint("The original string is : " + str(test_str)) # Using str.title()# Initial character upper caseres = test_str.title() # printing resultprint("The string after uppercasing initial character : " + str(res))
The original string is : geeksforgeeks
The string after uppercasing initial character : Geeksforgeeks

satyam00so
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
TypeScript | toLocaleString() Function

11 Jun, 2020
The toLocaleString() method in TypeScript is to convert the number into a local specific representation of the number using the locale of the environment.
Syntax:
number.toLocaleString()
Return Value: The toLocaleString() method in TypeScript returns a human readable string representing the number using the locale of the environment.
Below examples illustrate the working of toLocaleString() function in TypeScript:
Example 1:
<script>  // toLocaleString() methodvar num = new Number(432.3456);console.log(num.toLocaleString());</script>
Output:
432.3456

Example 2:
<script>  // toLocaleString() methodlet Number_1 : number = 23415.456;console.log("Number Method: toLocaleString()");  // returns in US Englishconsole.log(Number_1.toLocaleString()); </script>
Output:
Number Method: toLocaleString()
23, 415.456

TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to display percentage above a bar chart in Matplotlib?

To display percentage above a bar chart in Matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points; initialize a variable, width.
Create a figure and a set of subplots using subplots() method.
Add bars with x and y data points.
Iterate bars patches; put text over the bars using text() method.
To display the figure, use show() method.
from matplotlib import pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = [1, 2, 3, 4, 5]
y = [3, 4, 2, 1, 3]

width = 0.35
fig, ax = plt.subplots()

pps = ax.bar(x, y, width, align='center')

for p in pps:
   height = p.get_height()
   ax.text(x=p.get_x() + p.get_width() / 2, y=height+.10,
      s="{}%".format(height),
      ha='center')

plt.show()
Get n-largest values from a particular column in Pandas DataFrame

18 Dec, 2018
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).
Let’s see how can we can get n-largest values from a particular column in Pandas DataFrame.
Observe this dataset first. We’ll use ‘Age’, ‘Weight’ and ‘Salary’ columns of this data in order to get n-largest values from a particular column in Pandas DataFrame.
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df.head(10)
Code #1: Getting 5 largest Age
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")   # five largest values in column agedf.nlargest(5, ['Age'])
Output: 
Code #2: Getting 10 maximum weights
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")   # Ten largest values in column Weightdf.nlargest(10, ['Weight'])
Output: 
Code #3: Getting 10 maximum salary
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")   # five largest values in column Salarydf.nlargest(5, ['Salary'])
Output:
pandas-dataframe-program
Python pandas-dataFrame
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
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
Numpy | Sorting, Searching and Counting - GeeksforGeeks

15 Nov, 2018
Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order. Most common orders are in numerical or lexicographical order. In Numpy, we can perform various sorting operations using the various functions that are provided in the library like sort, lexsort, argsort etc.
numpy.sort() : This function returns a sorted copy of an array.
Output :
Along first axis : 
 [[10  1]
 [12 15]]

Along first axis : 
 [[10 15]
 [ 1 12]]

Along none axis : 
 [ 1 10 12 15]
 numpy.argsort() : This function returns the indices that would sort an array.
Output:
Original array:
 [9 3 1 7 4 3 6]
Sorted indices of original array-> [2 1 5 4 6 3 0]
Sorted array-> [1 3 3 4 6 7 9]

 numpy.lexsort() : This function returns an indirect stable sort using a sequence of keys.
Output :
column a, column b
9   4
3   6
1   9
3   2
4   1
3   8
6   7
Sorted indices-> [2 3 1 5 4 6 0]

 
Searching is an operation or a technique that helps finds the place of a given element or value in the list. Any search is said to be successful or unsuccessful depending upon whether the element that is being searched is found or not. In Numpy, we can perform various searching operations using the various functions that are provided in the library like argmax, argmin, nanaargmax etc.
numpy.argmax() : This function returns indices of the max element of the array in a particular axis.
Output :
INPUT ARRAY : 
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]

Max element :  11

Indices of Max element :  [2 2 2 2]

Indices of Max element :  [3 3 3]

 numpy.nanargmax() : This function returns indices of the max element of the array in a particular axis ignoring NaNs.The results cannot be trusted if a slice contains only NaNs and Infs.
Output :
INPUT ARRAY 1 : 
 [nan, 4, 2, 3, 1]

Indices of max in array1 :  1

INPUT ARRAY 2 : 
 [[ nan   4.]
 [  1.   3.]]

Indices of max in array2 :  1

Indices at axis 1 of array2 :  [1 1]

 numpy.argmin() : This function returns the indices of the minimum values along an axis.
Output :
INPUT ARRAY : 
 [0 1 2 3 4 5 6 7]

Indices of min element :  0

 
numpy.count_nonzero() : Counts the number of non-zero values in the array .
Output :
Number of nonzero values is : 5
Number of nonzero values is : [1, 1, 1, 1, 1]

 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Learn C++ Programming Step by Step - A 20 Day Curriculum!
Must Do Coding Questions for Product Based Companies
CSS Interview Questions and Answers
50 Common Ports You Should Know
GeeksforGeeks Jobathon - Are You Ready For This Hiring Challenge?
How to Find Length of String in Bash Script?
Samsung R&D Internship Interview Experience (On-Campus)
Tiger Analytics Interview Experience for Data Analyst (On-Campus)
Amazon Interview Experience for SDE-1
Python – Element Index in Range Tuples

16 Jan, 2022
Sometimes, while working with Python data, we can have a problem in which we need to find the element position in continuous equi ranged tuples in list. This problem has applications in many domains including day-day programming and competitive programming. Let’s discuss certain ways in which this task can be performed. 
Input : test_list = [(0, 10), (11, 20), (21, 30), (31, 40)] K = 37 Output : 3Input : test_list = [(0, 9), (10, 19), (20, 29), (30, 39)] K = 37 Output : 3  
Method #1 : Using loop This is brute force way in which this task can be performed. In this, we iterate for all the elements in the list and then using comparison operators, find the position of the desired element. 
Python3
# Python3 code to demonstrate working of# Element Index in Range Tuples# Using loop # initializing listtest_list = [(0, 10), (11, 20), (21, 30), (31, 40), (41, 50)] # printing original listprint("The original list is : " + str(test_list)) # initializing ElementK = 37 # Element Index in Range Tuples# Using loopres = Nonefor idx, ele in enumerate(test_list):    if K >= ele[0] and K <= ele[1]:        res = idx         # printing resultprint("The position of element : " + str(res))
The original list is : [(0, 10), (11, 20), (21, 30), (31, 40), (41, 50)]
The position of element : 3
 
 Method #2 : Using formula The element position can also be divided without using a loop, but to extract the same using division of element with the range size, being it consistent. 
Python3
# Python3 code to demonstrate working of# Element Index in Range Tuples# Using formula # initializing listtest_list = [(0, 10), (11, 20), (21, 30), (31, 40), (41, 50)] # printing original listprint("The original list is : " + str(test_list)) # initializing ElementK = 37 # Element Index in Range Tuples# Using formulares = (K // (test_list[0][1] - test_list[0][0]))         # printing resultprint("The position of element : " + str(res))
The original list is : [(0, 10), (11, 20), (21, 30), (31, 40), (41, 50)]
The position of element : 3
 
akshaysingh98088
adnanirshad158
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to get IP address settings using PowerShell?

To get the IP address of the system we can use IPConfig command in cmd and the same command can be used in PowerShell. IPConfig command shows all the connected and disconnected adapters including IPv4 and IPv6. For example,
PS C:\Users\Administrator> Ipconfig

Windows IP Configuration

Ethernet adapter Ethernet0:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.0.104
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

Tunnel adapter isatap.{27E40122-664A-404D-A4C9-4E48C0363BC5}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter Local Area Connection* 3:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::2ca8:29d5:3f57:ff97%5
   Default Gateway . . . . . . . . . :

But the problem with this utility is if you need to filter specific property like adapter name or the IP family (IPv4 or IPv6), string operation is required to filter the result out and this takes a bunch of lines of code to write. PowerShell also supports the similar command Get-NetIPAddress.
Get-NetIPAddress | ft -AutoSize
To retrieve only IPv4 addresses,
Get-NetIPAddress -AddressFamily IPv4 | ft -AutoSize

Similarly, you can retrieve IPv6 addresses.
Get-NetIPAddress -AddressFamily IPv6 | ft -AutoSize
You can also check if the IP is through DHCP or configured manually. Check the PrefixOrigin and SuffixOrigin properties in the above IPv4 example and that is DHCP. If you have static IP configured then the same will be reflected in both the properties. For Example,
To retrieve the IP address for the specific interface, use -InterfaceIndex parameter. For example,
Get-NetIPAddress -InterfaceIndex 3 | ft -AutoSize

To get the IP address settings for the remote computer, there is -CimSession parameter supported.
$sess = New-CimSession -ComputerName Test1-win2k16
Get-NetIPAddress -CimSession $sess | ft -AutoSize
You can apply the other parameters to filter out the result as mentioned in the above examples.
How to create a responsive side navigation menu with CSS?

Following is the code to create a responsive side navigation menu with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
   margin: 0;
   font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
nav {
   margin: 0;
   padding: 0;
   width: 150px;
   background-color: #2f77e4;
   position: fixed;
   height: 100%;
   overflow: auto;
}
nav a {
   display: block;
   color: rgb(255, 255, 255);
   font-weight: bolder;
   font-size: 20px;
   padding: 16px;
   text-decoration: none;
}
nav a.selected {
   background-color: rgb(15, 189, 20);
   color: rgb(255, 255, 255);
}
nav a:hover:not(.selected) {
   background-color: white;
   color: #2f77e4;
}
div.content {
   margin-left: 200px;
   padding: 1px 16px;
   height: 1000px;
}
@media screen and (max-width: 700px) {
nav {
   width: 100%;
   height: auto;
   position: relative;
}
nav a {float: left;}
div.content {margin-left: 0;}
}
</style>
</head>
<body>
<nav class="sideBar">
<a class="selected" href="#">Home</a>
<a href="#">Login</a>
<a href="#">Register</a>
<a href="#">Message Us</a>
<a href="#">Contact Us</a>
</nav>
<div class="content">
<h1>Sample Text</h1>
<h2>Resize the browser to 700px to change vertical navbar to horizontal navbar</h2>
</div>
</body>
</html>
This will produce the following output −
On resizing the window to 700px −
Python - math.ulp(x) function - GeeksforGeeks

23 Aug, 2021
ULP stands for “Unit in the Last Place”. math.ulp() is introduced in python 3.9.0 version, it returns the value of the least significant bit of the float x. In numerical analysis and computer science, unit of least precision (ULP) or unit in the last place is the spacing between floating-point numbers.
Note:
If the argument is a NaN (not a number), output is NaN.
If input x is negative, output is ulp(-x).
If input x is positive infinity, output is inf.
If the input is zero, the smallest positive denormalized representable float is the output(smaller than the minimum positive normalized float, sys.float_info.min).
If input value x is the largest positive representable float, the value of the least significant bit of x is the output, such that the first float smaller than x is x – ulp(x).
Otherwise, if input value x is a positive finite number, the value of the least significant bit of x is the output, such that the first float bigger than x is x + ulp(x).
Syntax: math.ulp(x)
Parameter:
x: float whose ulp is returned
Return:
Return the value of the least significant bit of the float x.
Example: To show the working of math.ulp(x) method.
Python3
# python program to explain# math.ulp(x) for different values of ximport mathimport sys # when x is NaNx = float('nan')print(math.ulp(x)) # when x is positive infinityx = float('inf')print(math.ulp(x)) # when x is negative infinityprint(math.ulp(-x)) # when x = 0x = 0.0print(math.ulp(x)) # when x is maximum representable floatx = sys.float_info.maxprint(math.ulp(x)) # x is a positive finite numberx = 5print(math.ulp(x)) # when x is a negative numberx = -5print(math.ulp(x))
Output:
nan
inf
inf
5e-324
1.99584030953472e+292
8.881784197001252e-16
8.881784197001252e-16
rs1686740
Python math-library
Python math-library-functions
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | os.path.join() method
Python | Get unique values from a list
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
EmberJS - Template Condition If

The #if statement uses a boolean expression wherein, if the Boolean expression is true, then the block of code inside the if statement will be executed; if the Boolean expression is false, then the else block will be executed.
{{#if property-name}}
   //statement
{{else}}
   //statement
{{/if}}

The example given below shows the use of the if conditional helper in Ember.js. Create a template called application.hbs under app/templates/ with the following code −
{{#if check}}
   //true block of statement
   <h3> boolean value is {{check}}</h3>
   {{else}}
   //false block of statement
   <h3>boolean value is {{check}}</h3>
{{/if}}
Next, create the controller called application.js file which will be defined under app/controller/ with the following code −
import Ember from 'ember';

export default Ember.Controller.extend ({
   bool: true,
   check: function () {
      //returning the boolean value to the called function
      return this.bool;
   }.property('content.check'),
});
Run the ember server and you will receive the following output −
 Print
 Add Notes
 Bookmark this page
SVG <animateMotion> Element - GeeksforGeeks

31 Mar, 2022
SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas.
The SVG <animateMotion> element let define how an element moves along a motion path.
Syntax:
<animateMotion values="" dur="" repeatCount="" path="" />
Attributes:
keyPoints: This attribute indicates in the range [0, 1], how far is the object along the path for each keyTimes associated values.
path: This attribute defines the path of the motion.
rotate: This attribute defines a rotation applied to the element animated along a path, usually to make it point in the direction of the animation.
Animation Attributes: Attributes used to give animation effects, exp timing attributes, event attributes, and value attributes, etc.
Global Attributes: some global attributes used like core attributes and styling attributes, etc.
Example:
<!DOCTYPE html><html>  <body>    <svg width="1200" height="1200">        <circle cx="60" cy="60" r="5" fill="green">            <animateMotion dur="10s" repeatCount="indefinite"          path="M20, 60 C20,                -50 180, 150 180,                 60 C180-60 20,                 150 20, 60 z" />        </circle>    </svg></body>  </html>
Output:
Browsers Supported: The following browsers are supported by this SVG element:
Chrome
Edge
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-SVG
SVG-Element
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Tryit Editor v3.7

CSS Style Images
Tryit: Place text in top-left corner of an image
JSTL - Core <c:import> Tag

The <c:import> tag provides all functionalities of the <include> action but also allows for the inclusion of absolute URLs.
For example, using the import tag allows for the inclusion of content from a different Website or an FTP server.
The <c:import> tag has the following attributes −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>

<html>
   <head>
      <title><c:import> Tag Example</title>
   </head>

   <body>
      <c:import var = "data" url = "http://www.tutorialspoint.com"/>
      <c:out value = "${data}"/>
   </body>
</html>
The above example will fetch complete content from tutorialspoint.com/index.htm and will store in variable data which will be printed eventually. Try it yourself.

    108 Lectures 
     11 hours 

 Chaand Sheikh

    517 Lectures 
     57 hours 

 Chaand Sheikh

    41 Lectures 
     4.5 hours 

 Karthikeya T

    42 Lectures 
     5.5 hours 

 TELCOMA Global

    15 Lectures 
     3 hours 

 TELCOMA Global

    44 Lectures 
     15 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Pandas - Find the Difference between two Dataframes - GeeksforGeeks

16 Mar, 2021
In this article, we will discuss how to compare two DataFrames in pandas. First, let’s create two DataFrames.
Creating two dataframes
Python3
import pandas as pd    # first dataframedf1 = pd.DataFrame({    'Age': ['20', '14', '56', '28', '10'],    'Weight': [59, 29, 73, 56, 48]})display(df1)  # second dataframedf2 = pd.DataFrame({    'Age': ['16', '20', '24', '40', '22'],    'Weight': [55, 59, 73, 85, 56]})display(df2)
Output:
By using equals() function we can directly check if df1 is equal to df2. This function is used to determine if two dataframe objects in consideration are equal or not. Unlike dataframe.eq() method, the result of the operation is a scalar boolean value indicating if the dataframe objects are equal or not.
Syntax:
DataFrame.equals(df)
Example:
Python3
df1.equals(df2)
Output:
False
We can also check for a particular column also.
Example:
Python3
df2['Age'].equals(df1['Age'])
Output:
False
We can use either merge() function or concat() function. 
The merge() function serves as the entry point for all standard database join operations between DataFrame objects. Merge function is similar to SQL inner join, we find the common rows between two dataframes. 
The concat() function does all the heavy lifting of performing concatenation operations along with an axis od Pandas objects while performing optional set logic (union or intersection) of the indexes (if any) on the other axes.
Example 1: Using merge function
Python3
df = df1.merge(df2, how = 'inner' ,indicator=False)df
Output:
Example 2: Using concat function
We add the second dataframe(df2) below the first dataframe(df1) by using concat function. Then we groupby the new dataframe using columns and then we see which rows have a count greater than 1. These are the common rows. This is how we can use-
Python3
df = pd.concat([df1, df2])  df = df.reset_index(drop=True)  df_group = df.groupby(list(df.columns))  idx = [x[0] for x in df_group.groups.values() if len(x) > 1]df.reindex(idx)
Output:
We have seen that how we can get the common rows between two dataframes. Now for uncommon rows, we can use concat function with a parameter drop_duplicate. 
Example:
Python3
pd.concat([df1,df2]).drop_duplicates(keep=False)
Output:
Picked
Python pandas-dataFrame
Python-pandas
Technical Scripter 2020
Python
Technical Scripter
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
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
continue command in Linux with examples - GeeksforGeeks

15 May, 2019
continue is a command which is used to skip the current iteration in for, while and until loop. It takes one more parameter [N], if N is mentioned then it continues from the nth enclosing loop.
Syntax:
continue
or 
continue [N]
 
continue statement in for loop :
continue statement in while loop :
continue statement in until loop :
continue --help : Displays help information.
DrRoot_
linux-command
Linux-Shell-Commands
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
UDP Server-Client implementation in C
Tail command in Linux with examples
Cat command in Linux with examples
touch command in Linux with Examples
echo command in Linux with Examples
scp command in Linux with Examples
Compiling with g++
Granting Permissions to Roles in Cassandra - GeeksforGeeks

05 Jun, 2020
In this article, we are going to discuss how we can granting permission to roles in Cassandra. First, we will create a new role and show how it can access the database.
Creating a new role:In this step, we are going to create a new role such that user_access is a new role and want to access the database. To create a new role using the following cqlsh query.
cassandra@cqlsh> create role user_access
   ... with password = 'user_access'
   ... and LOGIN = true;

Output:
Now, If we can see “user_access” role access by using the following cqlsh query.
cassandra@cqlsh> list all permissions of 'user_access';

 role | resource | permissions
------+----------+-------------

(0 rows)
cassandra@cqlsh>

Right now, it can’t access the Existing keyspace ‘University’. let’s have a look.
cassandra@cqlsh> login user_access
Password:user_access
user_access@cqlsh> 
Output:
To resolve this error “Unauthorized: Error from server: code=2100 [Unauthorized] message=”User user_access has no SELECT permission on
Consider if we want only access “student” table on university keyspace then we can use the following cqlsh query.
cassandra@cqlsh> 
grant all permissions on university.student to user_access;
Only we can grant permission to access “university.student” table.
Output:
Now, used the following cqlsh query if we want to give the grant access to all tables on a university keyspace.
cassandra@cqlsh>
grant all permissions on keyspace university to user_access;
We can see all the permissions by using “list all permissions”.
Output:
If we want to give the grant access to the full database then used the following cqlsh query.
cassandra@cqlsh>
grant all permissions on all keyspaces to user_access;
Output:
Ashish_rana
Apache
DBMS
GBlog
Write From Home
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
Introduction of B-Tree
CTE in SQL
Difference between Clustered and Non-clustered index
Data Preprocessing in Data Mining
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
DSA Sheet by Love Babbar
Socket Programming in C/C++
GET and POST requests using Python
Must Do Coding Questions for Product Based Companies
Lodash _.omit() Method - GeeksforGeeks

07 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.omit() method is used to return a copy of the object that composed of the own and inherited enumerable property paths of the given object that are not omitted. It is the opposite of the _.pick() method.
Syntax:
_.omit( object, paths )
Parameters: This method accepts two parameters as mentioned above and described below:
object: This parameter holds the source object.
paths: This parameter holds the property paths to omit.
Return Value: This method returns the new object.
Example 1:
Javascript
// Requiring the lodash library  const _ = require("lodash");    // The source objectvar obj = {             Name: "GeeksforGeeks",             password: "gfg@1234",             username: "your_geeks"        }  // Using the _.omit() method console.log(_.omit(obj, ['password', 'username']));
Output:
{Name: "GeeksforGeeks"}
Example 2:  
Javascript
// Requiring the lodash library  const _ = require("lodash");    // The source objectvar obj = { 'x': 1, 'y': '2', 'z': 3 };  // Use the _.omit() method console.log(_.omit(obj, ['x', 'y']));
Output:
{'z': 3}
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
Python | Print all the common elements of two lists

21 Feb, 2022
Given two lists, print all the common elements of two lists.  
Examples:
Input : list1 = [1, 2, 3, 4, 5] 
        list2 = [5, 6, 7, 8, 9]
Output : {5}
Explanation: The common elements of 
both the lists are 3 and 4 

Input : list1 = [1, 2, 3, 4, 5] 
        list2 = [6, 7, 8, 9]
Output : No common elements 
Explanation: They do not have any 
elements in common in between them
 
 
Convert the lists to sets and then print set1&set2. set1&set2 returns the common elements set, where set1 is the list1 and set2 is the list2. Below is the Python3 implementation of the above approach:  
Python3
# Python program to find the common elements# in two listsdef common_member(a, b):    a_set = set(a)    b_set = set(b)     if (a_set & b_set):        print(a_set & b_set)    else:        print("No common elements")            a = [1, 2, 3, 4, 5]b = [5, 6, 7, 8, 9]common_member(a, b)  a = [1, 2, 3, 4, 5]b = [6, 7, 8, 9]common_member(a, b)
Output: 
{5}
No common elements
 
Convert the list to set by conversion. Use the intersection function to check if both sets have any elements in common. If they have many elements in common, then print the intersection of both sets. Below is the Python3 implementation of the above approach:  
Python3
# Python program to find common elements in# both sets using intersection function in# sets  # functiondef common_member(a, b):       a_set = set(a)    b_set = set(b)         # check length    if len(a_set.intersection(b_set)) > 0:        return(a_set.intersection(b_set))     else:        return("no common elements")       a = [1, 2, 3, 4, 5]b = [5, 6, 7, 8, 9]print(common_member(a, b))  a =[1, 2, 3, 4, 5]b =[6, 7, 8, 9]print(common_member(a, b))
Output: 
{5}
No common elements
Method 3 : Using for loop
def common_member(a, b):
    result = [i for i in a if i in b]
    return result

a = [1, 2, 3, 4, 5]
b = [5, 6, 7, 8, 9]

print("The common elements in the two lists are: ")
print(common_member(a, b))
Akanksha_Rai
bhairavimec
aryangarg248
smiti139
Python list-programs
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
How to know which radio button is selected using jQuery?

03 Aug, 2021
To check which radio button is selected in a form, we first get the desired input group with the type of input as an option and then the value of this selection can then be accessed by the val() method. This returns the name of the option that is currently selected.
The selector ‘input[name=option]:checked’ is used to select all input groups that have the option type of input in the specified form.
Syntax:
$('input[name=option]:checked', 'formName').val()
This is shown in the example below.Example:
<!DOCTYPE html><html><head>    <title>      How to know which radio button      is selected via jQuery?  </title></head>  <body>    <h1 style="color: green">      GeeksForGeeks  </h1>    <b>      How to know which radio       button is selected via jQuery?  </b>    <p>        <form id="myForm">            <label>                <input                        type="radio"                       name="option"                        value="free">              Free Membership            </label>            <label>                <input type="radio"                        name="option"                        value="premium">              Premium Membership            </label>        </form>            <p>      The value of the option selected is:       <span class="output"></span>  </p>    <button id="btn">      Check option button  </button>        <script src="https://code.jquery.com/jquery-2.2.4.min.js">  </script>        <script type="text/javascript">              // Check the radio button value.        $('#btn').on('click', function() {            output =               $('input[name=option]:checked',                '#myForm').val();                        document.querySelector(              '.output').textContent = output;        });    </script></body>  </html>
Output:
Check after clicking on the first option:
Check after clicking on the second option:
jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it’s philosophy of “Write less, do more”.You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples.
jQuery-Misc
Picked
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JQuery | Set the value of an input text field
How to change selected value of a drop-down list using jQuery?
Form validation using jQuery
How to add options to a select element using jQuery?
How to fetch data from JSON file and display in HTML table using jQuery ?
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 ?
Required arguments in Python

Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.
To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −
 Live Demo
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme()
When the above code is executed, it produces the following result −
Traceback (most recent call last):
File "test.py", line 11, in <module>
printme();
TypeError: printme() takes exactly 1 argument (0 given)
JavaScript - Date getFullYear() Method

Javascript date getFullYear() method returns the year of the specified date according to local time. The value returned by getFullYear() is an absolute number. For dates between the years 1000 and 9999, getFullYear() returns a four-digit number, for example, 2008.
Its syntax is as follows −
Date.getFullYear()

Returns the year of the specified date according to local time.
Try the following example.
<html>
   <head>
      <title>JavaScript getFullYear Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date("December 25, 1995 23:15:00");
         document.write("getFullYear() : " + dt.getFullYear() ); 
      </script>      
   </body>
</html>
getFullYear() : 1995 


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page