Introduction to Programming for Data Science Practice Exam Quiz

Get solved practice exam answers for your midterm and final examinations

Introduction to Programming for Data Science Practice Exam Quiz

 

  1. What is the primary purpose of a programming language like Python in data science?
    A) To write operating system code
    B) To interact with databases
    C) To process, analyze, and visualize data
    D) To create web applications

 

  1. Which Python library is commonly used for data manipulation and analysis?
    A) Matplotlib
    B) Pandas
    C) Flask
    D) NumPy

 

  1. What is a variable in programming?
    A) A function
    B) A fixed value
    C) A container for storing data values
    D) A library for handling errors

 

  1. Which of the following is a valid Python data type?
    A) Integer
    B) List
    C) String
    D) All of the above

 

  1. In Python, how do you print a string to the console?
    A) console.log(“Hello”)
    B) print(“Hello”)
    C) echo(“Hello”)
    D) print.hello()

 

  1. Which function is used to calculate the mean of a dataset in Python’s NumPy library?
    A) mean()
    B) avg()
    C) np.mean()
    D) np.average()

 

  1. Which Python library is used for data visualization?
    A) Pandas
    B) Matplotlib
    C) TensorFlow
    D) Scikit-learn

 

  1. What is the output of the following Python code: print(3 + 2 * 4)?
    A) 14
    B) 20
    C) 11
    D) 10

 

  1. Which of the following data structures can be used to store multiple items in a single variable in Python?
    A) List
    B) Tuple
    C) Dictionary
    D) All of the above

 

  1. What is a tuple in Python?
    A) An ordered collection of elements that can be modified
    B) An ordered collection of elements that cannot be modified
    C) An unordered collection of elements
    D) A type of function

 

  1. Which of the following statements is true about loops in Python?
    A) The for loop is used to iterate over sequences like lists and tuples.
    B) The while loop only runs for a fixed number of iterations.
    C) The for loop only works for lists.
    D) A while loop runs forever unless explicitly broken.

 

  1. Which of the following is used to handle exceptions in Python?
    A) try and except
    B) if and else
    C) switch and case
    D) break and continue

 

  1. What does the len() function do in Python?
    A) Returns the type of an object
    B) Returns the length of an object
    C) Returns the first element of an object
    D) Returns the last element of an object

 

  1. What is the result of 5 / 2 in Python 3?
    A) 2
    B) 2.0
    C) 2.5
    D) Error

 

  1. How can you define a function in Python?
    A) def my_function()
    B) function my_function()
    C) func my_function()
    D) define my_function()

 

  1. What is the use of the pandas.read_csv() function?
    A) To export data to a CSV file
    B) To read data from a CSV file
    C) To create a CSV file from a DataFrame
    D) To sort a DataFrame

 

  1. In Python, what is the purpose of the break statement?
    A) To stop the program execution
    B) To exit a loop prematurely
    C) To continue to the next iteration of a loop
    D) To define a function

 

