Key Concepts in Python
Key Concepts in Python
3. Functions
o Explanation: Reusable blocks of code that perform a specific task, defined
with def.
o Real-World Example: A function to calculate BMI:
4. Data Structures
o Explanation: Tools to organize and store data, including lists, tuples,
dictionaries, and sets.
o Real-World Example: Storing patient data in a dictionary:
5. File Handling
o Explanation: Reading from and writing to files using Python's built-in open()
function.
o Real-World Example: Logging patient data to a file:
import pandas as pd
data = pd.read_csv("health_data.csv")
print(data.describe())
class Patient:
def __init__(self, name, age, bmi):
self.name = name
self.age = age
self.bmi = bmi
try:
weight = float(input("Enter weight: "))
except ValueError:
print("Invalid input. Please enter a number.")