Python Data Science Interview Questions
Python Interview Questions and Answers
1. What are the data types used in Python?
Image Source : Google image
- List, Set and Dictionary are mutable that means they can be modified during runtime.
- Number, String and Tuples are immutable that means they can not be modified during runtime.
2. Explain difference between List ,Tuples, Set and Dictionary.
3. What is Python Dictionary ?
- A built in data types and defined as unordered mapping of unique keys to values.
- Dictionary is indexed by Keys and Values can be any inbuilt data type or user defined class.
- Dictionary is mutable that means it can be modified during run time.
- Dictionary is created with curly braces {}. Ex: my_dict = {'name': 'kaushal', 'age': 50}
- Dictionary is index by square bracket []. Ex: my_dict['age'] = 50
4. What is different method and operation in python Dictionary ?
5. What are lambda function ?
- Lambda are anonymous function in python.
- They are very helpful when you need to define a function that's very short and consist only one expression.
- Instead of creating a small function with Name, argument, expression and return statement you can write everything in one liner code using Lambda function
- Example : (lambda x, y, x: (x+y) **z) (2,3,4) , Output: 625
5. Explain List comprehensions and how they are used in python ?
- List comprehensions is concise way to create the list.
- List are traditionally created within square bracket [].
- List comprehensions add expression within these bracket followed by a For clause and then IF clause ( when necessary)
- Evaluating the given expression with For Clause with IF clause produces a List.
- Example: a_list = [1,2,4,5,0,-2] , C_list = [x**2 for x in a_list if x>0] , Output: [1,4,16,25]
- Trick to Remember : For x in a_list:
- if ( x > 0) :
- print(x**2)
Image source: Google image
© Copyright 2022, crackdatascienceinterview.in. All rights reserved.