Complete the code to create a structured array with fields 'name' and 'age'.
import numpy as np people = np.array([('Alice', 25), ('Bob', 30)], dtype=[1])
The dtype defines the structure with a string field 'name' of length 10 and an integer field 'age'.
Complete the code to access the 'age' field from the structured array.
ages = people[1]Accessing a field in a structured array is done by indexing with the field name as a string.
Fix the error in the code to filter people older than 27.
older = people[people['age'] [1] 27]
To filter people older than 27, use the greater than operator >.
Fill both blanks to create a dictionary comprehension mapping names to ages for people younger than 30.
young_dict = {person[1]: person[2] for person in people if person['age'] < 30}Use indexing with field names to access 'name' and 'age' fields in each person.
Fill all three blanks to create a new structured array with uppercase names and ages increased by 1.
new_people = np.array([(person[1].upper(), person[2] + [3]) for person in people], dtype=people.dtype)
Access 'name' and 'age' fields with square brackets, convert name to uppercase, and add 1 to age.