Python Tutorilas | Python Interview Questions | Session - 1 | by Durga Sir

preview_player
Показать описание
Python Tutorilas | Python Interview Questions Session - 1 | by Durga Sir
Рекомендации по теме
Комментарии
Автор

Q1: DIFFERENCE BETWEEN "IS" AND "==" OPERATOR IN PYTHON.

IS -->is operator is used to refering the two variables to the same object(Simplt it is identity operator.)
== --->is used to compare two objects(simply it is a Equality operator)

Q2: TERNARY OPERATOR or CONDITIONAL OPERATOR:

Way of writing simple if/else statements in a single line(with 3 orguments).
syntax: x= a if (condition) else b
if condition is True x=a otherwise x=b

Q3: DATA TYPES:
1)int
2)float
3)str(string)
4)complex
5)bool
6)list
7)tuple
8)dict
9)bytearray
10)bytes
11)range..etc

Q4: MUTABLE AND IMMUTABLE OBJECTS
Mutable:
*posible to do modifications once creation of an object.
ex: list, dictionary, set .
Note: if we try to do modifications we will get an "type error".
Immutable:
*Imposible to do modifications once creation of an object.
ex: Tuple, string, range.


Q5: IN PYTHON WHICH OBJECTS ARE MUTABLE AND WHICH OBJECTS ARE IMMUTABLE?

Mutable Objects:
1)list
2)dict
3)bytearray
4)set..etc

Immutable Objects:
1)int
2)float
3)str(string)
4)complex
5)bool
6)frozenset
7)bytes

Note:All fundamental data types are immutable.

Q6: **** DIFFERENCE BETWEEN LIST AND TUPLE: ****
List:
-->List is group of comma seperated values with in square brackets and square brackets are mandatory.
* List is an mutable object simly we can do any kind of modifications.
ex: l=[10, 20, 30]
--->List riquires more memory space.
--->List objects are won't reusable.
--->The performance of list is low, i.e, the operation of list object take more time.
---> Comprehension concept is applicable for List .
--->List objects are ""unhashable type"" . so we can't store in set and in dict as keys.

ex: s={10, 20, 30, [40, 50]}
print(S)
o/p: TypeError: unhashable type: 'list'.
ex: s={[40, 50]:"jaya"}
print(S)

o/p: TypeError: unhashable type: 'list'.
--> Unpacking is possible in list but packing is not possible .
Tuple:
--->Tuple is a group of comma seperated values with in a paranthesis and paranthesis are optional.
*Tuple is an immutable object and we can't do any kind of modifications once creation of objects.
ex: t=(10, 20, 30, 40, 50)
t=10, 20, 30, 40, 50
---->Tuple riquire less memory space.
---->Tuple objects are reusable
---> The performance of list is high, i.e, the operation of list object take less time.
---> Comprehension concept is not applicable in Tuple.
---> Tuple objects are """hashable type""" so we can store in set and in dict as keys.
ex:s=(10, 20, 30, [40, 50])
print(S)
o/p: (10, 20, 30, [40, 50])
--> both packing and unpacking is possible in tuple.


Example for memory storage in list and tuple:

import sys
l=[10, 20, 30, 40, 50]
t=(10, 20, 30, 40, 50)
print("The size of List is :", sys.getsizeof(l))
print("The size of Tuple is:", sys.getsizeof(t))

o/p: The size of List is : 88
The size of Tuple is: 80


Example for object reusable in List and python:

l1=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
l2=[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]

t1=(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
t2=(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
print(id(l1))
print(id(l2))
print(id(t1))
print(id(t2))

o/p:2869878896000 #list object take different object location.
2869834003584

2869874051648 #tuple object use same object location.
2869874051648




😀😀GIVE LEFT AND RIGHT TO INTERVIEWER IF ASK THESE QUESTIONS....

kvgraphics
Автор

Thank you sir for your love towards students for providing always best concepts through videos at the correct Time. I am waiting for the part-2

venkatathanooj
Автор

He is a legend. That's why we still(2021) watching his videos and joining ur institutes.

mareboinaravi
Автор

Sir you are amazing...
Your methods are directly going in my mind.

Anand_Acharya
Автор

>>> t2 = (10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
>>> t1 = (10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
>>> print(id(t1))
140411054539552
>>> print(id(t2))
140411054539984

for same values I am getting different id location....please explain(both python2 and 3 same output)

MrRahulmaitra
Автор

What is meant by left n right.. Sir said in all session 😀

artcraftsdecoration
Автор

Is there any blog. It's hard to hear your voice and slang

rakeshnagarajan
Автор

sir...plz upload django interviw question

dpbekkanti
Автор

sir, please provide the pdf of content and wonderful experience with learning for you

GauravSharma-blxq
Автор

Sir can we get those interview questions and answers pdf?? Plzz it's a request to share those

kota.
Автор

set data type is mutable and immutable.

IndoriTrader
Автор

Sir can you please share the file as well?

rahultiwari
Автор

sir, where is the pdf of that session

ajtech
Автор

I want pdf file for those questions and answers

MrMeghesh