#EXAM GRADER [5]
from commonFunctions import float_input

repeating = True
while repeating:
    gettingData = True
    while gettingData:
        while True:
            examScore = float_input("Please enter the exam score between 0 and 100: ")      
            if examScore >= 0 and examScore <= 100:
                break

        print("You selected an exam score of {}.".format(examScore))
        while True:
            isInformationCorrect = input("Is the above information correct. Enter Y/N: ").lower()
            if isInformationCorrect == "y":
                gettingData = False
                break
            elif isInformationCorrect == "n":
                break
            else:
                print("Enter Y/N.")
                print()

    if examScore >= 80:
        print("Grade A.")
    elif examScore >= 70 and examScore < 80:
        print("Grade B")
    elif examScore >= 55 and examScore < 70:
        print("Grade C")
    elif examScore < 54:
Example #2
0
#TenNumbers
from commonFunctions import float_input

def mode(array):
    most = max(list(map(array.count, array)))
    return list(set(filter(lambda x: array.count(x) == most, array)))

repeating = True
while repeating:
    numbers = []
    for i in range(10):
        numbers.append(None)
        while True:
            numbers[i] = float_input("Please enter number {}: ".format(i+1))
            if numbers[i] >= 0:
                break
            
    total = 0
    for i in range(10):
        total += numbers[i]

    numbersSorted = sorted(numbers)
    mean = total /10
    median = (numbersSorted[4] + numbersSorted[5])/2
    mode = mode(numbers)
    theRange = numbersSorted[9] - numbersSorted[0]

    print("The total is {}.".format(total))
    print("The mean is {}.".format(mean))
    print("The median is {}.".format(median))
    print("The mode is {}.".format(mode))
#TIMES TABLE GENERATOR [2]
from commonFunctions import float_input
from random import randint

repeating = True
while repeating:
    gettingData = True
    while gettingData:
        timesTable = float_input("Please enter the times table you want: ")

        print("You selected the {} times table.".format(timesTable))
        while True:
            inputRight = input("Enter Y/N: ").lower()
            if inputRight == "y":
                gettingData = False
                break
            elif inputRight == "n":
                break
        
    for i in range(20):
        total = (i+1) * timesTable
        print("{} * {} = {}".format(i+1, timesTable, total))

    print()
    while True:
        userRepeat = input("Do you want to repeat? \nEnter Y/N: ").lower()
        if userRepeat == "y":
            break
        elif userRepeat == "n":
            repeating = False
            break