As a general rule you should always have at least 2 tests, one hidden from the students. So, for example, you ask students to write a function sum_series(first, last) to compute the sum of a series from a given start to a given end point. Or you get them to use an input() function to read the first and last values.
If you've already asked your question in an exam and are trying to recover, then you'll have to decide how many marks you wish to give the print(5050) answer. Then you have several options:
- Download all the quiz responses in Moodle (Results > Responses) and search for the ones you want to change. Update them manually.
- Customise the template so that it prints a message if there's no plausible looking for or while loop. Regrade. That will give all those students zero.
- Switch to a template grader and write code that analyses the source code submitted and allocates an appropriate grade. This option is for CodeRunner experts, though.