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 ಆಗಿ ಬರೆಯಿರಿ: ಬಣ್ಣದ code, auto-completion, ತಪ್ಪುಗಳು ಮೊದಲೇ ಕಾಣುವುದು.

▶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 ಅಂದ್ರೆ values ಮೇಲೆ ಕೆಲಸ ಮಾಡುವ symbols. 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 ಓದಿ run ಮಾಡುತ್ತೆ, ಮೇಲಿಂದ ಕೆಳಗೆ. ಯಾವುದಾದರೂ line ನಲ್ಲಿ error ಇದ್ದರೆ program ಅಲ್ಲೇ ನಿಲ್ಲುತ್ತೆ, ಆದರೆ ಅದರ ಮೊದಲಿನ lines ಆಗಲೇ run ಆಗಿರುತ್ತವೆ.

▶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 run ಮಾಡುತ್ತೆ. Exam ನಲ್ಲಿ ಈ answer ಅನ್ನು table ರೂಪದಲ್ಲಿ ಬರೆಯಿರಿ, interpreter column ನಲ್ಲಿ Python ಅನ್ನು 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 ಅಂದ್ರೆ code ಬರೆಯುವುದು, run ಮಾಡುವುದು, ತಪ್ಪು ಹುಡುಕುವುದು ಎಲ್ಲಾ ಒಂದೇ ಕಡೆ ಇರುವ software. Jupyter ನಲ್ಲಿ code cells ನಲ್ಲಿ run ಆಗುತ್ತೆ, 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 ಬಳಸಬಾರದು. Valid ಮತ್ತು invalid ಹೆಸರುಗಳನ್ನು ಕಾರಣದೊಂದಿಗೆ table ನಲ್ಲಿ ಬರೆದರೆ 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 ಉತ್ತರ 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 ಉತ್ತರ 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 run ಮಾಡುವಾಗ ಅದನ್ನು skip ಮಾಡುತ್ತೆ. 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 ನಲ್ಲಿ run ಆಗುತ್ತವೆ, 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 ಕೊನೆಯಲ್ಲಿ ಏನು print ಆಗಬೇಕು ಅನ್ನೋದನ್ನು ಬದಲಾಯಿಸುತ್ತೆ.

▶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 run ಮಾಡುತ್ತೆ, ಅದಕ್ಕೇ ಇದು 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 skip ಮಾಡುತ್ತೆ.

4.Which tool runs Python code in separate cells?

ಯಾವ tool Python code ಅನ್ನು ಬೇರೆ ಬೇರೆ cells ನಲ್ಲಿ run ಮಾಡುತ್ತೆ?

  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 ನಲ್ಲಿ run ಆಗಿ, 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: ಬರೆಯುವುದು, run ಮಾಡುವುದು, ತಪ್ಪು ಹುಡುಕುವುದು ಎಲ್ಲಾ ಒಂದೇ ಕಡೆ.

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. Truequotes ಇಲ್ಲದ True 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?

ಎರಡು values ಸಮವೇ ಅಂತ ಯಾವ operator check ಮಾಡುತ್ತೆ?

  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 print ಆಗುತ್ತೆ.

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 ಈಗಾಗಲೇ install ಆಗಿರುವ package ಅನ್ನು ಮಾತ್ರ load ಮಾಡುತ್ತೆ.

Updated 2026-10-28