B.Pharm Basics of Python Programming for Pharmaceutical Sciences MCQ Questions with Answers

Basics of Python Programming for Pharmaceutical Sciences – BP101T Unit-wise Multiple Choice Questions (MCQ) with Answers.

Unit – 1

Introduction to Python Programming MCQ

Q1. Python is an interpreted, high-level, dynamically typed programming language created by Guido van
Rossum and first officially released in which year?
A. 1985
B. 1991
C. 1999
D. 2008
Correct Answer: (B) 1991

Q2. In Computer-Aided Drug Design (CADD) and QSAR modeling, what is the primary role of Python scripts?
A. To control the mechanical rotation speed of rotary tablet presses
B. To compute physicochemical molecular descriptors like logP, molecular weight, and hydrogen-bonding capacity to predict bioactivity
C. To package glass ampoules into sterile shipping cartons
D. To chemically synthesize active pharmaceutical intermediates in reaction vessels
Correct Answer: (B) To compute physicochemical molecular descriptors like logP, molecular weight, and hydrogenbonding capacity to predict bioactivity

Q3. Why is it essential to check the “Add Python to PATH” checkbox during the Windows Python installation
procedure?
A. It installs specialized chemoinformatics libraries like RDKit automatically
B. It registers the Python interpreter executable within operating system environment variables, allowing scripts to run from any terminal directory
C. It creates desktop shortcuts for all text editors on the system
D. It converts Python source code into compiled C++ binary files
Correct Answer: (B) It registers the Python interpreter executable within operating system environment variables, allowing scripts to run from any terminal directory

Q4. What is the core operational function of the pip utility in the Python development ecosystem?
A. To compile source code line-by-line into machine bytecode
B. To serve as the official package installer to download, update, query, and manage third-party libraries from PyPI
C. To check for variable indentation errors in conditional statements
D. To clean corrupted clinical trial CSV files
Correct Answer: (B) To serve as the official package installer to download, update, query, and manage third-party libraries from PyPI

Q5. In Python, keyboard entries captured from a laboratory technician using the built-in input() function are
always returned as which data type?
A. Integer (int)
B. Floating-point (float)
C. String (str)
D. Boolean (bool)
Correct Answer: (C) String (str)

Q6. If a clinician captures patient weight as “70” via input() without type casting, what does the expression
weight * 2 evaluate to?
A. 140
B. 140.0
C. “7070” (string repetition)
D. Raises a TypeError immediately
Correct Answer: (C) “7070” (string repetition)

Q7. What will be the evaluated output of the floor division expression: bottles = 50 // 12?
A. 4.1667
B. 4
C. 2
D. 5
Correct Answer: (B) 4

Q8. In a blister-packaging calculation, what does the modulus expression leftover_tablets = 53 % 10
evaluate to?
A. 5.3
B. 5
C. 3
D. 0
Correct Answer: (C) 3

Q9. Which Python arithmetic operator is utilized to raise a base number to a specific mathematical power
(exponentiation)?
A. ^
B. **
C. ^^
D. exp()
Correct Answer: (B) **

Q10. According to standard Python operator precedence rules, which arithmetic operation is evaluated first in
a complex expression?
A. Addition (+)
B. Multiplication (*)
C. Exponentiation (**)
D. Operations enclosed in Parentheses ()
Correct Answer: (D) Operations enclosed in Parentheses ()

Q11. What runtime error is raised if a programmer attempts to modify a character in-place on a string (e.g.,
drug = “Aspirin”; drug[0] = “B”)?
A. ValueError
B. TypeError
C. IndexError
D. SyntaxError
Correct Answer: (B) TypeError

Q12. In Python string slicing, if drug = “ASPIRIN”, what substring is generated by executing
print(drug[0:3])?
A. ‘ASP’
B. ‘ASPI’
C. ‘SPIR’
D. ‘IRIN’
Correct Answer: (A) ‘ASP’

Q13. In Python string slicing syntax, what operation is performed when the step parameter is set to -1 (e.g.,
drug[::-1] on “ASPIRIN”)?
A. It extracts every second character starting from index 0
B. It reverses the entire sequence of characters, outputting ‘NIRIPSA’
C. It deletes the last character of the string
D. It converts all uppercase characters into lowercase
Correct Answer: (B) It reverses the entire sequence of characters, outputting ‘NIRIPSA’

