The reason why I put interview questions as the title of a lot of posts is
1. It makes you click on the post
2. It makes you feel that these are very important questions and you can nail an interview with it
3. These are actual interview questions asked in companies like Myntra, Flipkart, BookMyShow, WNS, Sapient, etc.
4. You have to practice to become perfect. You can practice here or anywhere else. But make sure you know all the questions given below.
Toh
Let’s start with the questions ๐
1. Which data type is mutable and ordered in Python?
List
2. Can a dictionary contain another dictionary?
Yes, a dictionary can contain another dictionary. In fact, this is the main advantage of using dictionary data type.
3. When to use
A list keeps order,
set requires items to be hashable,
4. WAP where you first create an empty list and then add the elements.
basic_list = []
basic_list.append(โAlphaโ)
basic_list.append(โBetaโ)
basic_list.append(โGammaโ)
5. What does this mean: *args, **
We use *args when we arenโt sure how many arguments are going to be passed to a function, or if we want to pass a stored list or tuple of arguments to a function. **
6. What are negative indexes and why are they used?
The sequences in Python are indexed and it consists of the positive as well as negative numbers. The numbers that are positive uses โ0โ that
7. Randomly shuffle the content of a list
8. Take a random sample of 20 elements and put it in a list
9. Take a list and sort it
10. Explain split() and sub() function from the “re” package
split() โ uses a regex pattern to โsplitโ a given string into a
sub() โ finds all substrings where the regex pattern matches and then replace them with a different string
11. What are the supported data types in Python?
The most important data types include the following:
1. Number
2. String
3. List
4.Tuple
5. Dictionary
6. Set
12. What is the function to reverse a list?
list.reverse()
13. How to remove the last object from the list?
list.pop(obj=list[-1])
Removes and returns last object or obj from
14. What is a dictionary?
A dictionary is one of the built-in data types in Python. It defines an unordered mapping of unique keys to values. Dictionaries are indexed by keys, and the values can be any valid Python data type (even a user-defined class). Notably, dictionaries are mutable, which means they can be modified. A dictionary is created with curly braces and indexed using the square bracket notation.
15. Python is an
OOP is the programming paradigm based on classes and instances of those classes called objects. The features of OOP
16. What is the difference between append() and extend() method?
Both append() and extend() methods are the methods of
append(element) โ adds the given element at the end of the list which has called this method.
extend(another-list) โ adds the elements of
17. Write a program to check if a string is a palindrome?
Below is the code, write it down yourself ๐
18. Take a random list and plot a histogram with 3 bins.
19. What is the
range () returns a list whereas
20. Guess the output of the following code
x = “Fox ate the pizza”
print(x[:7])
You can find Python interview questions on many websites, we will keep on updating this list. Time for some marketing, if you want to get some more interview questions on Python, then click below:-
100 Python Questions to crack Data Science/Analyst Interview
Keep practicing ๐
XtraMous
Hey,
You might wanna take another look at your palindrome code ๐