I want to change multiple array values from numeric to strings based on the condition that values greater than 70 will become 'P' while values less than 70 will become 'F'. For example: [20,80,30,100] should become ['F','P','F','P'] and [50,60,90,45] should become ['F','F','P','F'].
Current code:
def grade(input_array):
a = len(input_array)>70
return 'P','F'
grade([50,85,60,100])
Current output:
('P', 'F')
==70?res = ['F' if x < 70 else 'P' for x in arr]gradefunction can just be:return np.where(input_array < 70, 'F', 'P')(Assuming that the result for exactly 70 should be P)Numpy .whereapproach as also suggested.