User input scores of subjects and I need to check if these scores are valid (0->10, step is 0.1 because for exp: 5.25 or 5.1 is acceptable). Below is my code:
def Task_22():
    mathematics = float(input("Input mathematics score: "))
    literature  = float(input("Input literature score: "))
    english     = float(input("Input english score: "))
    # check valid score
    if all(i in range(0,11) for i in [mathematics, literature, english]):
        print("OK")
    else: print("NOK")

but when input as below, the result is not as my expected:
Input mathematics score: 2
Input literature score: 5
Input english score: 7.25
NOK


Check in range of multiple float variables
The range() function lets you create an iterator so you can loop over some integers. When you use i in range(0, 11), you're essentially asking "will range(0, 11) eventually iterate over i", not "is i within the upper and lower bounds of range(0, 11)". Because range() only works with integers, a float will be iterator over by range, and thus a float will never be in a range.
What you really want to do is check if the number is greater or equal to a lower bound and less than or equal to an upper bound, using operators like >= and <=.
def Task_22():
    mathematics = float(input("Input mathematics score: "))
    literature  = float(input("Input literature score: "))
    english     = float(input("Input english score: "))
    # check valid score
    if all(0 <= i <= 10 for i in [mathematics, literature, english]):
        print("OK")
    else: print("NOK")