Q14. What substring is extracted from drug = “PARACETAMOL” by the slicing expression drug[4:]?
A. ‘PARA’
B. ‘CETAMOL’
C. ‘ACETAMOL’
D. ‘ETAMOL’
Correct Answer: (B) ‘CETAMOL’

Q15. Which built-in string method eliminates all leading and trailing whitespace characters from messy
laboratory text records?
A. .clean()
B. .trim()
C. .strip()
D. .clear()
Correct Answer: (C) .strip()

Q16. Which string method transforms the lowercase drug label “paracetamol 500mg” into standard
uppercase format “PARACETAMOL 500MG”?
A. .upper()
B. .capitalize()
C. .to_upper()
D. .uppercase()
Correct Answer: (A) .upper()

Q17. During prescription standardization, what string method substitutes abbreviation “Tab. PCM” with
“Tablet PCM”?
A. “Tab. PCM”.modify(“Tab.”, “Tablet”)
B. “Tab. PCM”.replace(“Tab.”, “Tablet”)
C. “Tab. PCM”.swap(“Tab.”, “Tablet”)
D. “Tab. PCM”.update(“Tab.”, “Tablet”)
Correct Answer: (B) “Tab. PCM”.replace(“Tab.”, “Tablet”)

Q18. What data structure is produced when executing “Aspirin, 500mg, Oral”.split(“, “)?
A. (‘Aspirin’, ‘500mg’, ‘Oral’)
B. [‘Aspirin’, ‘500mg’, ‘Oral’]
C. {‘Aspirin’, ‘500mg’, ‘Oral’}
D. “Aspirin 500mg Oral”
Correct Answer: (B) [‘Aspirin’, ‘500mg’, ‘Oral’]

Q19. What is the formal definition of an Integrated Development Environment (IDE) in software engineering?
A. An operating system kernel designed exclusively for pharmaceutical robotics
B. A consolidated software application combining source code editor, interpreter, debugger, and terminal utilities into a unified interface
C. A physical hardware device that connects laboratory analytical balances to computers
D. A cloud database server used only for archiving clinical trial files
Correct Answer: (B) A consolidated software application combining source code editor, interpreter, debugger, and terminal utilities into a unified interface

Q20. Which four essential architectural components are consolidated within a full-featured IDE?
A. Web browser, Graphic designer, Video editor, Sound mixer
B. Source code editor, Python interpreter/compiler, Interactive debugger, Terminal manager
C. Database server, Network router, Firewall, Storage partition
D. RAM allocator, BIOS setup, CPU register, Power manager
Correct Answer: (B) Source code editor, Python interpreter/compiler, Interactive debugger, Terminal manager

Unit – 2

Control Structures & Functions MCQ

Q1. What is the primary role of conditional control structures in pharmaceutical algorithm design?
A. To allocate dynamic computer memory buffers during high-throughput drug screening
B. To evaluate criteria such as quality control specifications, dosage limits, and clinical alerts
C. To compile raw Python source code into machine-executable binary files
D. To convert analogue biosensor voltage streams into discrete integer values
Correct Answer: (B) To evaluate criteria such as quality control specifications, dosage limits, and clinical alerts

Q2. Under Python standard syntax conventions (PEP 8), how is statement block scoping defined?
A. By enclosing code blocks within curly braces { }
B. By terminating statements with mandatory semicolons (;)
C. By maintaining uniform leading whitespace, typically 4 spaces per indentation level
D. By sandwiching execution blocks between BEGIN and END tags
Correct Answer: (C) By maintaining uniform leading whitespace, typically 4 spaces per indentation level

Q3. Which built-in exception is explicitly triggered by Python when code blocks lack required spacing or mix tabs and spaces?
A. SyntaxError: invalid symbol
B. IndentationError
C. ValueError
D. TypeError
Correct Answer: (B) IndentationError

