BP101T Important Questions: Unit I, हिन्दी में समझिए

Unit I: Introduction to Python programming

PCI exam pattern के हिसाब से Unit I के सबसे ज़रूरी सवाल। Model answers English में हैं, जैसा exam में लिखना है, और हर सवाल के नीचे हिन्दी में आसान explanation है।

PCI exam pattern · 75 marks

  • Multiple choice questions20 × 1 = 20 marks
  • Long answers (answer 2 of 3)2 × 10 = 20 marks
  • Short answers (answer 7 of 9)7 × 5 = 35 marks

PCI syllabus के आधार पर expected questions। BP101T नया subject है, इसलिए अभी पिछले साल के papers नहीं हैं; university के असली सवाल अलग हो सकते हैं।

Long answer questions (10 marks)

Q1

Explain the features of Python and its applications in pharmaceutical sciences.

Python के features और pharmaceutical sciences में इसके applications समझाइए।

हिन्दी में समझिए

Answer को दो हिस्सों में लिखिए: पहले Python की खूबियाँ (आसान भाषा, interpreted, free, libraries वाली), फिर pharmacy में उपयोग जैसे clinical trial data, pharmacokinetics और drug design। हर point के साथ एक छोटा उदाहरण लिखेंगे तो पूरे marks मिलने की संभावना बढ़ती है।

▶Model answer देखें (English)

Introduction: Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It is one of the most widely used languages for data analysis, automation and artificial intelligence.

Features of Python:

  1. Simple and readable: its syntax is close to English, so programs are easy to write, read and learn.
  2. Interpreted: code is executed statement by statement by the Python interpreter, which makes testing and finding mistakes easy. (Internally, Python first converts code into bytecode, which the Python Virtual Machine runs.)
  3. High-level: the programmer does not need to manage memory or hardware details.
  4. Free and open source: anyone can use, share and modify it at no cost.
  5. Portable (cross-platform): the same program runs on Windows, macOS and Linux.
  6. Dynamically typed: the data type of a value is decided automatically when the program runs; it does not have to be declared.
  7. Large standard library and third-party libraries: for example NumPy, Pandas and Matplotlib for data analysis and graphs.
  8. Supports object-oriented programming and has a large, active community.

Applications in pharmaceutical sciences:

  1. Clinical trial data analysis: cleaning, summarising and analysing patient data.
  2. Pharmacokinetics: calculating parameters such as Cmax, Tmax and AUC and plotting concentration–time curves.
  3. Pharmacovigilance: analysing adverse drug reaction (ADR) reports to detect safety signals.
  4. Computer-aided drug design (CADD) and cheminformatics: handling molecular structures and predicting drug properties (e.g. with RDKit).
  5. Automation: generating lab reports, labels and dosage calculations.
  6. Machine learning and AI: predicting drug activity and supporting drug discovery.

Conclusion: Because it is easy to learn and has powerful libraries, Python is the preferred language for data work in the pharmaceutical industry.

Q2

Explain the steps to install Python and an IDE. List the advantages of using an IDE over a simple text editor.

Python और एक IDE install करने के steps समझाइए। Text editor की तुलना में IDE के फायदे लिखिए।

हिन्दी में समझिए

Install के steps क्रम से लिखिए: python.org से download, "Add to PATH" tick करना, फिर python --version से check करना। उसके बाद IDE के फायदे points में लिखिए, जैसे colour वाला code, auto-completion और error पहले ही दिख जाना।

▶Model answer देखें (English)

Installing Python (Windows):

  1. Download the latest Python 3 installer from python.org.
  2. Run the installer and tick "Add python.exe to PATH".
  3. Click Install Now and complete the installation.
  4. Verify the installation by typing python --version in Command Prompt.

(On macOS, download the installer from python.org; most Linux systems already include Python 3.)

Installing an IDE:

  • Jupyter Notebook: install the Anaconda distribution, which includes Python and Jupyter, then launch Jupyter Notebook. Google Colab offers the same notebook online, with no installation.
  • PyCharm: download the free Community edition from JetBrains and select the installed Python interpreter.
  • VS Code: download it from Microsoft, install the Python extension and select the interpreter.

IDE (Integrated Development Environment): a software application that combines a code editor, tools to run programs, error checking and a debugger in one place.

Advantages of an IDE over a text editor:

  1. Syntax highlighting: code is coloured, making it easier to read.
  2. Auto-completion: suggests keywords and names while typing.
  3. Error detection: highlights mistakes before the program is run.
  4. Integrated execution: programs run with one click and the output appears in the same window.
  5. Debugging tools: breakpoints and step-by-step execution help find errors.
  6. Project management: organises multiple files and folders.
  7. Package management: libraries and extensions can be installed easily.
Q3

Explain variables and the basic data types in Python with pharmaceutical examples. Add a note on type casting.

Python में variables और basic data types को pharmacy के उदाहरणों के साथ समझाइए। Type casting पर भी note लिखिए।

हिन्दी में समझिए

Variable एक नाम वाला डिब्बा है जिसमें value रखी जाती है। चार data types हैं: int (पूरी संख्या), float (दशमलव वाली संख्या), str (text) और bool (True/False)। Type casting का मतलब है एक type को दूसरे में बदलना, जैसे int("500")।

▶Model answer देखें (English)

Variables: A variable is a named location in memory that stores a value. A value is assigned using =, for example weight_kg = 52.5. The value can be changed later by assigning a new value, and Python decides the data type automatically.

Basic data types:

  1. Integer (int): whole numbers without a decimal point. Example: tablets_per_strip = 10
  2. Float (float): numbers with a decimal point. Example: weight_kg = 52.5
  3. String (str): a sequence of characters in quotes. Example: drug_name = "Paracetamol"
  4. Boolean (bool): only two values, True or False. Example: prescription_verified = True

The function type() returns the data type of a value:

print(type(10))            # <class 'int'>
print(type(52.5))          # <class 'float'>
print(type("Paracetamol")) # <class 'str'>
print(type(True))          # <class 'bool'>

Type casting (type conversion): changing a value from one data type to another.

  • Implicit conversion: Python converts automatically, e.g. 10 + 2.5 gives 12.5 (int becomes float).
  • Explicit conversion: the programmer converts using int(), float(), str() and bool().
dose = int("500")        # str to int: 500
weight = float("52.5")   # str to float: 52.5
label = str(250) + " mg" # int to str: "250 mg"

int() removes the decimal part: int(52.9) gives 52. Converting text that is not a number, such as int("abc"), causes a ValueError.

Rules for naming variables: letters, digits and underscore only; must not start with a digit; no spaces; case-sensitive; keywords such as if and True cannot be used.

Q4

Explain the different types of operators in Python with suitable examples.

Python में अलग-अलग प्रकार के operators उदाहरणों के साथ समझाइए।

हिन्दी में समझिए

Operators वो symbols हैं जो values पर काम करते हैं। Arithmetic (+, -, *, /, //, %, **), comparison (==, >, <), logical (and, or, not) और assignment (=, +=) सबसे ज़रूरी हैं। Table बनाकर लिखिए और अंत में dose calculation का छोटा program दीजिए।

▶Model answer देखें (English)

An operator is a symbol that performs an operation on values (called operands).

1. Arithmetic operators

OperatorMeaningExampleResult
+Addition500 + 250750
-Subtraction30 - 1218
*Multiplication500 * 31500
/Division (always float)10 / 42.5
//Floor division10 // 42
%Modulus (remainder)10 % 42
**Exponent (power)2 ** 38

2. Comparison (relational) operators: compare two values and give True or False: ==, !=, >, <, >=, <=. Example: dose_mg > 4000 gives True if the dose exceeds 4000 mg.

3. Logical operators: combine conditions: and (both must be True), or (at least one True), not (reverses the result). Example: age >= 18 and weight_kg >= 50.

4. Assignment operators: store values: =, +=, -=, *=, /=. Example: stock = 100 then stock -= 10 makes stock equal to 90.

5. Membership operators: in and not in check whether a value is present. Example: "cin" in "Amoxicillin" gives True.

6. Identity operators: is and is not check whether two names refer to the same object.

Operator precedence: ** is evaluated first, then *, /, //, %, then + and -; brackets () override this order.

Example: daily dose calculation

weight_kg = 60
dose_per_kg = 15          # mg per kg
doses_per_day = 3
daily_dose = weight_kg * dose_per_kg * doses_per_day
print("Daily dose:", daily_dose, "mg")   # Daily dose: 2700 mg
print(daily_dose <= 4000)                # True
Q5

Explain the input() and print() functions in Python. Write a program to calculate the dose of a drug from the patient's body weight.

Python के input() और print() functions समझाइए। मरीज़ के वज़न से दवा की dose निकालने का program लिखिए।

10 marksयह सीखिए Lesson 1.5 · lesson जल्द आ रहा है

हिन्दी में समझिए

input() keyboard से value पढ़ता है, लेकिन हमेशा text (str) के रूप में, इसलिए calculation से पहले float() या int() लगाना ज़रूरी है। print() screen पर output दिखाता है; f-string से values text के अंदर आसानी से लिखी जाती हैं।

▶Model answer देखें (English)

input() function: reads a line typed by the user from the keyboard. It can display a message (prompt). It always returns a string, so the value must be converted using int() or float() before calculations.

name = input("Enter patient name: ")
weight = float(input("Enter weight in kg: "))

print() function: displays output on the screen.

  • Several items can be printed, separated by commas; a space is added between them.
  • sep changes the separator: print("A", "B", sep="-") gives A-B.
  • end changes what is printed at the end (a new line by default): print("Dose", end=": ").
  • f-strings insert values into text: print(f"Dose: {dose} mg").

Program: dose from body weight

# Dose calculation from body weight
name = input("Patient name: ")
weight_kg = float(input("Body weight (kg): "))
dose_per_kg = float(input("Dose (mg per kg): "))

dose_mg = weight_kg * dose_per_kg

print(f"Patient: {name}")
print(f"Dose: {dose_mg} mg")

Sample run:

Patient name: Ravi
Body weight (kg): 20
Dose (mg per kg): 15
Patient: Ravi
Dose: 300.0 mg

Explanation: input() reads the values as text, float() converts them to numbers, the dose is calculated with *, and print() with f-strings displays the result.

Q6

What is a string? Explain string indexing, slicing and common string operations with examples.

String क्या है? String indexing, slicing और common string operations उदाहरणों के साथ समझाइए।

10 marksयह सीखिए Lesson 1.6 · lesson जल्द आ रहा है

हिन्दी में समझिए

String यानी quotes के अंदर लिखा text। हर अक्षर की एक position (index) होती है जो 0 से शुरू होती है, और -1 आखिरी अक्षर है। Slicing [start:stop] से string का एक हिस्सा निकलता है; stop वाली position शामिल नहीं होती।

▶Model answer देखें (English)

String: a sequence of characters enclosed in single, double or triple quotes, e.g. drug = "Amoxicillin". Strings are immutable: their characters cannot be changed after creation.

Indexing: each character has a position (index) starting from 0. Negative indexes count from the end, starting at -1.

drug = "Aspirin"
print(drug[0])    # A
print(drug[3])    # i
print(drug[-1])   # n

Slicing: string[start:stop] returns characters from start up to, but not including, stop.

print(drug[0:3])  # Asp
print(drug[3:])   # irin
print(drug[:4])   # Aspi

Common operations:

  1. Concatenation (+): "Para" + "cetamol" gives "Paracetamol".
  2. Repetition (*): "-" * 10 gives ten dashes.
  3. Length: len("Insulin") gives 7.
  4. Membership: "cin" in "Amoxicillin" gives True.

Common string methods:

MethodExampleResult
upper()"aspirin".upper()ASPIRIN
lower()"ASPIRIN".lower()aspirin
strip()" insulin ".strip()insulin
replace()"500 mg".replace("mg", "MG")500 MG
split()"Paracetamol,500,mg".split(",")['Paracetamol', '500', 'mg']
find()"Aspirin".find("pi")2

Pharmaceutical use: cleaning drug names typed in different cases, reading values from labels and generating standard label text.

Q7

What are modules, packages and libraries in Python? Explain how to install and use them with pip, and name important libraries for pharmaceutical sciences.

Python में modules, packages और libraries क्या हैं? pip से इन्हें install और use करना समझाइए, और pharmacy के लिए ज़रूरी libraries के नाम लिखिए।

10 marksयह सीखिए Lesson 1.7 · lesson जल्द आ रहा है

हिन्दी में समझिए

Module एक .py file है, package कई modules का folder है, और library किसी काम के लिए बना बड़ा संग्रह है। pip से library install होती है (pip install pandas) और import से program में use होती है। Pharmacy के लिए NumPy, Pandas, Matplotlib और RDKit याद रखिए।

▶Model answer देखें (English)

Module: a single Python file (.py) containing functions and variables that can be reused, e.g. math, random.

Package: a collection of related modules organised in a folder.

Library: a collection of packages and modules for a particular purpose, e.g. NumPy for numerical work.

Importing:

import math
print(math.sqrt(16))          # 4.0

from math import pi
print(pi)                     # 3.141592653589793

import numpy as np            # np is a short alias

pip (package installer for Python): the standard tool to install third-party packages from PyPI (Python Package Index). It is run in the Command Prompt or terminal, not inside a Python program:

TaskCommand
Installpip install pandas
Install a specific versionpip install pandas==2.2.0
Upgradepip install --upgrade pandas
Uninstallpip uninstall pandas
List installed packagespip list

In Jupyter Notebook or Google Colab, prefix the command with !, e.g. !pip install rdkit.

Important libraries for pharmaceutical sciences:

  1. NumPy: fast numerical calculations and arrays.
  2. Pandas: reading and analysing tables of data (CSV, Excel), e.g. clinical trial data.
  3. Matplotlib: graphs such as concentration–time curves.
  4. SciPy: scientific calculations, curve fitting and statistics.
  5. scikit-learn: machine learning models.
  6. RDKit: cheminformatics, handling molecules and calculating descriptors.

Short answer questions (5 marks)

Q8

What is an interpreter? Explain how a Python program is executed.

Interpreter क्या है? Python program कैसे execute होता है, समझाइए।

हिन्दी में समझिए

Interpreter program को एक-एक line करके पढ़ता और चलाता है, ऊपर से नीचे तक। अगर किसी line में error है तो program वहीं रुक जाता है, लेकिन उससे पहले वाली lines चल चुकी होती हैं।

▶Model answer देखें (English)

An interpreter is a program that reads source code and executes it statement by statement. Python uses an interpreter, so it is called an interpreted language.

How a Python program runs:

  1. The programmer writes source code in a .py file.
  2. The Python interpreter reads the program line by line, from top to bottom.
  3. Internally, the code is converted into bytecode, which the Python Virtual Machine (PVM) executes.
  4. The output of each statement appears as it runs.
  5. If a line has an error, execution stops at that line and an error message is shown; the lines before it have already run.
Q9

Differentiate between a compiler and an interpreter.

Compiler और interpreter में अंतर बताइए।

हिन्दी में समझिए

Compiler पूरे program को पहले एक साथ translate करता है, interpreter एक-एक statement चलाता है। Exam में यह answer table के रूप में लिखिए, और Python को interpreter वाले column में example के तौर पर ज़रूर लिखिए।

▶Model answer देखें (English)
CompilerInterpreter
Translates the whole program into machine code before running it.Translates and executes the program statement by statement.
Errors are reported after the whole program is checked.Execution stops at the first error.
Produces a separate executable file.No separate executable file is produced.
The compiled program usually runs faster.Usually slower, but easier to test and correct.
Examples: C, C++.Examples: Python, JavaScript.
Q10

What is an IDE? Compare Jupyter Notebook, PyCharm and VS Code.

IDE क्या है? Jupyter Notebook, PyCharm और VS Code की तुलना कीजिए।

हिन्दी में समझिए

IDE एक software है जिसमें code लिखना, चलाना और गलती ढूँढना, सब एक ही जगह होता है। Jupyter में code cells में चलता है और data analysis के लिए अच्छा है; PyCharm बड़े projects के लिए, और VS Code कई भाषाओं के लिए।

▶Model answer देखें (English)

An IDE (Integrated Development Environment) is a software application that combines a code editor, tools to run programs, error checking and a debugger in one place.

Jupyter NotebookPyCharmVS Code
TypeWeb-based notebookFull IDE for PythonLight code editor with extensions
Code runs inSeparate cellsWhole filesWhole files (notebooks via extension)
Best forData analysis, graphs, teachingLarge Python projectsMany languages, general use
Get it fromAnaconda or Google ColabJetBrains (free Community edition)Microsoft (free)
Q11

State the rules for naming variables in Python with valid and invalid examples.

Python में variables के नाम रखने के नियम valid और invalid उदाहरणों के साथ लिखिए।

हिन्दी में समझिए

नाम में सिर्फ अक्षर, अंक और underscore हो सकते हैं; अंक से शुरू नहीं हो सकता; space नहीं; और if, for जैसे keywords नहीं। एक table में valid और invalid नाम कारण के साथ लिखेंगे तो answer साफ़ दिखेगा।

▶Model answer देखें (English)
  1. Names may contain letters, digits and underscores (_) only.
  2. A name must not begin with a digit.
  3. Spaces and special characters such as -, @ and % are not allowed.
  4. Names are case-sensitive: dose and Dose are different variables.
  5. Keywords such as if, for, True and class cannot be used as names.
  6. Names should be meaningful, e.g. patient_weight_kg rather than x.
ValidInvalidReason
dose_mgdose-mg- not allowed
drug22drugstarts with a digit
_countdrug namecontains a space
Weightforkeyword
Q12

What is type casting? Explain implicit and explicit type conversion with examples.

Type casting क्या है? Implicit और explicit type conversion उदाहरणों के साथ समझाइए।

हिन्दी में समझिए

Implicit conversion Python खुद करता है, जैसे 10 + 2.5 का answer 12.5 (float)। Explicit conversion हम करते हैं, जैसे int("30") या str(500)। यह ज़रूरी है क्योंकि input() हमेशा text देता है।

▶Model answer देखें (English)

Type casting means converting a value from one data type to another.

1. Implicit conversion: done automatically by Python, usually to avoid losing information.

total = 10 + 2.5     # int + float
print(total)         # 12.5 (float)

2. Explicit conversion: done by the programmer using int(), float(), str() and bool().

tablets = int("30")         # "30" to 30
weight = float("52.5")      # "52.5" to 52.5
label = str(500) + " mg"    # 500 to "500 mg"
print(int(7.9))             # 7 (decimal part removed)

Explicit conversion is needed because input() always returns a string. Converting non-numeric text, e.g. int("ten"), raises a ValueError.

Q13

Explain operator precedence in Python with an example.

Python में operator precedence उदाहरण के साथ समझाइए।

हिन्दी में समझिए

Precedence यानी कौन सा operator पहले चलेगा। पहले brackets, फिर ** , फिर *, /, //, %, और आखिर में + और -। जैसे 10 + 5 * 2 का answer 20 है, क्योंकि गुणा पहले होता है।

▶Model answer देखें (English)

Operator precedence is the order in which Python evaluates operators in an expression.

Order (highest to lowest):

  1. () brackets
  2. ** exponent
  3. *, /, //, %
  4. +, -
  5. Comparison operators: ==, !=, >, <, >=, <=
  6. not, then and, then or

Operators of the same level are evaluated from left to right (except **, which is evaluated from right to left).

Example:

print(10 + 5 * 2)      # 20  (5 * 2 first)
print((10 + 5) * 2)    # 30  (brackets first)
print(2 ** 3 * 2)      # 16  (2 ** 3 first)
print(100 - 20 / 4)    # 95.0

Using brackets makes calculations such as dose formulas clear and avoids mistakes.

Q14

Differentiate between / and //, and between = and == in Python.

/ और // में, तथा = और == में अंतर बताइए।

हिन्दी में समझिए

/ पूरा exact भाग देता है (10 / 4 = 2.5), जबकि // नीचे की पूरी संख्या देता है (10 // 4 = 2)। = value रखता है (dose = 500), और == दो values की बराबरी check करता है और True या False देता है।

▶Model answer देखें (English)

/ and //:

/ (division)// (floor division)
Gives the exact resultGives the result rounded down to a whole number
Result is always a floatResult is an int when both values are int
10 / 4 gives 2.510 // 4 gives 2

Example: number of full strips from 25 tablets with 10 per strip: 25 // 10 gives 2.

= and ==:

= (assignment)== (comparison)
Stores a value in a variableChecks whether two values are equal
dose = 500dose == 500
Does not produce a resultProduces True or False
Q15

Write a Python program to read a patient's body weight and calculate the single dose of paracetamol at 15 mg/kg.

मरीज़ का body weight पढ़कर 15 mg/kg के हिसाब से paracetamol की single dose निकालने का Python program लिखिए।

5 marksयह सीखिए Lesson 1.5 · lesson जल्द आ रहा है

हिन्दी में समझिए

Program में तीन काम हैं: input() से वज़न पढ़ना और float() से number बनाना, वज़न को 15 से गुणा करना, और print() से result दिखाना। Exam में program के साथ sample output और explanation भी लिखिए।

▶Model answer देखें (English)
# Paracetamol dose at 15 mg per kg
weight_kg = float(input("Enter body weight (kg): "))
dose_mg = weight_kg * 15
print(f"Single dose of paracetamol: {dose_mg} mg")

Sample output:

Enter body weight (kg): 20
Single dose of paracetamol: 300.0 mg

Explanation:

  1. input() reads the weight as a string.
  2. float() converts it to a number with a decimal point.
  3. The dose is calculated by multiplying weight by 15.
  4. print() with an f-string displays the result.
Q16

Explain string indexing and slicing in Python with examples.

Python में string indexing और slicing उदाहरणों के साथ समझाइए।

5 marksयह सीखिए Lesson 1.6 · lesson जल्द आ रहा है

हिन्दी में समझिए

Index 0 से शुरू होता है: "Insulin" में I का index 0 है और आखिरी n का index -1। Slicing [0:3] से "Ins" मिलता है, क्योंकि stop वाली position (3) शामिल नहीं होती।

▶Model answer देखें (English)

Indexing: every character in a string has a position number (index). The first character has index 0; negative indexes count from the end, starting at -1.

drug = "Insulin"
print(drug[0])    # I
print(drug[2])    # s
print(drug[-1])   # n

Slicing: string[start:stop] returns the characters from start up to, but not including, stop. If start is left out, slicing begins at 0; if stop is left out, it goes to the end.

print(drug[0:3])  # Ins
print(drug[3:])   # ulin
print(drug[:2])   # In
print(drug[-3:])  # lin

Using an index outside the string, e.g. drug[10], causes an IndexError.

Q17

What are comments in Python? Why are they used? Give examples.

Python में comments क्या हैं? इनका उपयोग क्यों होता है? उदाहरण दीजिए।

हिन्दी में समझिए

Comment # से शुरू होता है और यह इंसानों के लिए note है; Python इसे चलाते समय छोड़ देता है। Comments से program समझना आसान होता है, और units (mg, kg) जैसी जानकारी लिखी जा सकती है।

▶Model answer देखें (English)

Comments are notes written in a program for humans to read. Python ignores them while running the program.

Single-line comment: starts with #.

# Calculate the daily dose
daily_dose = 500 * 3   # 500 mg three times a day

Multi-line comments: each line starts with #. A triple-quoted string (""" ... """) is also commonly used to write longer notes, such as a description at the top of a program.

Uses of comments:

  1. Explain what the code does and why.
  2. Make programs easier to read and maintain.
  3. Temporarily disable a line while testing.
  4. Record details such as the author, date and units (mg, kg).
Q18

What is pip? Explain the commands to install, upgrade, uninstall and list packages.

pip क्या है? Package install, upgrade, uninstall और list करने के commands समझाइए।

5 marksयह सीखिए Lesson 1.7 · lesson जल्द आ रहा है

हिन्दी में समझिए

pip Python के साथ आने वाला tool है जो internet (PyPI) से libraries install करता है। Commands Command Prompt में चलते हैं, Python program के अंदर नहीं। Colab या Jupyter में command के आगे ! लगाते हैं।

▶Model answer देखें (English)

pip (package installer for Python) is the standard tool used to download and install third-party packages from the Python Package Index (PyPI). It is included with Python 3 and is run in the Command Prompt or terminal.

TaskCommand
Install a packagepip install numpy
Install a specific versionpip install numpy==1.26.4
Upgrade a packagepip install --upgrade numpy
Uninstall a packagepip uninstall numpy
List installed packagespip list
Show details of a packagepip show numpy

In Jupyter Notebook or Google Colab, add ! before the command, e.g. !pip install pandas. After installing, the package is used in a program with import, e.g. import numpy as np.

Q19

Explain formatted output in Python using f-strings, sep and end, with examples.

f-strings, sep और end का उपयोग करके Python में formatted output उदाहरणों के साथ समझाइए।

5 marksयह सीखिए Lesson 1.5 · lesson जल्द आ रहा है

हिन्दी में समझिए

f-string में quotes से पहले f लगाते हैं और {} के अंदर variable लिखते हैं, जैसे f"Dose: {dose} mg"। sep items के बीच का निशान बदलता है, और end line के आखिर में क्या छपेगा, वो बदलता है।

▶Model answer देखें (English)

f-strings: a string with f before the quotes; values inside {} are inserted into the text.

drug = "Amoxicillin"
dose = 500
print(f"{drug}: {dose} mg")      # Amoxicillin: 500 mg
print(f"Daily: {dose * 3} mg")   # Daily: 1500 mg
print(f"{2/3:.2f}")              # 0.67 (two decimal places)

sep: sets the separator between items (a space by default).

print("12", "05", "2026", sep="/")   # 12/05/2026

end: sets what is printed at the end (a new line by default).

print("Dose", end=": ")
print("500 mg")                      # Dose: 500 mg

Formatted output is used to print clear labels, reports and prescriptions.

Multiple choice questions (1 marks)

1.Python was created by:

Python किसने बनाई?

  1. A.Dennis Ritchie
  2. B.Guido van Rossum
  3. C.James Gosling
  4. D.Bjarne Stroustrup
Answer देखें

Answer: B. Guido van RossumGuido van Rossum ने Python बनाई और 1991 में release की।

2.Python is an example of a/an:

Python किस प्रकार की भाषा है?

  1. A.Interpreted language
  2. B.Compiled-only language
  3. C.Assembly language
  4. D.Machine language
Answer देखें

Answer: A. Interpreted languagePython interpreter से एक-एक statement चलता है, इसलिए यह interpreted language है।

3.Which symbol starts a single-line comment in Python?

Python में single-line comment किस symbol से शुरू होता है?

  1. A.//
  2. B./*
  3. C.--
  4. D.#
Answer देखें

Answer: D. ## के बाद लिखा सब Python छोड़ देता है।

4.Which tool runs Python code in separate cells?

कौन सा tool Python code को अलग-अलग cells में चलाता है?

  1. A.Notepad
  2. B.Command Prompt
  3. C.Jupyter Notebook
  4. D.MS Word
Answer देखें

Answer: C. Jupyter NotebookJupyter Notebook (और Google Colab) में code cells में चलता है और output हर cell के नीचे दिखता है।

5.IDE stands for:

IDE का full form क्या है?

  1. A.Internal Data Editor
  2. B.Integrated Development Environment
  3. C.Interactive Design Engine
  4. D.Integrated Debugging Editor
Answer देखें

Answer: B. Integrated Development EnvironmentIntegrated Development Environment: लिखना, चलाना, गलती ढूँढना, सब एक जगह।

6.What is the output of type(52.5)?

type(52.5) का output क्या होगा?

  1. A.<class 'float'>
  2. B.<class 'int'>
  3. C.<class 'str'>
  4. D.<class 'bool'>
Answer देखें

Answer: A. <class 'float'>दशमलव वाली संख्या float होती है।

7.Which of these is a valid variable name?

इनमें से कौन सा variable name सही है?

  1. A.2dose
  2. B.dose-mg
  3. C.for
  4. D.dose_mg
Answer देखें

Answer: D. dose_mgनाम अंक से शुरू नहीं हो सकता, - नहीं हो सकता, और for एक keyword है।

8.Which of these is a Boolean value?

इनमें से Boolean value कौन सी है?

  1. A."True"
  2. B.1.0
  3. C.True
  4. D.'yes'
Answer देखें

Answer: C. TrueTrue बिना quotes के Boolean है; quotes में "True" एक string है।

9.What is the result of 7 // 2?

7 // 2 का result क्या है?

  1. A.3.5
  2. B.3
  3. C.4
  4. D.1
Answer देखें

Answer: B. 3// नीचे की पूरी संख्या देता है: 3।

10.What is the result of 7 % 2?

7 % 2 का result क्या है?

  1. A.1
  2. B.3
  3. C.3.5
  4. D.0
Answer देखें

Answer: A. 1% शेषफल (remainder) देता है: 7 को 2 से भाग देने पर 1 बचता है।

11.What is the result of 2 ** 3?

2 ** 3 का result क्या है?

  1. A.6
  2. B.5
  3. C.9
  4. D.8
Answer देखें

Answer: D. 8** घात (power) है: 2 × 2 × 2 = 8।

12.What is the result of 10 / 4?

10 / 4 का result क्या है?

  1. A.2
  2. B.2.0
  3. C.2.5
  4. D.3
Answer देखें

Answer: C. 2.5/ हमेशा exact answer float में देता है: 2.5।

13.What is the result of int("500") + 5?

int("500") + 5 का result क्या है?

  1. A."5005"
  2. B.505
  3. C.Error
  4. D.500
Answer देखें

Answer: B. 505int("500") text को number 500 में बदलता है, इसलिए जोड़ 505 है।

14.Which operator checks whether two values are equal?

कौन सा operator check करता है कि दो values बराबर हैं?

  1. A.==
  2. B.=
  3. C.!=
  4. D.=>
Answer देखें

Answer: A. ==== तुलना करता है; = value रखता है।

15.The input() function always returns a value of type:

input() function हमेशा किस type की value देता है?

  1. A.int
  2. B.float
  3. C.bool
  4. D.str
Answer देखें

Answer: D. strinput() हमेशा text (str) देता है, इसलिए calculation के लिए int() या float() लगाना पड़ता है।

16.What is the output of print("A", "B", sep="-")?

print("A", "B", sep="-") का output क्या होगा?

  1. A.A B
  2. B.AB
  3. C.A-B
  4. D.A,B
Answer देखें

Answer: C. A-Bsep items के बीच का निशान तय करता है, इसलिए A-B छपेगा।

17.If drug = "Aspirin", what is drug[-1]?

अगर drug = "Aspirin" है, तो drug[-1] क्या होगा?

  1. A.A
  2. B.n
  3. C.i
  4. D.Error
Answer देखें

Answer: B. n-1 आखिरी अक्षर है: n।

18.What is the output of len("Insulin")?

len("Insulin") का output क्या है?

  1. A.7
  2. B.6
  3. C.8
  4. D.5
Answer देखें

Answer: A. 7"Insulin" में 7 अक्षर हैं।

19.What is the result of "Dose" * 2?

"Dose" * 2 का result क्या है?

  1. A.Dose2
  2. B.Error
  3. C.Dose Dose
  4. D.DoseDose
Answer देखें

Answer: D. DoseDose* string को उतनी बार दोहराता है: DoseDose।

20.Which command installs the pandas library?

pandas library install करने का command कौन सा है?

  1. A.python install pandas
  2. B.import pandas
  3. C.pip install pandas
  4. D.install pandas
Answer देखें

Answer: C. pip install pandaspip install package को install करता है; import सिर्फ पहले से installed package को load करता है।

Updated 2026-10-28