In [1]:
#Using len() with a List of Integers
numbers = [10, 20, 30, 40, 50]
print(len(numbers))
5
In [2]:
#Using len() with a List of Strings
fruits = ["apple", "banana", "cherry", "date"]
print(len(fruits))
4
In [3]:
#Using len() with a Dictionary
student_scores = {"Alice": 95, "Bob": 87, "Eve": 91}
print(len(student_scores))
3
In [4]:
#Using len() with Healthcare Data
patients = [
{"name": "John Doe", "age": 30, "condition": "Hypertension"},
{"name": "Jane Smith", "age": 25, "condition": "Diabetes"},
{"name": "Emily Davis", "age": 40, "condition": "Asthma"}
]
print(len(patients))
print(len(patients[0]))
3 3