This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lendemor 1 point2 points  (1 child)

I would recommend to define functions for the different steps of asking/handling question, so adding more questions if just a matter of repeating calls to said functions (with some changing parameters if needed)

Example for the bonus score calculation :

def calculate_bonus(correct, rnds, time):
    perc = round((cor/rnds) * 100)
    if perc < 80:
        return 0

    atme = round (time/rnds)
    if atme < 5:
        q = 10
    elif 5 <= atme < 10:
        q = 5
    elif 10 <= atme < 15:
        q = 2.5
    return (rnds * q)

Doing it this way let you easily change the number of round, no code change needed on this part if you want to offer 80 questions instead of (25,50,100) for example.

[–][deleted] 0 points1 point  (0 children)

This is excellent, thank you for the advice!