Python Series- is Vs == Indepth Explanation- Boolean Evaluation

Krish Naik · Intermediate ·🏗️ Systems Design & Architecture ·5y ago

Key Takeaways

Explains Python's IS vs == operators in depth

Full Transcript

hello all my name is krishnan welcome to my youtube channel so guys today in this particular video we are going to see the difference between is keyword and double equal to so here we are basically going to see two things one is is versus double equal to now remember there's a lot of confusion with uh people also and yesterday also i was taking one of the session where people had a lot of doubts with respect to ease and double equal to so let's try to understand this and let's try to take some of the examples so first of all i am going to make a list where i have elements like probably crash uh i have three names suppose so i say krish and then i say crush one right if i say krish to so i have these all elements right and similarly what i do this is my list one okay and then i'm just going to copy this entirely and then i'm going to basically paste it over here now when i have this and let me just rename this into list2 now in this video now what i will be doing is that now see this if i use list one double equal to list two right this is a simple code over here where i'm just writing list one is equal to list two this is nothing but double equal to basically means that we are going to compare whether these two lists are equal or not just understand this equal with the with respect to the elements that are present inside this if i try to execute this definitely it will be coming as true okay so here i'm actually checking whether list one and list two are equal or not and obviously just by seeing it all the elements inside this list are different if i try to change this into something else and if i try to again execute it it is basically giving me false so let me make it back okay now this is with respect to double equal to operation that basically means whatever things i'm actually trying to compare you know like if i'm if i made a string like crash and probably my b string is again crash okay that basically means that if i try to compare any of this kind of variables which is having probably the same value inside it but remember all this will be having a different different memory location so when i'm doing this kind of comparison a double equal to b i'll definitely be getting as true before going ahead with respect to this particular video this video has been sponsored by an academy so guys if you are in the final year of a graduation or planning to prepare for gate or eac examination then you are at the right place an academy is back with its cs or it batch evolve 2022 these batches are starting from 18 jan 2021 don't miss a single class take all the live session and prepare with the best unacademy educators including ravindra babu rahula if you don't know about ravindra babu ravula guys he's an amazing teacher and you can also see his youtube videos with respect to gate you will be getting 800 plus hours of total lectures covering the full gate or esc course along with solving all your doubts do make sure that you try to use my code that is kn06 to get an additional 10 percent discount you can also take the demo class to get a full clarity about the educator that is ravindra babu ravula and subscribe to this particular platform all the information regarding this will be given in the description of this particular video now coming to the is keyword okay so let's see if i try to use the same list1 and list2 and i'll try to use the is keyword so if i use list 1 is list 2 if i try to execute over here you can see that i'm getting false now why probably i'm getting a false will try to understand but before that let me take one more example over here okay now instead of just writing like this i'll just copy this and now i will just paste it over here and let me do one thing instead of assigning this particular value again remember whenever we are assigning some values over here this will be taking a different memory location it will get saved over here this will be stored in different memory location now instead of doing this i'll remove this and i'll assign it to list one now when i am doing this now just see what will be the output over here list1 is list2 so when i execute this this will be true okay i'll tell you why it is true let me just reverse this thing again instead of making list 1 let me write it at list2 is list1 okay now here also you can see this is true now remember one thing guys whenever we are using the east keyword okay is keyword is just not about comparison of the elements instead it will try to see first of all in list one we have saved some kind of elements over here you can see some of the elements items are there and this items probably may be like allocated in a different memory location in some memory location and that same reference is basically provided to the list too when we do like this and at that time when we try to compare with respect to the east keyword then it basically gives me a true value again understand guys here different objects are not getting created only one object has been created in the memory and that is being referred by both the variables that is the most important thing to understand with respect to double equal to this does not happen like that in double equal to you'll be having two different memory location and you'll try to compare whatever values basically stored within them and then it will try to say whether it is true or false and this is very very important because probably in the next video i'll be also uploading about numpy dot array versus numpy dot azure so tell me the difference between this anyhow i'll be trying to create a video in my next next uh video in python series but just understand what is the basic difference between np dot array versus np dot as array let me talk one more concept which is called as mutability now guys remember if i make this changes like this and if i assign list one to list two now suppose my list two of zero is basically krish if i try to change it to something like krish two suppose okay now if i go and see my list two and here you'll be able to see krishna krishna and krishna okay but what about list one well whether the list one will also get updated then we can definitely see over here the list one is also getting updated with respect to the elements so wherever mutability is possible see in this particular case something is stored in one memory location two variables are referring that if one variable a child should change that particular value it will also get reflected to the other things so that is the reason why we use shallow copy and deep copy i'll also be creating a video on shallow copy and deep copy and we'll try to see how we can prevent that in order to just prevent it what we have to do is that when we are assigning like this we just have to use dot copy operation to make it as a deep copy deep copy basically means it will create a different memory location even for list2 so i hope you understood this particular video this is the basic difference between is versus double equal to uh now you probably you may have understood when should we use double equal to and when we have to use is when does it give true or when does it get false right this is just like a boolean operation so this is all about this particular video guys i'll see you all in the next video have a great day thank you and all bye

