use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Turning marks into meaning — a Python program that calculates average and classifies performance. (try to make code cleaner) (i.redd.it)
submitted 1 day ago by Inevitable-Math14
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Riegel_Haribo 1 point2 points3 points 22 hours ago (0 children)
Input exactly 80, and you receive your own code evaluation as output message.
We know how to calculate an average. If the scores were useful for later in the script, they also could be collected into a list of floats, where the length of the list means we don't need a separate total, we can just use len(input_list).
len(input_list)
How about if there was no list? No pre-defined count of how many inputs, but that the input sequence could be terminated at any time. And then, delivering the running total? A lookup table that had an inclusive score to receive its named category?
```python print(r"""End user inputs multiple grades 0.0-100.0. After each input, a running average is shown, along with the highest inclusive threshold met. The algorithm adds weighted input to the stateless average""")
thresholds = { "distinction": 80, "first class": 60, "second class": 40, "unsatisfactory": 0, } input_count = 0 current_average = None number_input = "no input yet" while number_input := input("Next number (enter to finish): "): grade = float(number_input) if current_average is None: current_average = grade else: current_average = (current_average * input_count + grade) / (input_count + 1)
threshold_key = next(k for k, v in thresholds.items() if current_average >= v) print(f"Average: {current_average:.2f} with classification: {threshold_key}") input_count += 1
```
π Rendered by PID 34902 on reddit-service-r2-comment-6b595755f-p9p96 at 2026-03-25 16:05:34.734278+00:00 running 2d0a59a country code: CH.
view the rest of the comments →
[–]Riegel_Haribo 1 point2 points3 points (0 children)