Python for Data Science PART 2
Python for Data Science PART 2
Question 1:
What is Python?
A) A type of snake
AM
B) A high-level programming language
C) A mathematical formula
D) A computer hardware
AY
Accepted Answer: B) A high-level programming language
Question 2:
SW
Which of the following libraries is commonly used for data manipulation and
analysis in Python?
A) TensorFlow
B) PyTorch
C) NumPy
D) Django
Y
M
Question 3:
What does the pandas library provide in Python for data science?
A) Data visualization tools
B) Machine learning algorithms
C) Data structures and data analysis tools
D) Web development capabilities
Page 1 MY SWAYAM
Python for Data Science IIT Kharagpur
Question 4:
Which of the following data types is not supported by Python?
A) Integer
B) Float
C) Complex
D) Character
AM
Question 5:
What does the 'print' function do in Python?
A) Reads input from the user
AY
B) Displays output to the console
C) Performs mathematical operations
D) Declares a variable
SW
Accepted Answer: B) Displays output to the console
Question 6:
What is the correct way to create a list in Python?
Y
A) list = {1, 2, 3}
B) list = [1, 2, 3]
M
C) list = (1, 2, 3)
D) list = "1, 2, 3"
@
Page 2 MY SWAYAM
Python for Data Science IIT Kharagpur
Question 7:
What is the purpose of the 'for' loop in Python?
A) To define a function
B) To iterate over a sequence (list, tuple, string, etc.)
C) To make a decision
D) To perform exception handling
AM
Question 8:
Which operator is used for exponentiation in Python?
A) ^
B)
C) /
D) %
AY
SW
Accepted Answer: B) (Double Asterisk)
Question 9:
What is the output of the following code snippet?
Y
```python
print("Hello, " + "World!")
M
```
A) Hello, World!
@
B) Hello, + World!
C) Hello, , World!
D) Hello World!
Page 3 MY SWAYAM
Python for Data Science IIT Kharagpur
Question 10:
Which of the following is a valid way to comment in Python?
A) // This is a comment
B) /* This is a comment */
C) # This is a comment
D) -- This is a comment
AM
Question 11:
What does the 'len()' function do in Python?
A) Returns the largest element in a list
AY
B) Returns the length of a sequence (list, tuple, string, etc.)
C) Checks if a variable is defined
D) Converts a string to lowercase
SW
Accepted Answer: B) Returns the length of a sequence (list, tuple, string, etc.)
Question 12:
What is the purpose of the 'if' statement in Python?
Y
A) To define a loop
B) To perform a specific action when a condition is true
M
Page 4 MY SWAYAM
Python for Data Science IIT Kharagpur
Question 13:
What is the correct way to define a function in Python?
A) function myFunction():
B) def myFunction():
C) define myFunction():
D) func myFunction():
AM
Question 14:
Which library is commonly used for data visualization in Python?
A) NumPy
B) Matplotlib
C) Pandas
D) Scikit-Learn
AY
SW
Accepted Answer: B) Matplotlib
Question 15:
What is the purpose of the 'import' keyword in Python?
Y
Page 5 MY SWAYAM
Python for Data Science IIT Kharagpur
Question 16:
What does the 'strip()' method do for strings in Python?
A) Removes whitespace characters from the beginning and end of a string
B) Converts the string to uppercase
C) Reverses the string
D) Counts the number of occurrences of a substring
AM
Question 17:
What does the 'append()' method do for lists in Python?
A) Sorts the list in ascending order
AY
B) Adds an element to the end of the list
C) Removes the last element from the list
D) Reverses the order of elements in the list
SW
Subscribe for
M
PART 3 AND 4
@
MY SWAYAM
Page 6 MY SWAYAM
Python for Data Science IIT Kharagpur
HAPPY LEARNING
THANK YOU.
AM
AY
SW
Y
M
@
Page 7 MY SWAYAM