Q4. If a pharmaceutical QC script checks if measured_hardness >= 4.0: with an input of 3.8 kgf, what
execution flow occurs?
A. The if block executes and prints “PASS”
B. The program aborts immediately with a FatalError
C. The else fallback block executes because the condition evaluates to False
D. The script enters an infinite loop waiting for updated input
Correct Answer: (C) The else fallback block executes because the condition evaluates to False

Q5. In Python, what exact integer sequence is generated by the built-in function expression range(5)?
A. 1, 2, 3, 4, 5
B. 0, 1, 2, 3, 4, 5
C. 0, 1, 2, 3, 4
D. 1, 2, 3, 4
Correct Answer: (C) 0, 1, 2, 3, 4

Q6. What exact integer sequence is generated by the Python expression range(10, 50, 10)?
A. 10, 20, 30, 40, 50
B. 10, 20, 30, 40
C. 0, 10, 20, 30, 40
D. 20, 30, 40, 50
Correct Answer: (B) 10, 20, 30, 40

Q7. What is the fundamental difference in execution mechanism between a for loop and a while loop?
A. A for loop is condition-driven, whereas a while loop is sequence-driven
B. A for loop iterates across elements of an iterable, while a while loop repeats as long as a condition evaluates to True
C. A for loop cannot iterate over numeric data, while a while loop only processes strings
D. A for loop terminates only upon an exception, whereas a while loop runs for a fixed number of counts
Correct Answer: (B) A for loop iterates across elements of an iterable, while a while loop repeats as long as a condition evaluates to True

Q8. Which jump statement completely halts the loop and shifts execution control to the statement immediately
following the loop body?
A. continue
B. pass
C. break
D. return
Correct Answer: (C) break

Q9. State the exact functional behavior of the continue statement inside an iterating loop:
A. It instantly terminates script execution
B. It restarts the loop starting from index zero
C. It skips remaining instructions in the current iteration and jumps immediately to the next loop cycle
D. It pauses script execution for a specified interval in seconds
Correct Answer: (C) It skips remaining instructions in the current iteration and jumps immediately to the next loop cycle

Q10. Which Python keyword is utilized to define a user-defined function?
A. function
B. define
C. def
D. fun
Correct Answer: (C) def

Q11. Under what data structure does Python package and return multiple comma-separated values from a
function?
A. List
B. Dictionary
C. Tuple
D. Set
Correct Answer: (C) Tuple

Q12. According to Young’s Rule, what is the mathematical formula used for calculating pediatric dosage in children aged 1 to 12 years?
A. [Age / 20] × Adult Dose
B. [Age / (Age + 12)] × Adult Dose
C. [Weight (kg) / 70] × Adult Dose
D. [Age / 12] × Adult Dose
Correct Answer: (B) [Age / (Age + 12)] × Adult Dose

Q13. According to Dilling’s Rule, what formula is applied to determine pediatric dose for children aged 4 to 20years?
A. [Age / 12] × Adult Dose
B. [Age / 20] × Adult Dose
C. [(Age + 12) / Age] × Adult Dose
D. [Weight (kg) / 100] × Adult Dose
Correct Answer: (B) [Age / 20] × Adult Dose

Q14. State the mathematical formula used to calculate adult Body Mass Index (BMI):
A. Weight (kg) / Height (cm)
B. Weight (kg) / [Height (m)]²
C. [Weight (kg)]² / Height (m)
D. Height (m) / [Weight (kg)]²
Correct Answer: (B) Weight (kg) / [Height (m)]²

Q15. Under WHO adult BMI criteria, how is an individual with a calculated BMI of 27.89 kg/m² categorized?
A. Underweight
B. Normal Weight
C. Overweight
D. Obese
Correct Answer: (C) Overweight

Q16. In Python conditional control structures, what is the specific role of the elif keyword?
A. To define an infinite fallback loop
B. To evaluate sequential, mutually exclusive alternate conditions in a multi-way branching ladder
C. To terminate the entire program when an error occurs
D. To enforce mandatory type casting on boolean variables
Correct Answer: (B) To evaluate sequential, mutually exclusive alternate conditions in a multi-way branching ladder

Q17. In an if-elif-else blood pressure ladder (<120 Normal, <130 Elevated, <140 Stage 1 HTN, else Stage 2 HTN), how is systolic_bp = 135 classified?
A. Normal
B. Elevated
C. Stage 1 Hypertension
D. Stage 2 Hypertension
Correct Answer: (C) Stage 1 Hypertension

