Skip to content

Professor Prick Problem

You’re a vindictive professor 👨‍🏫 and one of your pet peeves is when students rush through their exams. To teach them a lesson, you decide to give zeros to the first three students who score less than sixty, in the order they turned in their exams.

Given a 1-d array of integers, identify the first three values less than sixty and replace them with zero.

import numpy as np

generator = np.random.default_rng(80085)
scores = np.round(generator.uniform(low=30, high=100, size=15))

# [68. 36. 76. 57. 56. 54. 63. 64. 36. 88. 80. 82. 84. 76. 42.]

Try with Google Colab See the solution