Python Interview Questions
Python Interview Questions
Python Interview Questions
DAY:1
1.what is python?
Python is an interpreted, object oriented, high-level programming
language with dynamic semantics. It is a High –level programming
language.
9.What are the difference between input function and raw –input
function in python?
10. How you can convert given data into string type?
By using the str () function we can convert data into string function.
b=1.2
print(type(a)) #int
print(type(b)) #float.
11. How you can convert given string type data into integer type?
To convert a string to integer in python, use the int () function.
The initial string and the optional base to represent the data. Use the
syntax print(int(“STR”))
a=int (a)
print(type(a)) #int
12.How you can convert given integer type into float type?
By using float () function we can convert integers to floats. To use
this function we have to add integers Inside.
Ex: a=input (“enter the value for a:”)
Print(a)
a=float(a)
print(a)
13.How you can convert given data into complex number type?
By using complex () function we can convert data into complex type.
Take two separate numbers and convert them into complex.
Ex: a= 5+3j
print(type(a))
b= complex (10)
print(type(b))
print(b).
14.How we can store binary numbers in python?
In python we can use bin () function to convert or store binary values
in python. And the Int () function used as second argument.
20.Howwe can convert integer data type into binary data type?
By using bin () function we convert integer to binary data type in
python. And also format function.
EX: binary= bin (16)
Print(binary)
23. How you can convert given float number into binary type or not?
To convert a floating point decimal number into binary, first we
have to convert the integer part into binary form and then fractional
part into binary form and finally combine both results to get the final
answer.
1= (1)2
(1.0011…1)2
24.How you check the type of data the variable has in python?
To check the data type variable in python, use type () method. The
type () is a built-in method that returns the class type of the
argument object. And passed it as a parameter. You place the
variable inside a type () function, and python returns the data type.
DAY-3
Frozen set :
➢ Frozen set is a set which is used to make the set . and it is
not going to change again once we create the set.
➢ Frozen set cannot allow duplicate values.
➢ Frozen set can be empty.
78.How you can find two sets are disjoint or not?
We can find if two sets are disjoint or not by checking if they have
no common element in the set.
79.How to find the given set is super set to other set or not?
We can find the given set is super set or not by using the
Issuperset () method.
80.How to check the given set is subset to other set or not?
We can find the given set is subset or not by using the
Issubset () method.
81.What is the operator we used to check given set is super set or
not?
By using the assignment operator (=) we can able to check the given
set is super set or not.
82.What is the operator we used to check given set is subset or
not?
By using the assignment operator (=) we can able to check the given
set is sub set or not.
83.How to compare two sets are equal or not?
We can compare two sets are equal or not by using the if condition.
Ex : s1={1,2,3,4}
S2={5,6,7,8}
S3={5,6,7,8}
If (s2==s3):
Print (“two sets are equal”:)
84.What is the operator to compare two sets in python?
By using the assignment operator (==) we can able to compare two
sets in python.
85.How to find the difference between given two sets?
We can find the difference between given two sets by the following
two methods..
1. Operator (-)
2. Using difference () method
86.What is the symbol is used to find the difference of two sets?
By using the minus (-) symbol we can able to find the difference of
two sets.
87.What is the method is used to find the difference of two sets?
By using the difference () method returns the set of difference of
two sets.
88.How to find the union of two sets?
By using the union () method we can able to find the union of two
sets.
New _set= set
89.How to find the intersection of two sets?
We can find the intersection of two sets by two ways.
1. using & operator
2. Using intersection () method.
Day-4
92.What is the function / method used to find the given set is subset
or not?
➢ The function is used to subset.
➢ The issubset () method returns true if all elements of a set are
present in another set and it passed as an argument.
DAY-5
126.What are the various methods to add data into the dictionary?
For adding data into dictionary it cannot support add, append ,insert
methods.
So, to insert new elements in dictionary insert a new index key into
the dictionary. By this method we can add data into the dictionaries.
131.What are the various methods we have to remove the data from
dictionary?
There two methods and those are pop () method and del () method.
Pop () method can be used to delete a key and a value associated
with it which means key-pair value from dictionary.
135.What are the major difference between set and dictionary? Write
down the common methods and various methods of both?
Dictionaries and sets are identical. Except that set do not actually
contain values where as dictionary contains it also contains keys.
150.How to find the length of the string for the given range?
By using len () function we are able to find the length of the string
and for range we use (range(len)) function.
DAY-6
152.What is mean by class?
Class is building block of oops which is going to have both data and
as well as properties.
175.What is mean by child class, and write other names for it?
Child class is a class that inherits from another class,also called as
derived class.
DAY-7
214.What are the differences between logical & and bitwise & in
python?
The major difference between them are
➢ The logical AND works on Boolean expressions, and returns
Boolean values only.
➢ The bitwise AND operator works on integer, short int, long,
unsigned int type data , and also returns that type of data .
215.What are the supported literals by python language?
➢ String literals
➢ Numeric literals
➢ Boolean literals
➢ Literal collections
➢ Special literals