April 24, 2026

Input & Output in Python (with Patient Data Entry & Reports)

Input & Output in Python for Pharmacy Students (Patient Data Entry & Report Generation)

Input and Output (I/O) operations are fundamental in Python programming. In pharmaceutical applications, they are used to collect patient data, process clinical information, and generate reports.


๐Ÿ”ท What is Input in Python?

Input allows users to enter data into a program using the input() function.

name = input("Enter patient name: ")
๐Ÿ’ก Key Insight: input() always takes data as string by default.

๐Ÿ”ท Converting Input Data

Since input() returns string, we need type conversion for calculations.

age = int(input("Enter age: "))
weight = float(input("Enter weight: "))

๐Ÿ”ท What is Output in Python?

Output is displayed using the print() function.

print("Patient Name:", name)

๐Ÿ”ท Formatting Output

Formatted output improves readability.

print(f"Patient {name} is {age} years old")

๐Ÿ’Š Patient Data Entry Example

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

total_dose = weight * dose_per_kg

print(f"Total dose for {name} is {total_dose} mg")

๐Ÿ’Š Simple Patient Report

name = input("Enter patient name: ")
age = int(input("Enter age: "))
drug = input("Enter drug name: ")

print("----- Patient Report -----")
print("Name:", name)
print("Age:", age)
print("Drug:", drug)

๐Ÿง  Memory Tricks

  • input() โ†’ Takes data
  • print() โ†’ Displays data
  • int() / float() โ†’ Converts data

๐Ÿงช Practice Exercise

Create a program that:

  • Takes patient weight
  • Calculates dose (5 mg/kg)
  • Prints result

๐Ÿ“ MCQs

  1. input() returns:
    a) int
    b) float
    c) string
    d) bool
    Answer: c

  2. Which function displays output?
    a) input()
    b) print()
    c) show()
    d) display()
    Answer: b

  3. Which function converts string to integer?
    a) str()
    b) int()
    c) float()
    d) bool()
    Answer: b

โ“ FAQs

Why is type conversion required?

Because input() takes data as string, conversion is needed for calculations.

Where is input-output used in pharmacy?

In patient data entry, clinical reports, and data processing systems.


๐Ÿ“ฅ Download Patient Data Practice Exercises

Includes real-world pharma scenarios.


โžก Next Topic: String Manipulation in Python โ†’

Unit 1 Blog Series:

  1. Installing Python
  2. Installing IDEs like Jupyter, VS Code, PyCharm
  3. Variables and Data types in Python
  4. Operators in Python
  5. Input & Output (You are on this page page)
  6. String Manipulation
  7. Libraries in Python

Question Bank : Unit 1 Python Programming Basics

For more details: Basics of Python Programming for Pharmaceutical Sciences (Theory)