Q18. What constitutes a nested condition in Python programming?
A. A loop placed inside another loop construct
B. An if or if-else statement placed inside the execution block of another conditional statement
C. Combining two strings with an addition operator
D. A function that calls itself recursively
Correct Answer: (B) An if or if-else statement placed inside the execution block of another conditional statement

Q19. When the built-in function range(stop) is supplied with a single parameter, what is its implicit default start
value?
A. 1
B. -1
C. 0
D. None
Correct Answer: (C) 0

Q20. What is the default step increment in Python’s range(start, stop) function when the step argument is not
provided?
A. 0
B. 1
C. 2
D. -1
Correct Answer: (B) 1

Unit – 3

Data Structures & File Handling MCQ

Q1. Which Python data structure is enclosed in square brackets [] and permits dynamic addition, deletion, and
modification of elements?
A. Tuple
B. List
C. Dictionary
D. String
Correct Answer: (B) List

Q2. What runtime exception is raised by Python if an attempt is made to reassign an element inside an
allocated tuple?
A. ValueError
B. KeyError
C. TypeError
D. IndexError
Correct Answer: (C) TypeError

Q3. What is the average time complexity for searching a key in a standard Python dictionary implementation?
A. O(n)
B. O(log n)
C. O(1)
D. O(n²)
Correct Answer: (C) O(1)

Q4. Given drugs = [“Aspirin”, “Paracetamol”, “Ibuprofen”, “Caffeine”, “Codeine”], what does
drugs[1:3] return?
A. [‘Paracetamol’, ‘Ibuprofen’, ‘Caffeine’]
B. [‘Paracetamol’, ‘Ibuprofen’]
C. [‘Aspirin’, ‘Paracetamol’]
D. [‘Ibuprofen’, ‘Caffeine’]
Correct Answer: (B) [‘Paracetamol’, ‘Ibuprofen’]

Q5. Which string manipulation method safely removes leading and trailing white spaces from messy
prescription input records?
A. .clean()
B. .trim()
C. .strip()
D. .split()
Correct Answer: (C) .strip()

Q6. What is the fundamental N-dimensional homogeneous array data structure provided by the NumPy
library?
A. DataFrame
B. ndarray
C. Series
D. Matrix
Correct Answer: (B) ndarray

Q7. What exact sequence of values is produced by executing np.linspace(0, 60, 7)?
A. [0, 10, 20, 30, 40, 50]
B. [0., 10., 20., 30., 40., 50., 60.]
C. [10., 20., 30., 40., 50., 60., 70.]
D. [0, 7, 14, 21, 28, 35, 42]
Correct Answer: (B) [0., 10., 20., 30., 40., 50., 60.]

Q8. What is the mathematical formulation of the Beer-Lambert Law used in spectrophotometric drug assay
evaluations?
A. A = ε / (c × l)
B. A = ε × c × l
C. A = (ε × l) / c
D. A = c / (ε × l)
Correct Answer: (B) A = ε × c × l

Q9. Which Python module from the standard library provides writerows() and reader() for commadelimited tabular files?
A. os
B. sys
C. csv
D. fileio
Correct Answer: (C) csv

Q10. In structured healthcare informatics, clinical disease severity staged as (Mild < Moderate < Severe)
represents which data type?
A. Continuous Quantitative
B. Nominal Qualitative
C. Ordinal Qualitative
D. Temporal
Correct Answer: (C) Ordinal Qualitative

Q11. What is the operational behavior of np.where(condition, x, y) when applied to a clinical trial
DataFrame column?
A. It deletes rows where the condition evaluates to False
B. It returns value x if the condition evaluates to True, and value y if False
C. It computes the arithmetic mean of column x and column y
D. It raises a KeyError if condition contains missing values
Correct Answer: (B) It returns value x if the condition evaluates to True, and value y if False

Q12. Why are tuples strictly preferred over lists for storing reference standards like molecular weight, melting point, or CAS numbers?
A. Tuples require larger heap memory allocation than lists
B. Tuples guarantee data integrity because their elements are immutable and cannot be overwritten during runtime
C. Tuples automatically convert chemical formulas into lowercase text
D. Tuples support key-based hash lookup faster than dictionaries
Correct Answer: (B) Tuples guarantee data integrity because their elements are immutable and cannot be
overwritten during runtime

