Python Interview
Python Interview
#premetive :
1)int 2)float 3)Bolen 4)str
#non primitive:-
1)list:[]
2)set:{1,2,3,4,5}
3)tuple:()
4)dictionary:{keys:values}
5)frozen set
2)type casting :
to convert one Datatype in another , int, eval
3)condition Statement :
1) if, else,
if condition:
print("condition is true")
else:
print("condition is false")
#list:
-list is coma seprate value in square bracket []
-mutable
-heterogenous [ 1,"a",1.1,"pra"]
-order
-allow dublicate values
2)back-word
from -1 to until finish from right to left
[-5 -4 -3 -2 -1] #index backword
[10,20,30,40,50]
[1 , 2 , 3 ,4 , 5] #index forword
I)indixing - only acces one element
//syntex
variablename[indexvalue]
l[0]=1
l[-1]=5
//syntex
variablename[start:stop]
l[1:4]
3) update
var[index]=newvalue
eg l[2]=66
4)remove
remove through value or number
var.remove(value)
l.remove(33)
5)pop
remove by the index number
var.pop(index)
l.pop(0)
6) delet
del var[index]
del l[2]
#iterate in list
n=[]
for i in n:
print(i)
#method of dictionary
1)key()
-it returns list of keys only
print(dictname.keys())
2)value()
-it returns list of values only
print(dictname.values())
3)items()
-it returns list of key value pairs
#set
union()
intersetion()- common element
difference()-it show
1)list :-
duplicate is not allow
mutable
order
[]
2)tuples
duplicate allow
immutable
order
()
1. What is Python?
Python is a high-level, interpreted programming language known for its clear syntax, readability, and
versatility. It supports multiple programming paradigms, including procedural, object-oriented, and
functional programming. Python is widely used for web development, data analysis, artificial
intelligence, machine learning, automation, and more.
2. Applications of Python
- Web Development : Frameworks like Django and Flask.
- Data Science : Libraries such as Pandas, NumPy, and Matplotlib for data manipulation and
visualization.
- Machine Learning : Libraries like TensorFlow and Scikit-Learn for building predictive models.
- Automation/Scripting : Automating repetitive tasks and writing scripts for system management.
- Game Development : Libraries like Pygame for creating games.
- Internet of Things (IoT) : Used in Raspberry Pi for various IoT applications.
9. What is Indexing?
Indexing refers to accessing elements in a sequence (like a list or string) using their position, which
starts from 0. For example:
my_list = [10, 20, 30]
print(my_list[1]) # Output: 20
# duplicate allow #duplicate is not allow #duplication not allow #duplication not
allow
# () not mandatory likely # [] mandatory with #{} define in curly #{} coma
we can defin as t coma separated value bracket with key and separated value in
=”string” value curly bracket
#less memory required #required more memory #more memory #required less
required memory
#fast speed #slow speed # slower speed # faster
#fix value or data #changeable value #The keys are fixed # fix value or data
once created
#it support unpacking #support only #Supports unpacking #Supports
and packing unpacking for keys, values, or unpacking for
both. elements.