Data Analysis Interview Questions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Choose the correct answer:

1. What is Python?
a. A low-level programming language
b. A high-level programming language
c. A markup language
d. A database management system

2. What is the purpose of indentation in Python?


a. It is optional and doesn't affect the code execution
b. It helps in defining the data types
c. It is used to specify the number of iterations in loops
d. It defines the blocks of code and improves code readability

3. What is the purpose of the "if" statement in Python?


a. It is used for looping over a sequence of elements
b. It is used to define a function in Python
c. It allows conditional execution of code
d. It is used to handle exceptions in Python

4. How do you take user input in Python?


a. By using the "get()" function
b. By using the "input()" function
c. By declaring a variable and assigning user input to it
d. User input is not supported in Python
5. What is the difference between "==" and "is" operators in Python?
a. Both operators are used for value comparison
b. "==" compares the values, while "is" compares the identities of
objects
c. "==" is used for mathematical operations, while "is" is used for logical
operations
d. "==" performs a deep comparison, while "is" performs a shallow
comparison

6. What is the purpose of a loop in Python?


a. To define a block of code
b. To handle errors and exceptions
c. To perform repetitive tasks
d. To import external modules

7. What is the purpose of the "elif" statement in Python?


a. It is a shorthand for "else if" and is used for multiple conditions
b. It is used to declare a new function in Python
c. It is used to define a loop in Python
d. It is a syntax error, and there is no such statement in Python

8. How do you define a function in Python?


a. By using the "function" keyword
b. By declaring a variable with a function name
c. By using the "def" keyword followed by the function name
d. Functions are not supported in Python
9. What is the purpose of a dictionary in Python?
a. To store a sequence of elements
b. To perform mathematical calculations
c. To handle errors and exceptions
d. To store key-value pairs

10. How do you find the length of a list in Python?


a. Using the "length()" function
b. By calling the "size()" method
c. By using the "count()" function
d. By using the "len()" function

11. What is the difference between a "while" loop and a "for" loop in
Python?
a. Both loops are used for the same purpose
b. "while" loops are used for iterating over a sequence, while "for"
loops are used for conditional execution
c. "while" loops are used when the number of iterations is unknown,
while "for" loops are used when it is known
d. "while" loops are used for infinite loops, while "for" loops are used
for finite loops

12. How do you import a module in Python?


a. By using the "include" keyword
b. By calling the "import()" function
c. By using the "require" statement
d. By using the "import" keyword
13. What is the purpose of the "range()" function in Python?
a. To generate a sequence of numbers
b. To perform mathematical calculations
c. To check if a value exists in a list
d. To remove duplicate elements from a list

14. What is the difference between the remove() and pop() methods in
Python?
a. Both methods are used to delete an item from a list, and there is no
difference between them.
b. remove() removes the last item from a list, while pop() removes an
item at a specific index.
c. remove() returns the removed item, while pop() does not return
anything.
d. pop() removes an item based on its index and returns the removed
item, while remove() removes an item based on its value and does
not return anything

15. What is the purpose of the "try-except" block in Python?


a. To define a conditional statement
b. To handle errors and exceptions
c. To perform file operations
d. To define a loop in Python

16.How do you convert an integer to a string in Python?


a. By using the strToInt() function
b. By calling the parse() method
c. By using the toInteger() function
d. By using the str() function
What is the key difference between Lists and Tuples?
What is the key difference between Lists and Sets?
The key difference between the Lists and Tuples is that while lists are mutable,
tuples on the other hand are immutable objects. On other hand, Lists can contain
duplicate elements but Sets do not allow duplicate elements. If you try to add the
same value multiple times, it will only be stored once.

Write a Python program to swap the values of two


variables without using a temporary variable.
(Hint use multiple assignment)

Catch errors in the following code blocks.


1- Data conversion

2- Off-by-One Error:
3- Incorrect Variable Scoping:

Create a function that takes a list of numbers and


returns the sum of all the even numbers in the list.
(Without using for loop, hint: list comprehension)
Write a function that calculates the mean, and median
of given list, and write their formula.

You might also like