Tricky Interview Questions (Python)
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
The Data Monk services
We are well known for our interview books and have 70+ e-book across Amazon and The Data Monk e-shop page . Following are best-seller combo packs and services that we are providing as of now
- YouTube channel covering all the interview-related important topics in SQL, Python, MS Excel, Machine Learning Algorithm, Statistics, and Direct Interview Questions
Link – The Data Monk Youtube Channel - Website – ~2000 completed solved Interview questions in SQL, Python, ML, and Case Study
Link – The Data Monk website - E-book shop – We have 70+ e-books available on our website and 3 bundles covering 2000+ solved interview questions. Do check it out
Link – The Data E-shop Page - Instagram Page – It covers only Most asked Questions and concepts (100+ posts). We have 100+ most asked interview topics explained in simple terms
Link – The Data Monk Instagram page - Mock Interviews/Career Guidance/Mentorship/Resume Making
Book a slot on Top Mate
The Data Monk e-books
We know that each domain requires a different type of preparation, so we have divided our books in the same way:
1. 2200 Interview Questions to become Full Stack Analytics Professional – 2200 Most Asked Interview Questions
2.Data Scientist and Machine Learning Engineer -> 23 e-books covering all the ML Algorithms Interview Questions
3. 30 Days Analytics Course – Most Asked Interview Questions from 30 crucial topics
You can check out all the other e-books on our e-shop page – Do not miss it
For any information related to courses or e-books, please send an email to [email protected]
Comment ( 1 )
Hey,
You might wanna take another look at your palindrome code 🙂