Tag: vs
C++ : How to get element by index in vector | at() vs operator []
In this article we will discuss different techniques to get an element from vector by index or position. In vector elements are indexed from 0 to size() – 1. To access any element in vector by index vector provides two member functions i.e. at() operator[] Let’s discuss them in detail, Advertisements Access an element in …
C++ : How to get element by index in vector | at() vs operator []Read More
Python : How to copy a dictionary | Shallow Copy vs Deep Copy
In this article we will discuss how to create a shallow and deep copy of dictionary in Python. Create Shallow copy of Dictionary using dict.copy() Python’s dictionary provides a member function copy() i.e. Advertisements dict.copy() It returns a shallow copy of the existing dictionary. What is a shallow copy ? Frequently Asked: Convert dictionary values …
Python : How to copy a dictionary | Shallow Copy vs Deep CopyRead More
Python : How to Compare Strings ? | Ignore case | regex | is vs == operator
In this article we will discuss different ways to compare strings in python like, using == operator (with or without ignoring case) or using is operator or using regex. Python provides various operators to compare strings i.e. +, !=, <, >, <=, >=. When used for comparison these operators return Boolean True or False value. …
Python : How to Compare Strings ? | Ignore case | regex | is vs == operatorRead More
Python : Iterators vs Generators
In this article we will discuss the differences between Iterators and Generators in Python. Iterators and Generators both serves similar purpose i.e. both provides the provision to iterate over a collection of elements one by one. But still both are different. Let’s discuss how they are different Advertisements Ease of implementation Making your class Iterable …
Python : List Comprehension vs Generator expression explained with examples
In this article we will discuss the differences between list comprehensions and Generator expressions. Need of Generator Expression ? Sometimes we want to operate on selected elements only and that too one by one. For such scenarios we should avoid keeping unnecessary elements in memory by creating lists or set or tuple etc. Advertisements Let’s …
Python : List Comprehension vs Generator expression explained with examplesRead More
Python Set: add() vs update()
In this article we will discuss the main differences between add() and update() functions of Set in python. In python, set class provides two different functions to add or append elements in the set. Before going into the differences, first let’s have a basic overview about them, Advertisements set.add() Function: set.add(element) It accepts an element …
Python Numpy: flatten() vs ravel()
In this article we will discuss main differences between numpy.ravel() and ndarray.flatten() functions. Objective of both the numpy.ravel() and ndarray.flatten() functions is the same i.e. flatten a numpy array of any shape. But there are some basic differences in both of them. Before going into detail about differences, let’s have a basic overview of both …
Python Set: remove() vs discard() vs pop()
In this article we will learn about three different functions to remove elements from a set in python i.e. remove(), discard() and pop(). set.remove() In python, set class provides a member function remove() to delete an element from the set i.e. Advertisements set.remove(element) It removes the given element from the set. If the element is …
How to compare strings in Python? (‘is’ vs ‘==’)
In this tutorial, you will learn how to compare strings in Python. Table Of Contents Compare strings using ‘==’ operator Compare strings using ‘!=’ operator Compare strings using ‘>’ operator Compare strings using ‘>=’ operator Compare strings using ‘<‘ operator Compare strings using ‘<=’ operator Compare strings using is operator Difference between is & ‘==’ …
How to compare strings in Python? (‘is’ vs ‘==’)Read More
Python List – append() vs. extend()
In this Python tutorial, we will discuss the differences between append() and extend() methods of list. Table Of Contents append() method of List in Python extend() method of List in Python Difference between append() and extend() Similarities between append() and extend() Summary append() method of List in Python The append() method of class list adds …