**18. What does the following code do? dataframe.head()
A) Displays the first few rows of a DataFrame
B) Displays the last few rows of a DataFrame
C) Sorts the DataFrame
D) Drops missing values from the DataFrame

 

  1. What is the difference between == and is in Python?
    A) == checks for identity, and is checks for equality
    B) == checks for equality, and is checks for identity
    C) They are the same
    D) is checks if two variables are of the same type

 

  1. What is the output of list(range(3)) in Python?
    A) [0, 1, 2, 3]
    B) [0, 1, 2]
    C) range(0, 3)
    D) []

 

  1. Which Python library is used for scientific computing?
    A) Pandas
    B) NumPy
    C) Matplotlib
    D) Seaborn

 

  1. Which of the following can be used to visualize data distributions?
    A) Histogram
    B) Bar chart
    C) Pie chart
    D) All of the above

 

  1. What is the main use of the groupby() function in Pandas?
    A) To merge multiple DataFrames
    B) To sort data
    C) To perform aggregate functions on data subsets
    D) To handle missing data

 

  1. Which of the following is a valid way to import NumPy in Python?
    A) import numpy as np
    B) import numpy
    C) from numpy import *
    D) All of the above

 

  1. What is the purpose of the apply() function in Pandas?
    A) To apply a function along an axis of a DataFrame
    B) To apply a sorting algorithm
    C) To visualize data
    D) To handle missing values

 

  1. What is the matplotlib.pyplot library used for?
    A) Data analysis
    B) Data visualization
    C) Scientific computing
    D) Machine learning

 

  1. What does the term “data wrangling” refer to?
    A) Analyzing large datasets
    B) Cleaning and organizing data
    C) Building machine learning models
    D) Visualizing data

 

  1. In Python, which keyword is used to define a class?
    A) function
    B) object
    C) class
    D) def

 

  1. What does the map() function do in Python?
    A) Maps a sequence to a new sequence using a function
    B) Maps a variable to a value
    C) Maps one dictionary to another
    D) Maps a file to memory

 

  1. What does the sort_values() function do in Pandas?
    A) Sorts values in a DataFrame or Series
    B) Sorts columns alphabetically
    C) Sorts the data by index
    D) Sorts the data based on missing values

 

 

  1. What does the iloc[] function in Pandas do?
    A) Selects rows and columns by label
    B) Selects rows and columns by index
    C) Selects columns by name
    D) Selects rows by data type

 

  1. Which Python function is used to convert a string to lowercase?
    A) lowercase()
    B) string.lower()
    C) toLower()
    D) str.to_lower()

 

  1. In which case would you use the concat() function in Pandas?
    A) To join two DataFrames by index or columns
    B) To sort a DataFrame
    C) To fill missing values
    D) To group a DataFrame

 

**34. What does the following code do? df[‘Age’].mean()
A) Calculates the sum of the ‘Age’ column
B) Calculates the average value of the ‘Age’ column
C) Filters the DataFrame by ‘Age’
D) Returns the first value in the ‘Age’ column

 

  1. Which method is used to remove missing values in a DataFrame?
    A) dropna()
    B) fillna()
    C) remove()
    D) clear()

 

  1. How can you get the number of rows and columns in a DataFrame?
    A) df.size()
    B) df.shape()
    C) df.dim()
    D) df.info()

 

  1. Which of the following statements about Python lists is true?
    A) Lists are immutable
    B) Lists can only store numbers
    C) Lists are ordered collections of items
    D) Lists cannot store mixed data types

 

  1. Which Python function can be used to import data from an Excel file?
    A) pd.read_csv()
    B) pd.read_excel()
    C) pd.import_excel()
    D) pd.load_excel()

 

  1. What is a DataFrame in Pandas?
    A) A list of strings
    B) A two-dimensional array-like data structure
    C) A one-dimensional array-like data structure
    D) A dictionary of lists

 

  1. Which of the following is used to combine DataFrames vertically in Pandas?
    A) concat()
    B) merge()
    C) append()
    D) stack()

 

  1. What is the purpose of the lambda function in Python?
    A) To create a function without a name
    B) To define a class
    C) To store values in variables
    D) To handle exceptions

 

  1. What is the use of the split() method in Python?
    A) To split a list into individual items
    B) To split a string into a list of words
    C) To split a string into characters
    D) To split a number into digits

 

  1. Which Python library is used for machine learning tasks?
    A) Pandas
    B) NumPy
    C) Matplotlib
    D) Scikit-learn

 

  1. Which of the following is used to evaluate the performance of machine learning models in Python?
    A) Pandas
    B) Scikit-learn
    C) TensorFlow
    D) Keras

 

  1. What is the function of the train_test_split() function in Scikit-learn?
    A) To split a dataset into training and testing sets
    B) To combine two datasets
    C) To optimize a machine learning model
    D) To visualize data

 

  1. What is the output of range(5, 10) in Python?
    A) [5, 6, 7, 8, 9]
    B) [5, 6, 7, 8, 9, 10]
    C) [10, 9, 8, 7, 6, 5]
    D) [5, 6, 7, 8, 9, 10, 11]

 

  1. What is the purpose of the fit() function in machine learning?
    A) To train a model on data
    B) To test the performance of a model
    C) To predict outcomes based on trained data
    D) To visualize the model’s performance

 

  1. How can you change a column’s name in Pandas?
    A) df.rename_column(‘old_name’, ‘new_name’)
    B) df.change_column(‘old_name’, ‘new_name’)
    C) df.rename(columns={‘old_name’: ‘new_name’})
    D) df.rename_column(‘old_name’)

 

  1. Which of the following is a correct way to read data from a JSON file in Pandas?
    A) pd.read_json()
    B) pd.import_json()
    C) pd.load_json()
    D) pd.json_to_dataframe()

 

  1. What is the result of list(range(0, 10, 2)) in Python?
    A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    B) [0, 2, 4, 6, 8]
    C) [1, 3, 5, 7, 9]
    D) [10, 8, 6, 4, 2, 0]

 

  1. Which of the following is used to normalize data in machine learning?
    A) Standardization
    B) Linear regression
    C) Normal distribution
    D) Principal Component Analysis (PCA)

 

  1. In Python, which of the following is used to access a specific element in a list?
    A) list.element()
    B) list[index]
    C) list.index()
    D) list.access()

 

  1. Which of the following is used to handle categorical data in machine learning?
    A) One-hot encoding
    B) Linear regression
    C) Logistic regression
    D) K-means clustering

 

  1. What is the purpose of the fit_transform() function in Scikit-learn?
    A) To fit a model and then transform the data using that model
    B) To split data into training and testing sets
    C) To test the performance of a model
    D) To calculate accuracy

 

  1. Which Python module is used for working with dates and times?
    A) datetime
    B) calendar
    C) time
    D) All of the above

 

  1. Which of the following is true about numpy.array?
    A) It can store elements of only one data type
    B) It is mutable
    C) It can store different data types
    D) Both A and B

 

  1. What is the purpose of the pivot() function in Pandas?
    A) To reshape data by turning unique values from one column into separate columns
    B) To merge multiple DataFrames
    C) To sort the data in the DataFrame
    D) To fill missing data

 

  1. How can you combine two DataFrames on a specific column in Pandas?
    A) merge()
    B) concat()
    C) join()
    D) combine()

 

  1. Which function is used to create an empty DataFrame in Pandas?
    A) pd.DataFrame()
    B) pd.create_empty()
    C) pd.empty()
    D) pd.new()

 

  1. What is the function of the drop() method in Pandas?
    A) To drop a column
    B) To drop a row
    C) To remove missing values
    D) All of the above

 

 

**61. In Python, what is the output of the following code? len(“Data Science”)
A) 11
B) 12
C) 13
D) 14

 

  1. Which of the following is a valid way to create a NumPy array?
    A) array = numpy.create([1, 2, 3])
    B) array = np.array([1, 2, 3])
    C) array = numpy.array([1, 2, 3])
    D) array = array.create([1, 2, 3])

 

  1. What does the drop_duplicates() method in Pandas do?
    A) Drops rows with missing values
    B) Drops duplicate rows
    C) Drops columns with missing values
    D) Drops all rows

 

  1. In Pandas, which function is used to read data from a CSV file?
    A) pd.read_csv()
    B) pd.load_csv()
    C) pd.import_csv()
    D) pd.csv_read()

 

  1. Which of the following is the correct syntax for defining a function in Python?
    A) def function_name[]:
    B) def function_name():
    C) function_name() def:
    D) function function_name():

 

  1. What does the groupby() function in Pandas do?
    A) Splits data into groups based on a key and performs operations
    B) Merges two DataFrames
    C) Filters data based on a condition
    D) Drops columns from a DataFrame

 

  1. What does the set_index() function in Pandas do?
    A) Changes the column order
    B) Sets a specific column as the index of the DataFrame
    C) Resets the index of the DataFrame
    D) Adds a new index to the DataFrame

 

  1. Which of the following is used to visualize data in Python?
    A) Matplotlib
    B) NumPy
    C) SciPy
    D) TensorFlow

 

  1. In Python, what is the result of 3 ** 2?
    A) 5
    B) 6
    C) 9
    D) 7

 

  1. Which of the following is the correct syntax to import the Pandas library?
    A) import pandas as pd
    B) import pandas
    C) import pandas_data as pd
    D) import pandas as data

 

  1. Which of the following is used to handle missing data in Pandas?
    A) fillna()
    B) dropna()
    C) remove_na()
    D) Both A and B

 

**72. In Python, what is the output of type([1, 2, 3])?
A) tuple
B) list
C) set
D) dict

 

  1. What is the purpose of the plt.show() function in Matplotlib?
    A) To generate a plot
    B) To display a plot on the screen
    C) To save the plot to a file
    D) To add labels to the plot

 

  1. Which of the following is used to train a machine learning model?
    A) model.fit()
    B) model.predict()
    C) model.evaluate()
    D) model.score()

 

  1. In Python, which function is used to check if a string contains a substring?
    A) contains()
    B) find()
    C) in
    D) substring()

 

  1. What is the purpose of the sklearn.preprocessing.StandardScaler() function?
    A) To normalize data
    B) To standardize data by removing the mean and scaling to unit variance
    C) To handle missing data
    D) To split data into training and testing sets

 

  1. What is the default axis used by the sum() function in Pandas?
    A) Axis 0 (rows)
    B) Axis 1 (columns)
    C) Both rows and columns
    D) None of the above

 

  1. What is the purpose of the train_test_split() function in Scikit-learn?
    A) To shuffle and split data into training and testing sets
    B) To optimize a machine learning model
    C) To test the performance of a model
    D) To evaluate model accuracy

 

  1. In Python, how do you convert a string to an integer?
    A) int(string)
    B) str.to_integer()
    C) string.to_int()
    D) convert(int, string)

 

  1. What is the default value of the axis parameter in the drop() function in Pandas?
    A) Axis 0 (rows)
    B) Axis 1 (columns)
    C) Axis 2
    D) Axis None

 

  1. What is the purpose of the np.mean() function in NumPy?
    A) To calculate the median of the array
    B) To calculate the mean (average) of the array
    C) To calculate the standard deviation of the array
    D) To calculate the variance of the array

 

  1. Which of the following is used to visualize the relationship between two variables?
    A) Histogram
    B) Scatter plot
    C) Box plot
    D) Pie chart

 

  1. Which Python function is used to read data from a SQL database?
    A) pd.read_sql()
    B) pd.import_sql()
    C) pd.load_sql()
    D) pd.query_sql()

 

  1. Which Python module is used to work with arrays in Python?
    A) NumPy
    B) SciPy
    C) Pandas
    D) Matplotlib

 

  1. Which method is used to check if a file exists in Python?
    A) os.file_exists()
    B) os.exists()
    C) os.path.exists()
    D) file.exists()

 

  1. Which of the following is the correct syntax to create a NumPy array from a Python list?
    A) np.array([1, 2, 3])
    B) np.new_array([1, 2, 3])
    C) np.array(1, 2, 3)
    D) numpy.array([1, 2, 3])

 

  1. In Python, which of the following is used to perform element-wise addition between two arrays?
    A) array1 + array2
    B) array1.add(array2)
    C) np.add(array1, array2)
    D) Both A and C

 

  1. Which of the following is used to sort a DataFrame by a column in Pandas?
    A) df.sort()
    B) df.sort_values()
    C) df.order()
    D) df.sort_by()

 

  1. Which Python library is commonly used for statistical analysis and hypothesis testing?
    A) NumPy
    B) Pandas
    C) SciPy
    D) Keras

 

  1. What is the purpose of the predict() function in Scikit-learn?
    A) To evaluate the model’s performance
    B) To make predictions based on the trained model
    C) To visualize the predictions
    D) To split data into training and testing sets

 

 

  1. What is the purpose of the fillna() function in Pandas?
    A) To fill missing values in a DataFrame with specified values
    B) To remove rows with missing values
    C) To create a new DataFrame with only non-null values
    D) To drop missing columns

 

  1. In Python, which function is used to get the length of a list?
    A) len()
    B) count()
    C) size()
    D) length()

 

  1. What does the iloc[] function in Pandas do?
    A) Accesses data by labels
    B) Accesses data by column names
    C) Accesses data by integer-location based indexing
    D) Accesses data by row indices

 

  1. Which of the following is the default type of axis parameter in Pandas apply() method?
    A) Axis 1 (columns)
    B) Axis 0 (rows)
    C) Axis None
    D) Axis 2

 

  1. In Python, what does the range() function do?
    A) Generates a sequence of numbers
    B) Finds the range of a list
    C) Returns a list of values
    D) Generates a random number

 

  1. What is the purpose of the matplotlib.pyplot.subplot() function?
    A) To create a scatter plot
    B) To create subplots in a figure
    C) To display a plot on the screen
    D) To change the color of a plot

 

  1. Which of the following is used to combine two Pandas DataFrames?
    A) merge()
    B) concat()
    C) join()
    D) All of the above

 

  1. In Python, what is the result of bool(0)?
    A) True
    B) False
    C) None
    D) Error

 

  1. Which of the following is the correct syntax to install a Python library using pip?
    A) pip install library_name
    B) python install library_name
    C) install library_name
    D) pip get library_name

 

  1. Which Python library is best used for working with large datasets and performing data analysis?
    A) NumPy
    B) SciPy
    C) Pandas
    D) Scikit-learn

 

  1. What does the plot() function in Matplotlib do?
    A) Creates a scatter plot
    B) Creates a bar chart
    C) Creates a line plot
    D) Creates a pie chart

 

  1. What type of plot does df.hist() create in Pandas?
    A) Line plot
    B) Bar chart
    C) Histogram
    D) Scatter plot

 

  1. Which of the following is true about the reset_index() function in Pandas?
    A) It changes the column order
    B) It removes the index from a DataFrame
    C) It resets the index to the default integer index
    D) It updates the index based on a column

 

  1. In Python, what does the join() method do for strings?
    A) Combines a list of strings into a single string
    B) Splits a string into a list of characters
    C) Joins two strings in a list
    D) Concatenates a string with a number

 

  1. What does the drop() method in Pandas do?
    A) Drops duplicates from a DataFrame
    B) Drops a specific row or column from a DataFrame
    C) Drops all rows with missing values
    D) Drops the index from a DataFrame

 

  1. Which of the following is used to make predictions using a trained model in Scikit-learn?
    A) predict()
    B) predict_proba()
    C) transform()
    D) fit_predict()

 

  1. Which function in NumPy is used to generate random numbers?
    A) np.random.randint()
    B) np.random.choice()
    C) np.random.rand()
    D) All of the above

 

  1. Which of the following is the correct method to get the number of rows in a Pandas DataFrame?
    A) df.len()
    B) df.shape[1]
    C) df.size()
    D) df.shape[0]

 

  1. In Python, what does the round() function do?
    A) Rounds a number to the nearest integer
    B) Rounds a number to the nearest multiple of 10
    C) Rounds a number to the specified decimal places
    D) Both A and C

 

  1. In Python, which of the following will concatenate two lists?
    A) list1 + list2
    B) list1.concat(list2)
    C) concat(list1, list2)
    D) list1.merge(list2)

 

  1. Which of the following is used for statistical data analysis in Python?
    A) Pandas
    B) NumPy
    C) SciPy
    D) All of the above

 

  1. What does the np.unique() function in NumPy do?
    A) Finds the mean of an array
    B) Finds the unique elements of an array
    C) Sorts the array
    D) Finds the mode of the array

 

  1. In Scikit-learn, which method is used to evaluate the performance of a model?
    A) model.fit()
    B) model.score()
    C) model.predict()
    D) model.evaluate()

 

  1. Which of the following is a characteristic of a Pandas Series?
    A) It is a two-dimensional data structure
    B) It contains data of different data types
    C) It is a one-dimensional labeled array
    D) It is used for visualizing data

 

  1. What is the purpose of the fit() function in Scikit-learn?
    A) To evaluate a model’s accuracy
    B) To fit the model to the training data
    C) To make predictions
    D) To optimize model hyperparameters

 

  1. What does the apply() method in Pandas do?
    A) Applies a function to each element of the DataFrame
    B) Applies a function to each row or column of the DataFrame
    C) Applies a transformation to the DataFrame
    D) Both A and B

 

  1. Which of the following is used for creating bar charts in Matplotlib?
    A) plt.bar()
    B) plt.line()
    C) plt.hist()
    D) plt.scatter()

 

  1. Which of the following methods is used to convert a Pandas DataFrame to a NumPy array?
    A) df.to_numpy()
    B) df.convert()
    C) df.to_array()
    D) df.numpy()

 

  1. In Python, what does str.upper() do?
    A) Converts a string to lowercase
    B) Converts a string to uppercase
    C) Converts the first letter of each word to uppercase
    D) Capitalizes the string

 

  1. In Python, which of the following will return the sum of elements in a list?
    A) sum(list)
    B) list.sum()
    C) total(list)
    D) add(list)

 

 

  1. Which of the following is the primary purpose of Python’s pandas library in data science?
    A) Data visualization
    B) Numerical computation
    C) Data manipulation and analysis
    D) Machine learning

 

  1. What does the split() method in Python do?
    A) Combines two strings into one
    B) Splits a string into a list of substrings based on a specified delimiter
    C) Joins a list into a single string
    D) Removes white spaces from a string

 

  1. Which of the following is the best tool for handling large, structured data in data science?
    A) NumPy
    B) Pandas
    C) Matplotlib
    D) TensorFlow

 

  1. In Python, what does the map() function do?
    A) Maps a function to each element in an iterable
    B) Maps a function to each column in a DataFrame
    C) Maps the output of one function to another function
    D) Maps categorical data to numeric values

 

  1. What does the dropna() method in Pandas do?
    A) Drops missing values from a DataFrame
    B) Drops rows with non-null values
    C) Drops rows with duplicates
    D) Drops specific columns from the DataFrame

 

  1. Which Python library is primarily used for statistical computing and data visualization?
    A) Matplotlib
    B) NumPy
    C) Pandas
    D) SciPy

 

  1. In Python, which of the following is used to create a scatter plot?
    A) plt.plot()
    B) plt.scatter()
    C) plt.bar()
    D) plt.hist()

 

  1. Which of the following methods in Pandas is used to group data based on a column?
    A) df.groupby()
    B) df.sort()
    C) df.merge()
    D) df.pivot()

 

  1. In Python, which function is used to sort a list in ascending order?
    A) sorted(list)
    B) list.sort()
    C) sort(list)
    D) arr.sort()

 

  1. What is the difference between apply() and map() in Pandas?
    A) map() can only be used on DataFrames, while apply() can be used on both DataFrames and Series
    B) map() is used for element-wise operations, while apply() can be used for row or column-level operations
    C) apply() is faster than map()
    D) Both functions are the same

 

  1. What does the astype() method in Pandas do?
    A) Changes the index of a DataFrame
    B) Converts the data type of a column
    C) Creates a new DataFrame
    D) Joins two DataFrames

 

  1. Which Python library is used to handle multidimensional arrays and matrices, commonly used in data science for numerical computations?
    A) Pandas
    B) TensorFlow
    C) NumPy
    D) Scikit-learn

 

  1. What is a DataFrame in Pandas?
    A) A two-dimensional array
    B) A list of dictionaries
    C) A two-dimensional table with rows and columns
    D) A one-dimensional array

 

  1. In Python, which of the following functions is used to calculate the mean of a list of numbers?
    A) mean()
    B) np.mean()
    C) sum()
    D) np.median()

 

  1. In data science, which of the following is the primary advantage of using Python?
    A) Python is a statically typed language
    B) Python is ideal for numerical computing only
    C) Python has extensive libraries for data manipulation and analysis
    D) Python is optimized for hardware performance

 

  1. What is the concat() function in Pandas used for?
    A) Joining two DataFrames together along a particular axis
    B) Splitting a DataFrame into smaller chunks
    C) Counting the number of elements in a DataFrame
    D) Changing the index of a DataFrame

 

  1. In Python, what is the correct way to create a function?
    A) def function_name():
    B) function function_name()
    C) function_name :=
    D) create function_name()

 

  1. What is the output of the Python code snippet: print(2**3)?
    A) 6
    B) 5
    C) 8
    D) 2

 

  1. Which of the following Python libraries is used for machine learning?
    A) NumPy
    B) Matplotlib
    C) Scikit-learn
    D) Pandas

 

  1. What does the groupby() function in Pandas do?
    A) Groups data based on the index
    B) Groups data by column labels
    C) Groups data based on specific columns and applies aggregation functions
    D) Groups data into rows based on their values

 

  1. Which Python library is primarily used for building and training deep learning models?
    A) NumPy
    B) Pandas
    C) Matplotlib
    D) TensorFlow

 

  1. What does the plt.hist() function in Matplotlib do?
    A) Creates a histogram plot
    B) Creates a line plot
    C) Creates a scatter plot
    D) Creates a bar plot

 

  1. What is the purpose of the pivot() function in Pandas?
    A) Converts a DataFrame into a list of dictionaries
    B) Reshapes data from long format to wide format
    C) Combines two DataFrames
    D) Creates a scatter plot

 

  1. In Python, what does the zip() function do?
    A) Zips two lists together into a single list of tuples
    B) Zips a string into a list of characters
    C) Compresses files into a ZIP format
    D) Merges two dictionaries

 

  1. Which of the following methods in NumPy is used to find the standard deviation of an array?
    A) np.mean()
    B) np.std()
    C) np.var()
    D) np.median()

 

  1. In Python, what is the correct way to import the pandas library?
    A) import pandas as pd
    B) import pd as pandas
    C) from pandas import *
    D) import pandas

 

  1. What is the purpose of the value_counts() function in Pandas?
    A) To count the number of rows in a DataFrame
    B) To count the frequency of unique values in a column
    C) To count the number of null values in a DataFrame
    D) To count the number of columns in a DataFrame

 

  1. Which of the following is used to perform element-wise operations on arrays in NumPy?
    A) np.dot()
    B) np.add()
    C) np.multiply()
    D) Both B and C

 

  1. What does the iloc[] function in Pandas do?
    A) Accesses data by row labels
    B) Accesses data by column labels
    C) Accesses data by row and column integer indices
    D) Creates a new DataFrame

 

  1. In Python, what does enumerate() do?
    A) Iterates over a sequence and returns the index and value of each item
    B) Iterates over a sequence and returns only the values
    C) Combines multiple lists into one
    D) Creates a list of tuples

 

 

  1. What is the purpose of the lambda function in Python?
    A) It defines a function in a single line
    B) It is used to define variables
    C) It is used to execute loops
    D) It is used to create new data types

 

  1. What is the primary function of the seaborn library in Python?
    A) To manipulate data
    B) To visualize data using a high-level interface
    C) To perform statistical analysis
    D) To perform machine learning tasks

 

  1. What does the Python len() function do?
    A) Returns the number of elements in a list or sequence
    B) Returns the first element in a sequence
    C) Returns the last element in a sequence
    D) Returns the data type of an element

 

  1. Which of the following statements is true about NumPy arrays compared to Python lists?
    A) NumPy arrays can store elements of different data types
    B) NumPy arrays are not mutable
    C) NumPy arrays are faster and more efficient for large datasets
    D) NumPy arrays cannot be indexed

 

  1. Which Python function is used to read a CSV file into a Pandas DataFrame?
    A) pd.read_csv()
    B) pd.read_file()
    C) pd.open_csv()
    D) pd.load_csv()

 

  1. In Pandas, what does the head() function do?
    A) Displays the entire DataFrame
    B) Displays the first few rows of a DataFrame
    C) Drops the first few rows of a DataFrame
    D) Reverses the rows in a DataFrame

 

  1. What is the purpose of the fit() method in machine learning algorithms?
    A) To optimize the model’s hyperparameters
    B) To fit a model to the training data
    C) To evaluate the model’s performance
    D) To make predictions based on the model

 

  1. Which of the following Python libraries is best used for web scraping and working with HTML data?
    A) NumPy
    B) BeautifulSoup
    C) Scikit-learn
    D) Matplotlib

 

  1. In Python, which of the following keywords is used to handle exceptions?
    A) catch
    B) throw
    C) try and except
    D) raise

 

  1. What is the main purpose of the matplotlib library in Python?
    A) To perform statistical analysis
    B) To visualize data through graphs and charts
    C) To manipulate large datasets
    D) To implement machine learning algorithms

 

  1. In Python, which of the following functions is used to generate random numbers?
    A) random.randint()
    B) random.choice()
    C) random.shuffle()
    D) All of the above

 

  1. Which of the following is used to evaluate machine learning models in Python?
    A) sklearn.model_selection.train_test_split()
    B) pandas.read_csv()
    C) numpy.random.rand()
    D) matplotlib.pyplot.show()

 

  1. Which Python library is widely used for natural language processing (NLP) tasks?
    A) Matplotlib
    B) NLTK
    C) Scikit-learn
    D) Keras

 

  1. What is the purpose of the describe() function in Pandas?
    A) To drop missing values from a DataFrame
    B) To generate summary statistics of numeric columns
    C) To merge two DataFrames
    D) To sort the DataFrame

 

  1. In Python, which of the following methods is used to replace all occurrences of a specified string?
    A) replace()
    B) strip()
    C) split()
    D) join()

 

  1. In Pandas, which function is used to combine two DataFrames by aligning them on their columns or indices?
    A) concat()
    B) merge()
    C) join()
    D) groupby()

 

  1. What does the scatter() function in Matplotlib do?
    A) Creates a bar chart
    B) Creates a line graph
    C) Creates a scatter plot
    D) Creates a histogram

 

  1. Which of the following functions is used to compute the correlation between two series in Pandas?
    A) df.corr()
    B) df.cov()
    C) df.mean()
    D) df.std()

 

  1. Which of the following is the best description of a “class” in Python?
    A) A data structure that holds key-value pairs
    B) A function that returns a value
    C) A blueprint for creating objects
    D) A list of variables and values

 

  1. Which of the following methods in Pandas is used to convert a DataFrame into a NumPy array?
    A) df.to_numpy()
    B) df.array()
    C) df.to_list()
    D) df.to_matrix()

 

  1. What is the reshape() function used for in NumPy?
    A) To reshape an array into a different number of dimensions
    B) To resize an array
    C) To modify the shape of an array in-place
    D) To reshape a list

 

  1. Which of the following data types is immutable in Python?
    A) List
    B) Dictionary
    C) Tuple
    D) Set

 

  1. What is the purpose of the drop() function in Pandas?
    A) To drop rows or columns from a DataFrame
    B) To drop duplicate values from a DataFrame
    C) To drop the index of a DataFrame
    D) To drop null values from a DataFrame

 

  1. Which Python library is used for deep learning and neural networks?
    A) Matplotlib
    B) Pandas
    C) TensorFlow
    D) NumPy

 

  1. Which Python data structure is used to store a collection of unique, unordered elements?
    A) List
    B) Dictionary
    C) Set
    D) Tuple

 

  1. What is the main advantage of using Jupyter Notebooks in data science?
    A) They allow for building and running machine learning models
    B) They allow you to create interactive documents that combine code, visualizations, and text
    C) They are only used for statistical analysis
    D) They are used to write and test Python scripts only

 

  1. Which Python library is commonly used for working with time series data?
    A) Statsmodels
    B) Pandas
    C) NumPy
    D) Matplotlib

 

  1. What does the train_test_split() function in Scikit-learn do?
    A) Splits the dataset into training and testing sets
    B) Splits the dataset into rows and columns
    C) Splits the training data into smaller batches
    D) Splits a model into multiple models

 

  1. In Python, which of the following is used to handle large datasets more efficiently in memory?
    A) Pandas
    B) NumPy
    C) Dask
    D) Seaborn

 

  1. What is the primary purpose of the sklearn.preprocessing.StandardScaler class?
    A) To scale data into a specific range
    B) To normalize data by scaling features to a mean of 0 and standard deviation of 1
    C) To perform feature selection
    D) To split data into training and testing sets

 

 

  1. In Python, which of the following functions is used to merge two DataFrames along columns?
    A) df.append()
    B) df.concat()
    C) df.merge()
    D) df.join()

 

  1. Which Python library is specifically designed for data manipulation and analysis, especially for tabular data?
    A) NumPy
    B) Pandas
    C) Scikit-learn
    D) Matplotlib