Q13. Which combination correctly pairs Python data structures with their respective enclosure syntax?
A. List: (), Tuple: [], Dictionary: {}
B. List: [], Tuple: (), Dictionary: {}
C. List: {}, Tuple: (), Dictionary: []
D. List: [], Tuple: {}, Dictionary: ()
Correct Answer: (B) List: [], Tuple: (), Dictionary: {}

Q14. Which built-in list method appends a new active pharmaceutical ingredient to the very end of an existing
list?
A. .push()
B. .add()
C. .append()
D. .insert()
Correct Answer: (C) .append()

Q15. Which list method inserts a new excipient at a specified designated index position?
A. .append()
B. .insert()
C. .extend()
D. .add()
Correct Answer: (B) .insert()

Q16. What is the fundamental operational difference between .remove(x) and .pop([i]) on a Python list?
A. .remove(x) deletes by index, whereas .pop([i]) deletes by value
B. .remove(x) deletes the first occurrence of value x, whereas .pop([i]) removes and returns the element at index i
C. .remove(x) clears the entire list, whereas .pop([i]) only resets element to zero
D. .remove(x) only works on tuples, whereas .pop([i]) works on dictionaries
Correct Answer: (B) .remove(x) deletes the first occurrence of value x, whereas .pop([i]) removes and returns the element at index i

Q17. In Python list slicing, what is the critical governing rule regarding the terminal stop index?
A. The element at the stop index is always included in the returned slice
B. The terminal stop boundary is strictly excluded, extracting items up to stop – 1
C. Slicing raises an IndexError if the stop boundary exceeds list length
D. The stop index must always be negative
Correct Answer: (B) The terminal stop boundary is strictly excluded, extracting items up to stop – 1

Q18. Given drugs = [“Aspirin”, “Paracetamol”, “Ibuprofen”, “Caffeine”, “Codeine”], what
value is accessed by drugs[-1]?
A. “Aspirin”
B. “Caffeine”
C. “Codeine”
D. “Paracetamol”
Correct Answer: (C) “Codeine”

Q19. Which dictionary method allows direct iteration over paired key-value tuples?
A. .keys()
B. .values()
C. .items()
D. .pairs()
Correct Answer: (C) .items()

Q20. Given stock = {“Paracetamol”: 500, “Amoxicillin”: 250, “Ciprofloxacin”: 100}, what total
is calculated by iterating over stock.values()?
A. 750
B. 850
C. 600
D. 950
Correct Answer: (B) 850

Unit – 4

Data Handling with Pandas MCQ

Q1. Developed by Wes McKinney in 2008, the term “Pandas” is derived from which econometric concept?
A. Parallel Data Systems
B. PANel DAta
C. Predictive Analytical Datasets
D. Pharmaceutical Analysis Database
Correct Answer: (B) PANel DAta

Q2. What is the fundamental 1-dimensional labeled homogeneous array data structure provided by the Pandas
library?
A. DataFrame
B. Series
C. ndarray
D. Panel
Correct Answer: (B) Series

Q3. What is a Pandas DataFrame, and how does it organize multi-variable pharmaceutical data?
A. A 1-dimensional array that holds only floating-point numbers
B. A 2-dimensional, size-mutable tabular data structure with labeled rows and heterogeneous named columns
C. An unindexed binary file format for storing spectrophotometer spectra
D. A 3-dimensional tensor used exclusively for deep neural network training
Correct Answer: (B) A 2-dimensional, size-mutable tabular data structure with labeled rows and heterogeneous
named columns

Q4. Why is Pandas strongly preferred over manual Microsoft Excel spreadsheets in pharmaceutical quality
control and clinical trials?
A. Excel cannot perform basic mathematical additions
B. Pandas scripts provide an automated, reproducible audit trail compliant with regulatory standards like GxP and 21 CFR Part 11
C. Pandas operates without using system memory or RAM
D. Excel files cannot be stored on modern operating systems
Correct Answer: (B) Pandas scripts provide an automated, reproducible audit trail compliant with regulatory
standards like GxP and 21 CFR Part 11

