View on GitHub

curly-knife

the curliest knife in the cupboard

Home Create Python TPT

Riya Create Task: Typing Game Tester!!!!

Video

Raw Code

Written Response:

3a: Our world is getting increasingly digitalized, and almost everyone has to use their computers for communication, work, research, etc. By having fast and accurate typing, users can use computers more efficiently. Thus, this program provides feedback on the user’s typing ability by having the user type a given phrase and scoring them based on either the time taken or accuracy. In the video, the user chooses to test their typing accuracy and then their speed. A random quote is provided to them, and they type it the best they can. When they hit enter to check, the program provides the correct score and error score percentages and the words missed. The program’s input is the user choosing either the time or accuracy mode and their typed-out entry. The program’s output is the scoring of the user’s ability; it displays the users’ accuracy percentages or the words per minute.

3b: (i)

def splitStringsIntoList(userString):

 .....

    # get the global list of words in user string using space as tokenizer
    global userList
    userList = userString.split(" ")
    # User entered string =  Oprah Winfrey : Be thankful for what you have; you'l end up having more.
    # userString =  ['Oprah', 'Winfrey', ':', 'Be', 'thankful', 'for', 'what', 'you', 'have;', "you'l", 'end', 'up', 'having', 'more.']

    #assign global variable to the user  string word count
    global userCount
    userCount = len(userList)

    #get the minumum of word count between quote provided and User entry
    minWordCount = quoteCount

    #check if minCount is greater than userCount and if so, assign userCount to minCount
    if minWordCount > userCount:
        minWordCount = userCount

    return minWordCount

3b: (ii)

def compareQuoteToUserString(userInputString, metricChoice):
....
    else:
        while loopIndex < minCount:
            if quoteList[loopIndex] == userList[loopIndex]:
                correctList.append(userList[loopIndex])
            else:
                print("Error! : ", userList[loopIndex], " : at word# =>", loopIndex)
                errorScore = errorScore + 1
                errorList.append(userList[loopIndex])
            loopIndex += 1
        return errorScore

3c(i)

    def compareQuoteToUserString(userInputString, metricChoice):

    # call procedure to split strings based on space tokens
    global minCount
    minCount = splitStringsIntoList(userInputString)

    # loop through quoteSplit list and userSplit list and compare each word in it
    # loopIndex is the incremental counter to execute the loop
    # compare words in quoteList to user list to check for errors,  using the loopIndex as the array element index
    #after comparison, we go to the second word by increasing loopIndex
    #we stop the loop when loopIndex == minCount

    #global variables accessed in function
    global correctList
    global errorList
    global typingSpeed
    global userCount
    global quoteCount

    #local variables
    loopIndex = 0
    errorScore = 0

    if metricChoice == 'T':
        #calculate time it took for user input
        timeTaken = endTime - startTime
        return timeTaken
    else:
        while loopIndex < minCount:
            if quoteList[loopIndex] == userList[loopIndex]:
                correctList.append(userList[loopIndex])
            else:
                print("Error! : ", userList[loopIndex], " : at word# =>", loopIndex)
                errorScore = errorScore + 1
                errorList.append(userList[loopIndex])
            loopIndex += 1
        return errorScore
    

3c(ii)

  while True:
    ....
**    userScore = compareQuoteToUserString(userString, metricChoice)**

    #Based on user's choice of what to measure, display the appropriate scores.

    if metricChoice == 'A':
        # 3. display error score
        displayErrorList(userScore)
        calculatePercentages(userScore, False)

        # 4. display correct score
        correctCount = displayCorrectScore(userScore)
        calculatePercentages(correctCount, True)
    else:
        #calculate the speed of typing - total words in reference quote over user time taken
        wordsPerMinute = quoteCount/userScore
        print("\n" + "Time Taken = ", userScore, "Words/Minute = ", wordsPerMinute)

3d: