Data Structures and File Handling-BPPS Notes

Class Notes · Free · 36 pages · Basics of Python Programming for Pharmaceutical Sciences · Topic: Data Structures and File Handling

Preview

Data Structures and File Handling-BPPS Notes — page 1Data Structures and File Handling-BPPS Notes — page 2

Summary

These notes cover all of Unit III: Data Structures and File Handling, written for first-year B.Pharm students and following on from Units I and II. They explain lists, tuples and dictionaries with their syntax, properties and operations, using medicine records as examples. Next they cover string manipulation for cleaning messy data. Then they introduce NumPy arrays: creating them, doing arithmetic and simple statistics. The unit ends with structured data and reading and writing CSV files, using the practice dataset drugs.csv. Every example can be run in the free Pharmakaksha Python Lab or Google Colab. The notes have comparison tables, code panels with output, worked programs, 30 MCQs with an answer key, 20 short-answer questions and 4 long-answer questions with answer plans.

Key points

  • Lists: Creating, indexing, slicing and changing lists, common list methods like append, insert and remove, and looping over a list of medicines.
  • Tuples and dictionaries: Tuples as fixed records and dictionaries as key : value pairs for drug details, with a four-column comparison of lists, tuples and dictionaries.
  • String manipulation for data cleaning: strip(), lower(), upper(), replace() and split() to clean messy medicine names and text before analysis.
  • NumPy arrays: Creating arrays, array arithmetic and simple statistics (mean, max, min), and why arrays are faster and easier than lists for numbers like doses and concentrations.
  • CSV files and healthcare data: What structured data is, reading and writing CSV files with the csv module, and a worked program that reads a medicine dataset and finds averages.

Log in or create a free account to read the full note. More in Notes and the Study Library.