Q5. Which syntax correctly constructs a Pandas Series to track Paracetamol plasma concentration across
specific sampling time intervals?
A. pd.Series(data=[2.5, 8.4, 12.1], index=[‘0.5 hr’, ‘1.0 hr’, ‘2.0 hr’], name=”Plasma_Conc”)
B. pd.DataFrame(values=[2.5, 8.4, 12.1], labels=[‘0.5 hr’, ‘1.0 hr’, ‘2.0 hr’])
C. pd.Series(rows=[2.5, 8.4, 12.1], columns=[‘0.5 hr’, ‘1.0 hr’, ‘2.0 hr’])
D. pd.CreateSeries([2.5, 8.4, 12.1], time=[‘0.5 hr’, ‘1.0 hr’, ‘2.0 hr’])
Correct Answer: (A) pd.Series(data=[2.5, 8.4, 12.1], index=[‘0.5 hr’, ‘1.0 hr’, ‘2.0 hr’], name=”Plasma_Conc”)

Q6. By default, how many rows are printed on the console when invoking the diagnostic function df.head()
without arguments?
A. 10
B. 5
C. 3
D. 1
Correct Answer: (B) 5

Q7. What is the default number of trailing rows returned by executing df.tail() on an analytical assay
dataset?
A. 5
B. 10
C. 7
D. 2
Correct Answer: (A) 5

Q8. Which diagnostic function summarizes the total row count, non-null observations, column data types, and
memory footprint of a DataFrame?
A. df.describe()
B. df.info()
C. df.shape()
D. df.dtypes()
Correct Answer: (B) df.info()

Q9. If a clinical trial dataset contains 120 total participant rows, and df.info() reports 114 non-null entries for
Blood_Pressure, how many values are missing?
A. 114
B. 0
C. 6
D. 120
Correct Answer: (C) 6

Q10. In df.info(), if a column containing tablet dosage numbers is listed with data type object, what does
this indicate?
A. The column is stored as binary floating-point numbers
B. The column has been parsed as text strings due to non-numeric entries or improper formatting
C. The column contains only boolean flags
D. The column is completely empty
Correct Answer: (B) The column has been parsed as text strings due to non-numeric entries or improper formatting

Q11. Which statistical metrics are automatically calculated by calling df.describe() on numerical columns
in a quality control dataset?
A. Mean, standard deviation, count, min, 25%, 50% (median), 75%, and max
B. Mode, variance, skewness, and kurtosis only
C. Chi-square statistic and p-value
D. Sum and cumulative product only
Correct Answer: (A) Mean, standard deviation, count, min, 25%, 50% (median), 75%, and max

Q12. In evaluating tablet weight variation against Indian Pharmacopoeia (IP) standards (>250 mg average
weight: ±5% limit), which descriptive statistics verify batch compliance?
A. Checking whether the min and max weights stay within ±5% of the calculated sample mean
B. Checking whether the total tablet count is an odd integer
C. Verifying that the standard deviation equals exactly 0.00
D. Ensuring that the median is exactly twice the minimum weight
Correct Answer: (A) Checking whether the min and max weights stay within ±5% of the calculated sample mean

Q13. In Pandas data sanitation protocols, what does the missing value placeholder NaN represent?
A. New Array Number
B. Not a Number
C. Negative Analytical Null
D. Nominal Attribute Notation
Correct Answer: (B) Not a Number

Q14. In pharmacokinetic studies, which parameter in pd.read_csv() converts unquantified text entries like
‘BQL’ and ‘ND’ into standard NaN values?
A. missing_values
B. na_values
C. null_markers
D. drop_na
Correct Answer: (B) na_values

Q15. Which Pandas function is specifically designed to ingest multi-sheet safety logs stored in Microsoft Excel
(.xlsx) workbooks?
A. pd.read_csv()
B. pd.read_excel()
C. pd.read_sheets()
D. pd.import_workbook()
Correct Answer: (B) pd.read_excel()