Original Description

github: https://github.com/krishnaik06/Machine-Learning-in-90-days/blob/master/Section%201-%20Python%20Crash%20Course/Python%20IS%20Keyword.ipynb Evolve for GATE 2022 | CS/IT: https://bit.ly/3svw5Cm Demo Class: CS/IT: https://unacademy.com/class/last-30-days-preparation-strategy-for-gate-2021-csit/R5NOYSA0 Use Code: KN06 ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for a few months and I love it! https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=krishnaik&utm_content=description-only All Playlist In My channel Interview Playlist: https://www.youtube.com/playlist?list=PLZoTAELRMXVM0zN0cgJrfT6TK2ypCpQdY Complete DL Playlist: https://www.youtube.com/watch?v=9jA0KjS7V_c&list=PLZoTAELRMXVPGU70ZGsckrMdr0FteeRUi Julia Playlist: https://www.youtube.com/watch?v=Bxp1YFA6M4s&list=PLZoTAELRMXVPJwtjTo2Y6LkuuYK0FT4Q- Complete ML Playlist :https://www.youtube.com/playlist?list=PLZoTAELRMXVPBTrWtJkn3wWQxZkmTXGwe Complete NLP Playlist:https://www.youtube.com/playlist?list=PLZoTAELRMXVMdJ5sqbCK2LiM0HhQVWNzm Docker End To End Implementation: https://www.youtube.com/playlist?list=PLZoTAELRMXVNKtpy0U_Mx9N26w8n0hIbs Live stream Playlist: https://www.youtube.com/playlist?list=PLZoTAELRMXVNxYFq_9MuiUdn2YnlFqmMK Machine Learning Pipelines: https://www.youtube.com/playlist?list=PLZoTAELRMXVNKtpy0U_Mx9N26w8n0hIbs Pytorch Playlist: https://www.youtube.com/playlist?list=PLZoTAELRMXVNxYFq_9MuiUdn2YnlFqmMK Feature Engineering :https://www.youtube.com/playlist?list=PLZoTAELRMXVPwYGE2PXD3x0bfKnR0cJjN Live Projects :https://www.youtube.com/playlist?list=PLZoTAELRMXVOFnfSwkB_uyr4FT-327noK Kaggle competition :https://www.youtube.com/playlist?list=PLZoTAELRMXVPiKOxbwaniXjHJ02bdkLWy Mongodb with Python :https://www.youtube.com/playlist?list=PLZoTAELRMXVN_8zzsevm1bm6G-
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 0 of 60

← Previous Next →
1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related Reads

📰
Why I’m Thinking of Switching My Portfolio to Astro.js ..
Learn why Astro.js is a promising alternative for building portfolios and how to get started with it
Dev.to · Kavin HBN
📰
Angular : do we need CSP_NONCE for both Frontend & Backend toghether ?
Learn why CSP_NONCE requires both frontend and backend cooperation in Angular applications
Medium · Programming
📰
You Have a System Design Interview in a Week and You Know You’re Not Ready.
Learn to prepare for a system design interview in a week with actionable steps and resources
Medium · DevOps
📰
I Built a Free PDF Tool That Runs 100% in Your Browser (No Uploads, No Servers)
Learn how to build a free PDF tool that runs entirely in your browser using React, TypeScript, and WebAssembly, ensuring your files never leave your device.
Dev.to · pirate_haizei
Up next
Supply Chain Management Systems Explained | What Is SCM?
The Learning Studio
Watch →