Q16. When loading a large pharmacovigilance Excel file, which parameter selects only targeted attributes (e.g.,
[‘Report_ID’, ‘Severity’]) to optimize memory?
A. select_cols
B. usecols
C. filter_cols
D. columns_include
Correct Answer: (B) usecols

Q17. When exporting a cleaned pharmacokinetic DataFrame to a CSV file using to_csv(), which argument
prevents writing redundant numeric row indices?
A. index=False
B. header=False
C. drop_index=True
D. no_index=True
Correct Answer: (A) index=False

Q18. Which method saves an adverse event summary DataFrame into an Excel file on disk without writing the
default DataFrame index?
A. df.to_excel(‘severe_cases.xlsx’, index=False)
B. df.save_excel(‘severe_cases.xlsx’)
C. df.write_xls(‘severe_cases.xlsx’, index=False)
D. pd.export_excel(df, ‘severe_cases.xlsx’)
Correct Answer: (A) df.to_excel(‘severe_cases.xlsx’, index=False)

Q19. What is the fundamental difference between label-based selection using .loc[] and position-based
selection using .iloc[]?
A. .loc[] uses integer positions (0, 1, 2), while .iloc[] uses explicit row/column text labels
B. .loc[] selects data using explicit row and column labels, whereas .iloc[] selects data strictly using integer positions
C. .loc[] only works on Series, while .iloc[] works only on DataFrames
D. .loc[] is used for file export, while .iloc[] is used for file ingestion
Correct Answer: (B) .loc[] selects data using explicit row and column labels, whereas .iloc[] selects data strictly using integer positions

Q20. Which expression extracts the very first row of a clinical trial DataFrame using integer-based
positioning?
A. df.loc[0]
B. df.iloc[0]
C. df.get_row(1)
D. df.position[0]
Correct Answer: (B) df.iloc[0]

Unit – 5

Data Visualization with Matplotlib MCQ

Q1. What is the primary role of the Matplotlib library in pharmaceutical research and computational drug
development?
A. To perform robotic pill dispensing in hospital outpatient pharmacies
B. To generate 2D scientific visualizations of pharmacokinetic profiles, in vitro dissolution kinetics, and quality control distributions
C. To execute database indexing on SQL hospital records
D. To control hardware temperature sensors in tablet drying ovens
Correct Answer: (B) To generate 2D scientific visualizations of pharmacokinetic profiles, in vitro dissolution
kinetics, and quality control distributions

Q2. Which standard Python statement is executed to import the 2D plotting submodule of Matplotlib under its
conventional alias?
A. import matplotlib.plot as plt
B. import matplotlib.pyplot as plt
C. from pyplot import matplotlib
D. import matplotlib.charts as plt
Correct Answer: (B) import matplotlib.pyplot as plt

Q3. Which Matplotlib plotting function is executed to create continuous two-dimensional line plots illustrating
plasma drug concentration changes over time?
A. plt.line()
B. plt.scatter()
C. plt.plot()
D. plt.curve()
Correct Answer: (C) plt.plot()

Q4. Which visualization chart is preferred for evaluating the frequency distribution and spread of tablet
weights during in-process quality control?
A. Pie Chart
B. Histogram (plt.hist)
C. Line Plot
D. Polar Chart
Correct Answer: (B) Histogram (plt.hist)

Q5. Which functions are invoked in Matplotlib to label the horizontal X-axis and define an overarching title for a
dissolution profile?
A. plt.set_xaxis() and plt.heading()
B. plt.xlabel() and plt.title()
C. plt.xaxis_title() and plt.main_title()
D. plt.label_x() and plt.chart_name()
Correct Answer: (B) plt.xlabel() and plt.title()

Q6. What is the essential utility of invoking the plt.legend() function in multi-formulation comparative
plots?
A. To delete incomplete rows from the underlying DataFrame
B. To display an explanatory key decoding colors, linestyles, and markers corresponding to plotted formulations
C. To calculate the mathematical area under the curve (AUC)
D. To automatically close the active plotting window
Correct Answer: (B) To display an explanatory key decoding colors, linestyles, and markers corresponding to
plotted formulations

Q7. Which Matplotlib plotting function produces a five-number summary display to visually isolate Out-ofSpecification (OOS) batches?
A. plt.stem()
B. plt.boxplot()
C. plt.pie()
D. plt.scatter()
Correct Answer: (B) plt.boxplot()

Q8. In the method plt.savefig(‘pk_plot.png’, dpi=300), what does the argument dpi=300 specify?
A. Data points inspection interval
B. Dots per inch, controlling physical print resolution
C. Degree of pixel indentation
D. Display plot intensity
Correct Answer: (B) Dots per inch, controlling physical print resolution

Q9. How is a background reference grid activated across the plotting area to facilitate reading exact
pharmacokinetic concentration values?
A. plt.set_mesh()
B. plt.grid(True)
C. plt.background_grid()
D. plt.draw_axis_lines()
Correct Answer: (B) plt.grid(True)

Q10. Which command renders and displays the compiled Matplotlib plotting canvas to the end user?
A. plt.render()
B. plt.display()
C. plt.show()
D. plt.view()
Correct Answer: (C) plt.show()

Q11. Which chart type is best suited for contrasting discrete Adverse Drug Reaction (ADR) reporting counts
among distinct antibiotic classes?
A. Line Plot
B. Scatter Plot
C. Categorical Bar Chart (plt.bar)
D. 3D Wireframe Plot
Correct Answer: (C) Categorical Bar Chart (plt.bar)

Q12. Which command terminates and clears memory allocated to the currently active Matplotlib figure
window?
A. plt.close()
B. plt.exit()
C. plt.delete()
D. plt.discard()
Correct Answer: (A) plt.close()

Q13. Inside a Matplotlib box plot, what specific statistical metric is represented by the central horizontal line within the box?
A. Arithmetic Mean
B. Mode
C. Median (50th percentile)
D. Standard Error
Correct Answer: (C) Median (50th percentile)

Q14. Which Matplotlib function renders horizontal threshold lines spanning the full time axis to demarcate
Minimum Effective Concentration (MEC)?
A. plt.horizontal_line()
B. plt.draw_hline()
C. plt.axhline()
D. plt.yline()
Correct Answer: (C) plt.axhline()

Q15. Which parameter in plt.plot() assigns a dashed line pattern to an elimination kinetics curve?
A. linetype=’dashed’
B. linestyle=’–‘
C. style=’dash’
D. line=’dots’
Correct Answer: (B) linestyle=’–‘

Q16. Under Tukey’s outlier detection rule in box plots, data points falling beyond which boundary are plotted
as isolated flier dots?
A. 1.0 × IQR beyond Q1 or Q3
B. 1.5 × IQR beyond Q1 or Q3
C. 2.0 × Standard Deviation from the mean
D. 3.0 × Variance from the median
Correct Answer: (B) 1.5 × IQR beyond Q1 or Q3

Q17. What is the fundamental difference in application between a Line Plot (plt.plot) and a Scatter Plot
(plt.scatter)?
A. Line plots connect ordered continuous temporal observations, whereas scatter plots display individual coordinates to examine correlation
B. Line plots can only plot positive integers, whereas scatter plots plot negative numbers
C. Scatter plots require dates, while line plots require text strings
D. Line plots only work on Pandas DataFrames, while scatter plots only work on tuples
Correct Answer: (A) Line plots connect ordered continuous temporal observations, whereas scatter plots display
individual coordinates to examine correlation

Q18. In pharmacology research, which plotting function is best suited to display the relationship between
administered drug dose and receptor inhibition percentage?
A. plt.bar()
B. plt.scatter()
C. plt.pie()
D. plt.hist()
Correct Answer: (B) plt.scatter()

Q19. When initializing a plotting canvas with plt.figure(figsize=(8, 4.5)), what do the numerical values
represent?
A. Canvas width and height in centimeters
B. Canvas width and height in inches
C. Total number of data rows and columns
D. Aspect ratio in millimeters
Correct Answer: (B) Canvas width and height in inches

Q20. What is the mathematical definition of the Interquartile Range (IQR) represented by the box body in a box
plot?
A. Maximum value minus Minimum value
B. 75th percentile (Q3) minus 25th percentile (Q1)
C. Median minus Mean
D. Standard deviation divided by sample size
Correct Answer: (B) 75th percentile (Q3) minus 25th percentile (Q1)

Leave a Comment